Me, Myself and Chatbot Flow
My previous post was about my struggle with the chatbot. Let’s continue with what is inside of it, technologies I used.
We have started with Microsoft Bot Framework at the end of 2016. With Microsoft engineers, we have attended a workshop in London. As my company is Microsoft Ventures Alumni and we are using C# and Azure Services, it is completely normal.
After a month or two, we have discovered Api.AI (now Dialogflow). What I loved about it was small-talk feature. The Interface was really easy and predefined utterances and intents make things easier.
To summarize, our chatbot uses:
- .Net Framework 4.7 WebApi
- Dialogflow as NLP
- Facebook / Alexa / Actions on Google and Slack API’s
- Azure Web Services
- Chatbase as Analytics
Let’s assume you’re talking with my bot via Facebook.
When you say something to Facebook Bot;
- Facebook sends message to WebApi
- WebApi writes the message into a Queue and returns 200 OK.
- WebJob gets the message from Queue and sends it to Service.
- Service sends the message to Dialogflow and gets the response.
- Based on Dialogflow’s response, Service creates the response.
- Created response send to Facebook. (You see the message in chat window)
- Service does housecleaning (analytics, saving incoming/outgoing messages etc)
I want to go into details here.
Why queue? Most of the messaging platforms have 6–10 seconds of response time requirement. If you do not respond in time, they may unsubscribe you. That’s why we have added a queue layer. In Facebook case, if you do not respond in 6 seconds, it resends the message. A queue also helps continuous deployment / load balancing.
The tricky part is, you can not use this queue system for Google Home and Alexa because they need the response directly. You can not send proactive messages to these platforms. So you skip the queue part in flow go directly to service and return the message.
Dialogflow, supports direct integration with Facebook, Slack, Google Home and many other platforms but Amazon Alexa is not directly supported. When we started the project, we were not sure if we stick to Dialogflow or switch to something else. That’s why we use native API’s of the platforms and used Dialogflow just for NLP.
Next: Architecture of Webhook Service (named as fulfilment in Dialogflow)