Cloudkibo / KiboPush

0 stars 1 forks source link

DialogFlow integration with KiboPush #6948

Open sojharo opened 5 years ago

sojharo commented 5 years ago

This is an investigation issue for looking into how we can integrate KiboPush with DialogFlow. As an start, we can read from following two resources on what ChatFuel is doing this.

https://miningbusinessdata.com/integrating-chatfuel-dialogflow/

https://medium.com/@activechat/dialogflow-api-ai-to-chatfuel-integration-easy-as-1-2-3-with-integrator-729798e21b8

sojharo commented 5 years ago

I looked into it yesterday. ChatFuel doesn't give native integration with Dialogflow but there are 3rd party tools and solutions which provide this integration. The integration is detailed enough to the point that they let us define each component or block of chatfuel to trigger on matching on any intent in dialogflow.

1st Third Party Solution

This person has written some PHP scripts that we can run on any server environment to support integration. He is doing following steps with these PHP files:

Now, main thing in chatfuel to do is to setup the session id for subscriber in user attribute as first thing welcome message. This session id will serve as session or context id in dialogflow. Chatfuel has blocks such as "user attribute" and "use json api". They are for now used to get and store sessoins id for our subscriber from our PHP scripts.

After this, capture the user message and save in user attribute and goto next block defined as NextStep. Use JSON API block again to send the user query to your script. It will call dialogflow and send the response back into JSON API which will output the answer to user on messenger.

We can then repeat the same process for next questions.

2nd Solution - ActiveChat.ai platform to do integration

According to their definition:

We’ve launched our own visual chatbot platform and there’s no more need for complex integrations (like Chatfuel+Dialogflow+Integrator, described in this article). Activechat.ai visual chatbot builder has everything you need — visual conversation flow, skills and intents, and direct Dialogflow integration for advanced natural language processing. It seems to be a bit more flexible and powerful than Chatfuel

https://activechat.ai

They tend to be competitor of ChatFuel and are saying alongwith many features, we have native integration with Dialogflow. This is basically what we need to do with KiboPush. There should not be any external code or service do integration. We should natively support Dialogflow integration in such a way that we can use dialogflow at any point during bot development in KiboPush and can call the integration from any place.

However, they also provide free integrator which can serve as external service to integrate ChatFuel with Dialogflow. This service will be called from ChatFuel's default block. This block is called when user input could not be recognized and we want to send then generic fallback message. In this block, now we will call ActiveChat's integrator endpoint using JSON API plugin. That integrator will call the dialogflow agent and return the response.

We can send the response as it is to subscriber or trigger any block of ChatFuel to send rich message. The integrator has the UI for settings where we can map dialogflow intents matched with blocks from chatfuel. We can just copy the blocks name and paste there and integrator will take care of calling the block.

They also take care of mapping entities values with user attributes in ChatFuel. User attributes is same as custom fields that we have in KiboPush. This will be done automatically if any intent is matched which contains entities.

Next step in this is to do simple design to let user do integration with dialogflow from KiboPush.

sojharo commented 5 years ago

Imran and I have reviewed it together and have created following discussion document:

https://docs.google.com/document/d/1_fakGFVJ2Oane4LWjKmRTJredWFaaHGJYL_WAOdS4vI/edit#

It also contains my above comment.

sojharo commented 5 years ago

As discussed in meeting, we will be doing this work after 3 months, I am marking it as deferred

jekram commented 5 years ago

@sojharo @ImranBinShoukat Good job ... Thanks