Friday, January 15Digital Marketing Journals

Setup Twilio Integration on your server to connect Google Dialogflow | by Pragnakalp Techlabs | Dec, 2020


Pragnakalp Techlabs

Dialogflow has discontinued the one-click integration of Twilio for SMS and instead made the Twilio integration available as open source.

Here, we take you through the process of setting up Twilio integration on your own server to connect Twilio phone number with the Dialogflow agent.

Steps

1. 3 Tips for your Voice and Chatbot Program from Gartner’s Customer Service Hype Cycle 2020

2. Deploying Watson Assistant Web Chat in Salesforce Lightning Console

3. Are Chatbots Vulnerable? Best Practices to Ensure Chatbots Security

4. Your Path to AI — An IBM Developer Series

To simplify it, we have created our own zip file which contains code for twilio only and also we have setup the code to run the server easily.

You can download the zip file by clicking here.

Extract the zip file in the folder and change the working directory to the extracted folder.

2. Now, browse to the directory where you extracted the folder and run

npm install

This will install all the required libraries for the project.

3. Now, download the json file for the service account.

To do that, go to https://dialogflow.cloud.google.com/#/agent/.

Select your agent.

4. Click on the settings button.

5. Now copy the Project id and paste it in the index.js file as value of projectId. Then open service account page in new tab by clicking on the service account.

6. Now on the service account page

Check the project

Check the service account is the same as the previous page

Click on the 3 dots

On clicking on the “create key” you will get the JSON file.

Save the JSON file in the working directory where you have extracted the zip file.

NOTE: the json file and index.js must be in the same directory at the same level.

Now export the path of the json file. By typing in the terminal export GOOGLE_APPLICATION_CREDENTIALS=”/full/path/to/your/json/file”

NOTE: Don’t close the terminal we will start our nodejs server here.

7. Now, the next step is to login to https://www.twilio.com/console.

Copy SID and paste in index.js as value of accountSID.

Copy Authtoken and paste in index.js as value of authToken.

8. Now click on the three dots

9. Click on “programmable sms”.

10. Click on “SMS”.

Click on “+” sign.

11. Give service name and then select mixed from the dropdown.

12. Check the radio button “send an incoming message webhook”.

Keep the window open we will back here to paste the ngrok url in Request URL.

Open index.js file and paste all the required fields.

Now run the node server with node index.js in the terminal where you have exported the path earlier.

Open ngrok in new terminal and type sudo ngrok http 8989

You will get the ngrok URL for your server. Paste it in the Twilio as SEND AN INCOMING MESSAGE WEBHOOK.

Now, the connection of Twilio of Dialogflow is done using the integration we setup. You can test it by sending the SMS.`

Send a message from your mobile to the number purchased from Twilio. You will get a reply from Dialogflow agent.

STEPS TO DEPLOY THE APP ON HEROKU

5. Now install Heroku CLI with

sudo snap install --classic heroku

6. Now run the below command and login with heroku via CLI.

heroku login

5. Now run following three commands one after one.

git add .
git commit -am "Initial commit"
git push heroku master

6. Set environment variable in Heroku

heroku config:set GOOGLE_APPLICATION_CREDENTIALS='YOUR_JSON_FILE_PATH'

Feel free to comment your doubts/questions. We would be glad to help you.

If you are looking for Chatbot Development or Natural Language Processing services then do contact us or send your requirement at letstalk@pragnakalp.com. We would be happy to offer our expert services.

Leave a Reply

Your email address will not be published. Required fields are marked *