Integration between Rocket.Chat and the Dialogflow Chatbot platform
-
Clone this repo and Change Directory:
git clone https://github.com/RocketChat/Apps.Dialogflow.git && cd Apps.Dialogflow/
-
Install the required packages from
package.json
:
npm install
-
Deploy Rocket.Chat app:
rc-apps deploy --url http://localhost:3000 --username user_username --password user_password
Where:http://localhost:3000
is your local server URL (if you are running in another port, change the 3000 to the appropriate port)user_username
is the username of your admin user.user_password
is the password of your admin user.
For more info refer this guide
In order to connect to Dialogflow, this app requires a following credentials from Dialogflow.
1. Project Id
2. Client email
3. Private Key
You can find all these credentials in a JSON file, which u can get from here. Under Create a service account and download the private key file
section there, you will find detailed instruction about how to get the JSON file. After obtaining this JSON file, you can proceed to the next section.
-
First go ahead n create a Bot User. Login as administrator, then goto
Setting > Users
. There create a new Bot User. This new user should have these 2 roles.- bot
- livechat-agent
-
Then configure the app to automatically assign a livechat-visitor to this bot. To do so, goto
Setting > Livechat > Routing
orSetting > Omnichannel > Routing
. There enableAssign new conversations to bot agent
Setting. -
The app needs some configurations to work, so to setup the app Go to
Setting > Apps > Dialogflow
. There, fill all the necessary fields inSETTINGS
and click SAVE. Note all fields are required.Some of the fields in
SETTING
include- Bot Username (required)
- This should contain the same bot username which we created above in Step 1
- Project Id (required)
- This corresponds to
project_id
property of the Google Credentials File obtained fromRocket.Chat Apps Setup
section above
- This corresponds to
- Client Email (required)
- This corresponds to
client_email
property of the Google Credentials File obtained fromRocket.Chat Apps Setup
section above
- This corresponds to
- Private Key (required)
- This corresponds to
private_key
property of the Google Credentials File obtained fromRocket.Chat Apps Setup
section above. - Kindly note that this value will be very long. So please take extra care while copy/paste.
- This corresponds to
- Fallback Responses Limit (optional)
- The app will automatically trigger handover if consecutive
fallback
intents are triggeredN
no of times. This setting defines this valueN
. - Eg. Suppose the bot is not able to answer visitor's consecutive 3 answers, and this setting threshold is
3
. In such case, the app will trigger an handover to an online agent on its own. - To Deactivate this feature, simply set the value to
0
.
- The app will automatically trigger handover if consecutive
- Target Department for Handover (optional)
- Enter the department name where you want the visitor to be transferred upon handover.
- Handover Message (optional)
- The Bot will send this message to Visitor upon handover
- Service Unavailable Message (optional)
- The Bot will send this message to Visitor if service is unavailable like suppose if no agents are online.
- Close Chat Message (optional)
- This message will be sent automatically when a chat is closed
- Hide Quick Replies (required)
- If enabled, then all quick-replies will hide when a visitor clicks on any one of them
- Bot Username (required)
-
(Optional Step) Lastly you can test your Dialogflow Connection by viewing App Logs. To view the logs, goto App Page (
Setting > Apps > Dialogflow
). There click on menu item (3 vertical dots icon) and then selectView Logs
. There select the most recentonSettingUpdated
title. If you see------------------ Google Credentials validation Success ----------------
message, then it means your setup is fine. If you don't see this message, then recheck your Dialogflow credentials.
The app provides API to trigger specific actions. The URL for the API can be found on the Apps Page(Setting > Apps > Dialogflow
). Currently the app provides 2 APIs.
-
Incoming API/Endpoint
This endpoint can be used to trigger specific actions. The list of supported actions include
- Close Chat
To close a chat- REST API Documentation for this endpoint can be found here
- Handover
To perform a handover- REST API Documentation for this endpoint can be found here
- Trigger Event
To trigger an event on Dialogflow- REST API Documentation for this endpoint can be found here
- Send-Message
To send a message as a bot to Visitor- REST API Documentation for this endpoint can be found here
- Close Chat
-
Fulfillment API/Endpoint
The fulfillment endpoint will enable the app to handle asynchronous messages. More information on it here
- To add quick Replies you can make use of
Custom-Payload
for Responses on Dialogflow Console. (Under any Intent > Responses > Add Responses > Custom Payload
) - A box labelled
Custom Payload
will appear. There enter theQuick Replies
you want following the format here