Sunday, August 13, 2017

Developer’s tools for quick chatbot prototyping: Chatfuel + Gomix + QnAMaker

One day, one of my colleagues asked me a question:
“What tools do you recommend for quickly building a chatbot?”
I knew that she was taking part in a weekly hackathon session with our client where they would quickly brainstorm different ideas, prototype them and make a presentation with a working demo. I also knew that she was a great software developer who could write code on anything from Objective-C to Javascript, but she needed to make the chatbot in a maximum of 1-3 days.
Here is the short version of my answer:
  1. Use Chatfuel for all simple user flows.
  2. Use Chatfuel + Gomix if you need more complex logic, persistency or access to external data.
  3. Use Chatfuel + Gomix + Wit.ai/Api.ai/QnAMaker if you need even more complex interactions with Natural Language Understanding (NLU) and work with a lot of free-form requests from users.
For the purpose of quick chatbot prototyping and even for a first public MVP it’s more than enough technology to build almost everything you need. It’s also not bad for a production release either. Chatfuel is able to serve chatbots with hundreds of thousands of messages per day.
Below is a detailed look at what is available for your disposal at each step.

Ready to build a conversational bot for your business, but confused with the variety of platforms? Let’s talk!

Chatfuel and simple user flows

Almost every chatbot has a tree-like structure, or rather a graph-like structure. It contains edges, vertices, and conditions that direct the user to the correct flow of interactions.
Below is an example of such interactions on My Coffee Shop, a sample bot that I created for the purpose of this article. You can play with this bot in Messenger here and review a backend source code on Gomix.
Simple graph of interactions that you can easily create with Chatfuel
Simple graph of interactions that you can easily create with Chatfuel
Not all chatbots are equal and some chatbot developers are taking a more serious approach, trying to use generative algorithms, deep RNN with LSTM, memory and attention mechanisms for text comprehension and knowledge management.
Here, however, I’m assuming that these advanced mechanisms are still in the research stage rather than in deployment and the majority of chatbot makers want to test the water in the simplest and fastest way possible. By the way, you still have the option to use almost any complex algorithm and generate your own responses with any Deep Learning algorithm through Chatfuel JSON API.
Chat Bots for Business: The Up-To-Date Guide to Building Chat Bots

It’s like a programming tool for kids, but for building chatbots

Chatfuel is like a graphical programming language with a WYSIWYG-style interface. You create blocks, buttons, quick replies and link it all together.
Here’s how it looks to get a user location, call an external API and get a list of stores in the Chatfuel interface.
Chatfuel Block interface for making graphs of conversations
Chatfuel Block interface for making graphs of conversations

Default Answer block captures every unprocessed text

Messages that aren’t directly processed by a block (like those waiting for Quick Replies actions or inputs) pass to a Default Answer block handler where you can make whatever NLU analysis that you want in order to handle them. Alternatively, you can just store them for later analysis  in order to refine your questions to better serve users.
Here is a Default Answer block that captures all such requests and sends them to the API endpoint.
Default Answer captures all requests
Default Answer captures all requests

Store variables and conditions

You can store any user inputs into a variable, or define a block that creates variables based on the position in the graph and use it later for conditions.
Example of using variables `coffee_type` and `milk_type` for JSON Plugin request
Example of using variables coffee_type and milk_type for JSON Plugin request
You can use variables almost anywhere –  as a text output, or as a GET/POST parameter in a JSON Plugin, etc.

“Go To block” feature

It’s a blessing and a curse thing that gives you immense power but can be tricky to debug later if you overuse it.
Ask about milk type only for `Cappuccino` and `Flat White` coffees
Ask about milk type only for Cappuccino and Flat White coffees
But there are a lot of out-of-the-box integrations in Chatfuel that work without any assistance.

Chatfuel AI and Stochastic Responses

Built-in AI can handle various free-form pattern matching so you can catch the phrases and provide the user with the most relevant responses. There’s also a random mechanism in AI that makes it less deterministic and introduces some intrigue into a conversation.
Stochastic AI behaviour
Stochastic AI behaviour
The same random feature is available in Go To blocks as well, so if there are matched criteria you can provide a couple of possible outcomes that will be selected randomly.

Some plugins are like huge modules in your program

There are a lot of other plugins, each designed to suit a specific case that you can explore in your own time. They can be seen as a subprogram or as modules in your program. For example Live Chat or Chat Room plugins give you the complete flow of user interactions that you can’t fine tune for small details, but they work well as they are.
List of Chatfuel Plugins
List of Chatfuel Plugins
Or to give another example, Subscriber, Subscriptions List, Google site search, Bing search and RSS Import give you the whole complex web of interactions that enables managing subscriptions and automatic push notifications about new content in your bot without any line of code.

