3.1.16 Bi-Directional Twilio
This document gives an overview of how to use the Twilio node and configure a sample flow in Experience Designer for a bi-directional conversation using SMS.
When a mobile phone user sends an SMS to the Twilio phone number, Orbita recognizes the intent and replies back with an SMS (which contains the configured response for that intent) to the user via the Twilio phone number.
Prerequisites
Registered Twilio account.
Twilio-powered Phone number.
Experience Designer
Import the below flow to the Experience Designer.
[ { "id": "fc3d6a5b.e921e8", "type": "http in", "z": "8a8b3a1.0b8abc8", "name": "Twilio - SMS", "url": "/twilio/message", "method": "post", "upload": false, "swaggerDoc": "", "x": 90, "y": 440, "wires": [ [ "ce22e0f2.724c2", "e6e548b3.6bb298" ] ] }, { "id": "e6e548b3.6bb298", "type": "function", "z": "8a8b3a1.0b8abc8", "name": "Post Process", "func": "var _ = global.get('lodash');\nvar text = _.get(msg, 'payload.Body',null);\nmsg.payload.text = text;\nmsg.payload.sessionId = _.get(msg, 'req.sessionID', '');\nreturn msg;\n", "outputs": 1, "noerr": 0, "x": 270, "y": 440, "wires": [ [ "3ab2c841.9b1d28", "8db04496.f15b38" ] ] }, { "id": "3ab2c841.9b1d28", "type": "orbita-bot-provider-v2", "z": "8a8b3a1.0b8abc8", "name": "", "botInParser": "", "botOutParser": "", "transcriptEnabled": false, "ttsconfig": "{\n \"languageCode\": \"en-US\",\n \"ssmlGender\": \"FEMALE\",\n \"name\": \"en-US-Standard-C\",\n \"audioEncoding\": \"MP3\"\n }", "providerType": "Google", "skillConfig": "496cb5db.ebb6fc", "token": "", "noerr": 0, "agentId": "", "nlpData": false, "x": 460, "y": 440, "wires": [ [ "7c190c7f.9afab4", "70f78986.278088" ] ] }, { "id": "7c190c7f.9afab4", "type": "function", "z": "8a8b3a1.0b8abc8", "name": "Process", "func": "const utils = global.get('orbitaUtil');\nmsg.text = utils.sanitizeSimpleHtmlText(msg.payload.orbitaPayload.payload.multiagent.chat.chatText);\nreturn msg;", "outputs": 1, "noerr": 0, "x": 640, "y": 440, "wires": [ [ "97de6336.c9e2e" ] ] }, { "id": "97de6336.c9e2e", "type": "template", "z": "8a8b3a1.0b8abc8", "name": "Respond", "field": "payload", "fieldType": "msg", "format": "handlebars", "syntax": "mustache", "template": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Response>\n <Message>{{text}}</Message>\n</Response>\n", "output": "str", "x": 800, "y": 440, "wires": [ [ "5bba4979.cbe6a8" ] ] }, { "id": "5bba4979.cbe6a8", "type": "http response", "z": "8a8b3a1.0b8abc8", "name": "", "statusCode": "", "headers": {}, "x": 950, "y": 440, "wires": [] }, { "id": "496cb5db.ebb6fc", "type": "alexa-skill-config", "skillname": "Documentation Flows", "projectId": "5cf9249637e124a03087780b", "intents": "[]", "skillstate": "", "disableLogging": false }, { "id": "slots", "type": "slots", "z": "", "slots": [] } ]
This will import a flow to your canvas as shown below.
Change the endpoint in the http in node to your liking.
In the above example, it is/twilio/message
.Click on Done and Deploy the Experience Designer flow.
Twilio Configuration
Navigate to Console | Twilio
From the Side navigation bar, select Phone Numbers > Manage > Active Numbers and click on the phone number to go to the configuration page.
On the configuration page, select the “Configure“ tab and scroll down to the Messaging section.
Add the web hook (URL endpoint) you created in the Experience Designer.
In this example, it ishttps://sandbox15.orbita.cloud:8443/oeapi/twilio/message
Best Practices
Do not use special characters in the messages.
Video Content
https://cdn.orbita.cloud/assets/orbita/ivr/bidirectionaltwilio.mp4
Supporting Documentation
No additional supporting documentation