Sitemap

Chatbots Life

Best place to learn about Conversational AI. We share the latest News, Info, AI & NLP, Tools, Tutorials & More.

Chatbot using django rest framework + api.ai + slack — Part 1/3

3 min readJan 18, 2017

--

In this three part blog, I will go over design and development of an events chatbot using custom backend built with Django Rest Framework, API.AI and Slack.

Parts

  1. Chatbot definition, architecture and API.ai agent setup.
  2. Steps to integrate DRF, API.AI, and Slack to get basic responses from your backend.
  3. Steps to send rich Slack message from your backend.

Chatbot

First step is to clearly define the bot’s purpose. We want our events chatbot to show a list of events with all the relevant information only when it is prompted. Information includes event’s title, start and end time, location, link to maps and calendar. Prompt can be anything from the list below or a variation:

  • hey, what are the events on Christmas?
  • events tomorrow
  • events day after tomorrow
  • events on Dec 21
  • events tomorrow afternoon
  • events with free beer
  • events on python tomorrow evening
  • ….

Architecture

In the block diagram below, I show the interactions between Django, API.ai, and Slack. Each of these blocks play a specific role.

Press enter or click to view image in full size
Chatbot architecture

Slack is the only interface that the user interacts with. Chatbot resides in Slack. Bot’s response is rich in nature with cards, links to maps, calendar and other apps.

Get Santi Adavani’s stories in your inbox

Join Medium for free to get updates from this writer.

API.AI is the natural language processing (NLP) brains that translates user’s prompt to structured data with intents, entities and contexts.

Django has the business logic to query the database based on intents, entities and contexts from API.ai and create rich slack messages.

API.AI setup

Refer to this very well written tutorial for setting a basic bot in API.ai. I will go over the methodology to create intents for events bot. All the prompts above may look very similar. However, for a prompt like “events tomorrow” we are only looking for tomorrow’s date to list all events and for a prompt like “events tomorrow evening” we are looking for a date and time-range. So, it is important to split the prompts into multiple sections in order to setup the agent. We will split them into two sections, which will be our intents.

Get events for a date

Press enter or click to view image in full size
User prompts for Events for a given date

Get events for a date and time range

Press enter or click to view image in full size
User prompts for Events for a given date and time range

Try out API.AI test console

Check the date and time-period for different variations of the prompts.

Press enter or click to view image in full size

In part 2, I will go over steps involved in creating and deploying DRF app, enabling webhook in API.AI, and starting the bot in a slack channel.

--

--

Chatbots Life
Chatbots Life

Published in Chatbots Life

Best place to learn about Conversational AI. We share the latest News, Info, AI & NLP, Tools, Tutorials & More.

Santi Adavani
Santi Adavani

Written by Santi Adavani

Founder, RocketML-SpaceX for Machine Learning (rocketml.net)

Responses (10)