Using JSON API Plugin for complex user flows

This is a window to the outside world where you can send and receive data in your graph flow. It’s the essential link to any external API that you want to connect to. It’s a barebones, powerful plugin and I’m glad the developers didn’t restrict it and are continuing to extend its functionality.
JSON API can return text messages, image/audio/video messages, templates with buttons, templates with quick replies, templates with a gallery and the whole set of airline templates. With its help you can also receive postbacks when the user clicks on return buttons and continue interactions between the user and a backend.
Here’s how I return stores by location zip (though I’m not making a real search here, it’s a demo app so that I can model the process :)
Gomix endpoint returns a gallery of nearby places
Gomix endpoint returns a gallery of nearby places
Search results in a bot:
A gallery of nearby places
A gallery of nearby places
Another useful feature is the ability to set up variables from JSON API to the Chatfuel graph, which is very helpful in controlling complex logic flows.

JSON API Plugin + Gomix

Gomix is a Node.js environment hosted in a cloud where you can edit each file online right in the browser in collaboration with others. So it’s an ideal candidate for quick chatbot prototyping and you can use it as a connection between Chatfuel JSON API Plugin and any other external API.
Yes, it’s easier than Digital Ocean Node.js server or Amazon’s Lambda function; just try it on the backend of my sample My Coffee Shop bot.
Here’s how I serve coffee for My Coffee Shop customers through the Giphy API on Gomix.
Order Coffee endpoint returns Giphy image by ‘coffee_type’ and ‘milk_type’
Order Coffee endpoint returns Giphy image by ‘coffee_type’ and ‘milk_type’
And from the user’s point of view.
Order coffee user flow
Order coffee user flow

Add even more power with Wit.ai/Api.ai/QnAMaker integrations for Natural Language Understanding (NLU)

Not everything is so simple in chatbot text interactions and sometimes you need a better understanding of the input text. The beauty of Gomix is that it’s an unrestricted Node.js environment and you can use it to call any third party API and have the power of Javascript to process responses.
Here’s an example using Microsoft’s QnAMaker.ai for processing user inputs that were not captured by a Chatfuel flow.
QnAMaker.ai integration with Chatfuel
QnAMaker.ai integration with Chatfuel
From the user’s perspective.
FAQ user flow inside the bot
FAQ user flow inside the bot
So I think you’ve got the idea, it’s just API calls with some processing.

Chatbot Analytics

Whatever chatbot prototype you are building you need to measure all the important metrics, such as popular user utterances, popular blocks, user retention, etc. Such high level metrics are all available in Chatfuel Analytics.
Analytics Activity for a Bot
However, if you connect a Yandex.Metric account to a Chatfuel Analytics page you will have access to all events in .csv or .json format through the Yandex Logs API.
Ready to build a conversational bot for your business, but confused with the variety of platforms? Let’s talk!

Summary

Chatbots constitute a new paradigm shift in technology, allowing us to build apps right inside messenger platforms so the user doesn’t need to download and install them separately.
As Benedict Evans pointed out, we are on the edge of Mobile 2.0 transformations and we are going to keep building on top of other apps (What’s App micro apps, Messenger bots, Skype bots, Google Maps integration, Amazon Alexa Voice skills, etc.) rather than for just mobile.
In today’s rapidly changing technological landscape, time to market matters more than sophistication and cost of development matters more than having a state-of-the-art conversational algorithm.
As a chatbot service provider we understand the need to use existing technology and move really quickly in order to deliver meaningful value for our customers. Later on when you have validated your idea and see that people love your chatbot you can build it on top of the best AI algorithms and make your own Facebook API integration, but before this happens I think it makes a lot of sense to use existing solutions for experiments and first trials.
Unless, of course, you want to push an AI research community forwards, but this is a completely different story and a topic for the next article.
Happy chatbot building!

2 comments:

  1. We have to thank and share such a nice blog post and interesting information. It is helpful for develop my knowledge, people always searching for this type of posts.
    Chatbot Developers in Dubai
    Facebook Chatbot in Dubai
    AI Chatbot in Dubai
    Artificial intelligence Company in Dubai

    ReplyDelete
  2. They’re really convincing and will definitely work. Still, the posts are too brief for newbies. May you please extend them a little from subsequent time?Also, I’ve shared your website in my social networks.
    Chatbot Company in Dubai
    Chatbot Companies in Dubai
    Chatbot Development
    AI Chatbot Development
    Chatbot Companies in UAE
    Chatbot Company in Chennai
    Chatbot Company in Mumbai
    Chatbot Company in Delhi
    Chatbot Development Companies

    ReplyDelete