{"_id":"5845a4a99f6fbb1b00430801","user":"55bf6cdcad601c2b00762d13","__v":0,"version":{"_id":"5845a4a89f6fbb1b004307b7","project":"54d3007669578e0d002730c9","__v":2,"createdAt":"2016-12-05T17:32:24.708Z","releaseDate":"2016-12-05T17:32:24.708Z","categories":["5845a4a89f6fbb1b004307b8","5845a4a89f6fbb1b004307b9","5845a4a89f6fbb1b004307ba","5845a4a89f6fbb1b004307bb","5845a4a89f6fbb1b004307bc","5845a4a89f6fbb1b004307bd","5845a4a89f6fbb1b004307be","5845a4a89f6fbb1b004307bf","5845a4a89f6fbb1b004307c0","592deb23644f060f008e5aa6"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"25.0.0","version":"25"},"category":{"_id":"5845a4a89f6fbb1b004307bd","project":"54d3007669578e0d002730c9","__v":0,"version":"5845a4a89f6fbb1b004307b7","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-07-08T18:48:02.369Z","from_sync":false,"order":5,"slug":"integrations","title":"Integrations"},"parentDoc":null,"project":"54d3007669578e0d002730c9","updates":["5744ddb411628d0e009a766f"],"next":{"pages":[],"description":""},"createdAt":"2016-05-16T04:39:47.550Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":13,"body":"* [Overview](#overview)\n* [Video](#video)\n* [Creating a Messaging Service in Twilio](#creating-a-messaging-service-in-twilio)\n* [Integrating API.AI Agent with Twilio Messaging Service](#integrating-apiai-agent-with-twilio-messaging-serv)\n* [Configuring Request URL in Twilio Messaging Service](#configuring-request-url-in-twilio-messaging-servic)\n* [Testing Your Bot](#testing-your-bot)\n* [Hosting Twilio Bot with Heroku](#hosting-twilio-bot-with-heroku)\n * [Creating a Messaging Service in Twilio](#section-creating-a-messaging-service-in-twilio)\n * [Integrating API.AI Agent with Twilio Messaging Service and Heroku Hosting](#section-integrating-api-ai-agent-with-twilio-messaging-service-and-heroku-hosting)\n* [Hosting Bots on Your Server](#hosting-bots-on-your-server)  \n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Overview\"\n}\n[/block]\n**API.AI Twilio Integration** for SMS allows you to easily create Twilio bots with natural language understanding based on the API.AI technology.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Video\"\n}\n[/block]\nWatch this video on how to integrate your API.AI agent with Twilio Messaging Services. Or you can follow the steps described in the documentation [below](#creating-a-messaging-service-in-twilio).\n[block:embed]\n{\n  \"html\": \"<iframe class=\\\"embedly-embed\\\" src=\\\"//cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FEERuCsGH3rc%3Ffeature%3Doembed&url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DEERuCsGH3rc&image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FEERuCsGH3rc%2Fhqdefault.jpg&key=02466f963b9b4bb8845a05b53d3235d7&type=text%2Fhtml&schema=youtube\\\" width=\\\"640\\\" height=\\\"480\\\" scrolling=\\\"no\\\" frameborder=\\\"0\\\" allowfullscreen></iframe>\",\n  \"url\": \"https://www.youtube.com/watch?v=EERuCsGH3rc&feature=youtu.be\",\n  \"title\": \"Build Twilio bots with Api.ai\",\n  \"favicon\": \"https://s.ytimg.com/yts/img/favicon-vflz7uhzw.ico\",\n  \"image\": \"https://i.ytimg.com/vi/EERuCsGH3rc/hqdefault.jpg\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Creating a Messaging Service in Twilio\"\n}\n[/block]\nIn your Twilio account, go to **Products > Programmable SMS**:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/lHLteUbUQkifaJc2ET7a_Twilio-choose-Programmable-SMS.png\",\n        \"Twilio-choose-Programmable-SMS.png\",\n        \"2254\",\n        \"1478\",\n        \"#bf0f0d\",\n        \"\"\n      ],\n      \"sizing\": \"full\"\n    }\n  ]\n}\n[/block]\nThen, select **Messaging Services**:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/fFmRiVe3S42LRcg3p0s8_Twilio-Messaging-Services.png\",\n        \"Twilio-Messaging-Services.png\",\n        \"2246\",\n        \"1300\",\n        \"#c10e0c\",\n        \"\"\n      ],\n      \"sizing\": \"full\"\n    }\n  ]\n}\n[/block]\nClick on ‘**Create a Messaging Service**’ and go through the set-up process.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/5DI3itx7SAGe89lplS9I_Twilio-create-messaging-service.png\",\n        \"Twilio-create-messaging-service.png\",\n        \"2250\",\n        \"1082\",\n        \"#ba0707\",\n        \"\"\n      ],\n      \"sizing\": \"full\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Integrating API.AI Agent with Twilio Messaging Service\"\n}\n[/block]\n<a href=\"https://console.api.ai/api-client/#/newAgent\" target=\"_blank\">Create an API.AI agent</a> with the help of the <a href=\"https://docs.api.ai/docs/key-concepts\" target=\"_blank\">API.AI NLU technology tools</a>.\n\nTo enable Twilio Integration, click ‘Integrations’ from the left side menu and turn Twilio integration on.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/FhaonCYaShmxdCE7blFY_Twilio-integration-enable.png\",\n        \"Twilio-integration-enable.png\",\n        \"2076\",\n        \"988\",\n        \"#2d9be0\",\n        \"\"\n      ],\n      \"sizing\": \"full\"\n    }\n  ]\n}\n[/block]\nThen, click 'Start' and copy the Request URL.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/8XHFhGoiQNmI4BgrIvHf_Twilio-integration-copy-Request-URL.png\",\n        \"Twilio-integration-copy-Request-URL.png\",\n        \"2226\",\n        \"1240\",\n        \"#695cc8\",\n        \"\"\n      ],\n      \"sizing\": \"full\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Configuring Request URL in Twilio Messaging Service\"\n}\n[/block]\nIn your Twilio account, in the Phone Numbers list, select the messaging service that you want to integrate with your API.AI agent.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/Yn5ysseFQueSC79Ou4GQ_Twilio-phones.png\",\n        \"Twilio-phones.png\",\n        \"2024\",\n        \"1164\",\n        \"#b62b2c\",\n        \"\"\n      ],\n      \"sizing\": \"full\"\n    }\n  ]\n}\n[/block]\nIn the pop-up window, insert the Request URL that you’ve copied in your API.AI agent settings and click ‘Save’.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/dc1Uq2a0Tn6kKvefiLNF_Twilio-request-URL.png\",\n        \"Twilio-request-URL.png\",\n        \"1594\",\n        \"674\",\n        \"#1d6038\",\n        \"\"\n      ],\n      \"sizing\": \"80\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Testing Your Bot\"\n}\n[/block]\nTest your bot sending text messages to the messaging service number.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/hS6x9J8lS5WSNtJa0W3z_Twilio-Test.png\",\n        \"Twilio-Test.png\",\n        \"1440\",\n        \"2560\",\n        \"#e69311\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Hosting Twilio Bot with Heroku\"\n}\n[/block]\n## Creating a Messaging Service in Twilio\n\nCreate a Messaging Service in Twilio as described [here](#creating-a-messaging-service-in-twilio).\n\n## Integrating API.AI Agent with Twilio Messaging Service and Heroku Hosting\n\n<a href=\"https://console.api.ai/api-client/#/newAgent\" target=\"_blank\">Create an API.AI agent</a> with the help of the <a href=\"https://docs.api.ai/docs/key-concepts\" target=\"_blank\">API.AI NLU technology tools</a>.\n\nIn your API.AI agent, go to 'Integrations' from the left side menu, enable Twilio integration, and then, ‘Deploy to Heroku’. \n\nOn the Heroku page, insert your app name, make sure that the language settings are the same as in your API.AI agent, and click 'Deploy for Free'.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/49p2LuSAQBC0BHF5HFBL_Twilio-Heroku.png\",\n        \"Twilio-Heroku.png\",\n        \"1878\",\n        \"1432\",\n        \"#5e458f\",\n        \"\"\n      ],\n      \"sizing\": \"full\"\n    }\n  ]\n}\n[/block]\nAfter your Heroku app has been successfully deployed, you can test your Twilio bot.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Hosting Bots on Your Server\"\n}\n[/block]\nYou can use our source code from <a href=\"https://github.com/api-ai/apiai-nodejs-client/tree/master/samples/twilio/bot\">github</a> to create your custom Twilio bots.","excerpt":"","slug":"twilio-integration","type":"basic","title":"Twilio"}
* [Overview](#overview) * [Video](#video) * [Creating a Messaging Service in Twilio](#creating-a-messaging-service-in-twilio) * [Integrating API.AI Agent with Twilio Messaging Service](#integrating-apiai-agent-with-twilio-messaging-serv) * [Configuring Request URL in Twilio Messaging Service](#configuring-request-url-in-twilio-messaging-servic) * [Testing Your Bot](#testing-your-bot) * [Hosting Twilio Bot with Heroku](#hosting-twilio-bot-with-heroku) * [Creating a Messaging Service in Twilio](#section-creating-a-messaging-service-in-twilio) * [Integrating API.AI Agent with Twilio Messaging Service and Heroku Hosting](#section-integrating-api-ai-agent-with-twilio-messaging-service-and-heroku-hosting) * [Hosting Bots on Your Server](#hosting-bots-on-your-server) [block:api-header] { "type": "basic", "title": "Overview" } [/block] **API.AI Twilio Integration** for SMS allows you to easily create Twilio bots with natural language understanding based on the API.AI technology. [block:api-header] { "type": "basic", "title": "Video" } [/block] Watch this video on how to integrate your API.AI agent with Twilio Messaging Services. Or you can follow the steps described in the documentation [below](#creating-a-messaging-service-in-twilio). [block:embed] { "html": "<iframe class=\"embedly-embed\" src=\"//cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FEERuCsGH3rc%3Ffeature%3Doembed&url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DEERuCsGH3rc&image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FEERuCsGH3rc%2Fhqdefault.jpg&key=02466f963b9b4bb8845a05b53d3235d7&type=text%2Fhtml&schema=youtube\" width=\"640\" height=\"480\" scrolling=\"no\" frameborder=\"0\" allowfullscreen></iframe>", "url": "https://www.youtube.com/watch?v=EERuCsGH3rc&feature=youtu.be", "title": "Build Twilio bots with Api.ai", "favicon": "https://s.ytimg.com/yts/img/favicon-vflz7uhzw.ico", "image": "https://i.ytimg.com/vi/EERuCsGH3rc/hqdefault.jpg" } [/block] [block:api-header] { "type": "basic", "title": "Creating a Messaging Service in Twilio" } [/block] In your Twilio account, go to **Products > Programmable SMS**: [block:image] { "images": [ { "image": [ "https://files.readme.io/lHLteUbUQkifaJc2ET7a_Twilio-choose-Programmable-SMS.png", "Twilio-choose-Programmable-SMS.png", "2254", "1478", "#bf0f0d", "" ], "sizing": "full" } ] } [/block] Then, select **Messaging Services**: [block:image] { "images": [ { "image": [ "https://files.readme.io/fFmRiVe3S42LRcg3p0s8_Twilio-Messaging-Services.png", "Twilio-Messaging-Services.png", "2246", "1300", "#c10e0c", "" ], "sizing": "full" } ] } [/block] Click on ‘**Create a Messaging Service**’ and go through the set-up process. [block:image] { "images": [ { "image": [ "https://files.readme.io/5DI3itx7SAGe89lplS9I_Twilio-create-messaging-service.png", "Twilio-create-messaging-service.png", "2250", "1082", "#ba0707", "" ], "sizing": "full" } ] } [/block] [block:api-header] { "type": "basic", "title": "Integrating API.AI Agent with Twilio Messaging Service" } [/block] <a href="https://console.api.ai/api-client/#/newAgent" target="_blank">Create an API.AI agent</a> with the help of the <a href="https://docs.api.ai/docs/key-concepts" target="_blank">API.AI NLU technology tools</a>. To enable Twilio Integration, click ‘Integrations’ from the left side menu and turn Twilio integration on. [block:image] { "images": [ { "image": [ "https://files.readme.io/FhaonCYaShmxdCE7blFY_Twilio-integration-enable.png", "Twilio-integration-enable.png", "2076", "988", "#2d9be0", "" ], "sizing": "full" } ] } [/block] Then, click 'Start' and copy the Request URL. [block:image] { "images": [ { "image": [ "https://files.readme.io/8XHFhGoiQNmI4BgrIvHf_Twilio-integration-copy-Request-URL.png", "Twilio-integration-copy-Request-URL.png", "2226", "1240", "#695cc8", "" ], "sizing": "full" } ] } [/block] [block:api-header] { "type": "basic", "title": "Configuring Request URL in Twilio Messaging Service" } [/block] In your Twilio account, in the Phone Numbers list, select the messaging service that you want to integrate with your API.AI agent. [block:image] { "images": [ { "image": [ "https://files.readme.io/Yn5ysseFQueSC79Ou4GQ_Twilio-phones.png", "Twilio-phones.png", "2024", "1164", "#b62b2c", "" ], "sizing": "full" } ] } [/block] In the pop-up window, insert the Request URL that you’ve copied in your API.AI agent settings and click ‘Save’. [block:image] { "images": [ { "image": [ "https://files.readme.io/dc1Uq2a0Tn6kKvefiLNF_Twilio-request-URL.png", "Twilio-request-URL.png", "1594", "674", "#1d6038", "" ], "sizing": "80" } ] } [/block] [block:api-header] { "type": "basic", "title": "Testing Your Bot" } [/block] Test your bot sending text messages to the messaging service number. [block:image] { "images": [ { "image": [ "https://files.readme.io/hS6x9J8lS5WSNtJa0W3z_Twilio-Test.png", "Twilio-Test.png", "1440", "2560", "#e69311", "" ] } ] } [/block] [block:api-header] { "type": "basic", "title": "Hosting Twilio Bot with Heroku" } [/block] ## Creating a Messaging Service in Twilio Create a Messaging Service in Twilio as described [here](#creating-a-messaging-service-in-twilio). ## Integrating API.AI Agent with Twilio Messaging Service and Heroku Hosting <a href="https://console.api.ai/api-client/#/newAgent" target="_blank">Create an API.AI agent</a> with the help of the <a href="https://docs.api.ai/docs/key-concepts" target="_blank">API.AI NLU technology tools</a>. In your API.AI agent, go to 'Integrations' from the left side menu, enable Twilio integration, and then, ‘Deploy to Heroku’. On the Heroku page, insert your app name, make sure that the language settings are the same as in your API.AI agent, and click 'Deploy for Free'. [block:image] { "images": [ { "image": [ "https://files.readme.io/49p2LuSAQBC0BHF5HFBL_Twilio-Heroku.png", "Twilio-Heroku.png", "1878", "1432", "#5e458f", "" ], "sizing": "full" } ] } [/block] After your Heroku app has been successfully deployed, you can test your Twilio bot. [block:api-header] { "type": "basic", "title": "Hosting Bots on Your Server" } [/block] You can use our source code from <a href="https://github.com/api-ai/apiai-nodejs-client/tree/master/samples/twilio/bot">github</a> to create your custom Twilio bots.