In this video, I will explain how you can connect Chatfuel to Dialogflow so you can use Google's AI in your Messneger chatbot.
With this integration, you can:
Understand the intent of the user and reply with a Chatfuel block
Handle entities and use the value of entities in your Chatfuel flow
And even handle multiple languages inside your Chatfuel chatbot by using DialogFlow
The best part: the first two months it’s free and after that, it will only cost you $5 per month!
Get $100 credit on Digital Ocean: https://chatimize.com/digital-ocean/
Get started with Chatfuel: https://chatimize.com/cf/
Dialogflow tutorials:
If you want more videos on how you can use chatbots in your marketing, subscribe to my channel👇
/ @chatimize
---
Copy the code from Github
First, you need to copy the code from my Github account to your Github account:
1. Log in to Github
2. Go to Repositories → New
3. Fill in the repository name and set it on "Private"
4. Click on "Import code" and fill in https://github.com/chatimize/chatfuel...
5. And then click on "Begin Import"
After you've copied the files, note that we need to change two files:
1. Config.json
2. chatfuel-dialogflow.py
---
Create Google Cloud project
After we've copied the code from Github, we need to create a new Google Cloud project:
1. Go to https://console.cloud.google.com/
2. Click on the list of projects and then on "New Project"
3. Fill in the Project name and click on "Create"
---
Create Google Service Account Key Page:
1. Go to https://cloud.google.com/docs/authent...
2. Click on "Go to the Create Service Account Key Page"
3. Here, you need to choose the right Google Project
4. Fill in your service account name and click on "Create and Continue"
5. Set the Role to "Owner" and click on "Continue"
6. Click on "Done"
7. Click on the service account in the overview, and then click on "Keys"
8. Click on "Add Key" and choose "JSON" as your key type.
Automatically, the JSON key will be saved to your computer.
Once you have the JSON key, you need to go to your config.json file, click on "Edit" and paste the JSON key there.
---
Create agent in DialogFlow and get Project ID
1. Go to DialogFlow (https://dialogflow.cloud.google.com) and create an agent
2. Then go to the Settings
3. And copy the Project ID under "Google Project"
Then, you need to go to chatfuel-dialogflow.py in Github and paste the Project ID in that file.
Get Chatfuel Bot ID
Go to your Chatfuel chatbot
Copy the characters after /bot/ in the URL bar
Then, you need to go to chatfuel-dialogflow.py in Github and paste the Chatfuelbot ID in that file.
Get Chatfuel API Key
1. Go to Configure in Chatfuel
2. Scroll down until you see "Broadcasting API Token"
3. Here you can find your API key and you need to copy it
4. Also paste this key to chatfuel-dialogflow.py
---
Host code on Digital Ocean
Get $100 credit on Digital Ocean for 60 days: https://chatimize.com/digital-ocean/
1. Sign up for Digital Ocean
2. Click on "Create" and then on "Apps"
3. Link your Github account to Digital Ocean
4. Choose the right repository and click on "Next" (2 times)
5. Select the Basic plan
6. Set the Basic size to $5/mo and click on "Launch"
---
Create Default Answer in Chatfuel
1. Go to Chatfuel, click on "Blocks" under "Automation"
2. There, click on the "Default Answer"
3. Set the User Attribute "{{language_code}}" to "en"
4. Set the JSON API element
5. Set the type to Post, add the URL of the Digital Ocean app in the request URL and set the request body to:
{
“messenger_user_id”: “{{messenger user id}}“,
“last_input”:”{{last user freeform input}}“,
“language_code”:”{{language_code}}”
}
---
Create Response Block in Chatfuel
In Chatfuel, you can just create a random block and you need to the part after /structure/ in the URL bar to your clipboard.
---
Create Intent in DF with response in Chatfuel
Then in DialogFlow, you can just add an intent to your agent, for example, "order.pizza"
After that, you need to set the Response to Custom Payload with {"block":"6125bfenv82nngrgrj"}
NOTE: Use double parentheses in the custom payload, single parentheses will not work!
---
Contents:
Intro: (00:00)
The chatbot strategy: (00:22)
Copy code from Github: (02:00)
Create Google Cloud project: (03:22)
Create Google Service Account Key: (03:54)
Create agent in DialogFlow and get Project ID: (05:41)
Get Chatfuel Bot ID: (06:48)
Get Chatfuel API Key: (07:10)
Host code on Digital Ocean: (07:40)
Create Default Answer in Chatfuel: (10:12)
Create Response Block in Chatfuel: (11:59)
Create Intent in DF with response in Chatfuel: (12:30)
Handle entities in DF and send to Chatfuel: (13:58)
Understand multiple languages with DialogFlow and Chatfuel: (18:06)