Chatbots

Architecture Decisions

Dialogflow

Implement the intent

Guide: Google Documenation

Model your Dialog

Here is the plantuml activity diagram

"Manage BMI" Dialog

Create a "Default Welcome Intent" with answers: "Hi I am your personal trainer, let me advice you on your health. I can currently calculate your BMI, store the BMI and advices you on your BMI."

Implement a "mange_bmi" intent

After creating the intent add training phrases and activate webhook fulfilment (this is required to check if allready a user exists for this profile):

Do the same for the update_bmi intent (training phrase: My hight is 177 cm, I weigh 80 kg and my birthday is 19.12.1987). How to handle partial dates (https://miningbusinessdata.com/dialogflow-tutorial-setting-context-from-your-inline-webhook-using-contextout/)

Implement the fulfilment

Using Firebase

To start it makes sense to implement all fulfillments in one webhook on firebases. Later for more complex logic it is adviced to move this logic to it's own webhooks that are then called from the fulfillment webhook. For more details see the later section.

Setup Firebase (https://den.gitbook.io/developerplaybook/services-api/firebase)

mkdir fulfillment-router
firebase login
firebase init

Guide: Google Documentation

  • "we highly recommend that you use the Node.js client library to process requests and return responses"

Using a Webhook with AWS Lambda

First build a webhook with a fullfilment router

https://medium.com/@pallavtrivedi03/how-to-make-a-webhook-for-dialogflow-fulfillment-d02835cc50bf

Test a chatbot - manually & unit test

Connect the Chatbot to Facebook Messanger

Integrate fulfilment with REST Python AWS Lambda (e.g. "analyse my bmi trend")

Sample: https://github.com/miningbusinessdata/apiai-python-webhook/blob/master/app.py

Last updated