{"_id":"5845a4a99f6fbb1b00430804","__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"},"user":"55bf6cdcad601c2b00762d13","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":[],"next":{"pages":[],"description":""},"createdAt":"2016-05-15T22:26:06.296Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":11,"body":"* [Overview](#overview)\n* [Video](#video)\n* [Creating a Bot in Telegram](#creating-a-bot-in-telegram)\n* [Integrating API.AI Agent with Telegram Bot](#integrating-apiai-agent-with-telegram-bot)\n* [Testing Your Bot ](#testing-your-bot)\n* [Hosting Your Telegram Bot with Heroku](#hosting-your-telegram-bot-with-heroku)\n * [Creating a Bot in Telegram](#hosting-your-telegram-bot-with-heroku)\n * [Testing Your Bot](#section-testing-your-bot)\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 Telegram Integration** allows you to easily create <a href=\"https://core.telegram.org/bots\" target=\"_blank\">Telegram bots</a> 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 Telegram. Or you can follow the steps described in the documentation [below](#creating-a-bot-in-telegram).\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%2Fcjhcdi61Ugw%3Ffeature%3Doembed&url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dcjhcdi61Ugw&image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fcjhcdi61Ugw%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=cjhcdi61Ugw&feature=youtu.be\",\n  \"title\": \"Build Telegram bots with Api.ai\",\n  \"favicon\": \"https://s.ytimg.com/yts/img/favicon-vflz7uhzw.ico\",\n  \"image\": \"https://i.ytimg.com/vi/cjhcdi61Ugw/hqdefault.jpg\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Creating a Bot in Telegram\"\n}\n[/block]\nLog in to your Telegram account and go to <a href=\"https://telegram.me/botfather\" target=\"_blank\">https://telegram.me/botfather</a>. You’ll be redirected to the Telegram application. Here’s how it may look like in the Telegram desktop version:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/966mIJlzSQmXVIYXpPGI_Telegram-BotFather-step1.png\",\n        \"Telegram-BotFather-step1.png\",\n        \"1592\",\n        \"1246\",\n        \"#6a8eac\",\n        \"\"\n      ],\n      \"sizing\": \"80\"\n    }\n  ]\n}\n[/block]\nAfter clicking on 'Start', a list of commands appears. Select **/newbot**. \n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/sI0y7agdT1CKHuYN9wzI_Telegram-BotFather-newbot.png\",\n        \"Telegram-BotFather-newbot.png\",\n        \"1602\",\n        \"1244\",\n        \"#688dab\",\n        \"\"\n      ],\n      \"sizing\": \"80\"\n    }\n  ]\n}\n[/block]\nType in your **bot name** and click 'Send'. For this example, we've chosen the name \"WeatherBot\" because we want our bot to provide weather forecast.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/Cs7hwzomQhaxvIZDzKHk_Telegram-BotFather-botname.png\",\n        \"Telegram-BotFather-botname.png\",\n        \"1598\",\n        \"1242\",\n        \"#688dac\",\n        \"\"\n      ],\n      \"sizing\": \"80\"\n    }\n  ]\n}\n[/block]\nYou’ll be prompted to choose a **username** for your bot. Note that it must end in ‘bot’.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/ZoLS3OyS2WoeDuMwCbIc_Telegram-BotFather-username.png\",\n        \"Telegram-BotFather-username.png\",\n        \"1592\",\n        \"1244\",\n        \"#0f414f\",\n        \"\"\n      ],\n      \"sizing\": \"80\"\n    }\n  ]\n}\n[/block]\nCopy the Telegram **access token**:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/TwY5hhyQcWJRKBudD340_Telegram-BotFather-token.png\",\n        \"Telegram-BotFather-token.png\",\n        \"1592\",\n        \"1238\",\n        \"#698eac\",\n        \"\"\n      ],\n      \"sizing\": \"80\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Integrating API.AI Agent with Telegram Bot\"\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 Telegram integration, click ‘Integrations’ from the left side menu and turn Telegram integration on.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/hyAnTCcoSvegVtjvDYnL_Telegram-integration-enable.png\",\n        \"Telegram-integration-enable.png\",\n        \"2076\",\n        \"1322\",\n        \"#2c9be0\",\n        \"\"\n      ],\n      \"sizing\": \"80\"\n    }\n  ]\n}\n[/block]\nThen, insert your Telegram access token to the ‘Telegram token’ field and click ‘Start’.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/YGKd6QxHTCYWCJwO6M0d_Telegram-integration-access-token.png\",\n        \"Telegram-integration-access-token.png\",\n        \"2216\",\n        \"1224\",\n        \"#5f65ca\",\n        \"\"\n      ],\n      \"sizing\": \"80\"\n    }\n  ]\n}\n[/block]\nYou can create <a href=\"https://docs.api.ai/docs/concept-intents\" target=\"_blank\">intents</a>, integrate your agent with a web service via a <a href=\"https://docs.api.ai/docs/webhook\" target=\"_blank\">webhook</a>, or just use our built-in Small Talk from the left-hand menu. \n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Testing Your Bot\"\n}\n[/block]\nGo to the Telegram app and search your bot by username.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/hTpZqvzgRHaZwUqR71Ty_Telegram-search-username.png\",\n        \"Telegram-search-username.png\",\n        \"1598\",\n        \"1356\",\n        \"#123842\",\n        \"\"\n      ],\n      \"sizing\": \"80\"\n    }\n  ]\n}\n[/block]\nSelect the bot from the search results and click 'Start'.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/DhuXrx1MREeKKR68j0el_Telegram-bot-select-start.png\",\n        \"Telegram-bot-select-start.png\",\n        \"1598\",\n        \"1240\",\n        \"#6b8eac\",\n        \"\"\n      ],\n      \"sizing\": \"80\"\n    }\n  ]\n}\n[/block]\nTest your bot. In our WeatherBot example, we test it by asking questions about weather in specific locations:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/S4QIYaZdSIC7n9KW5VEe_Telegram-bot-chat.png\",\n        \"Telegram-bot-chat.png\",\n        \"1604\",\n        \"1240\",\n        \"#688dab\",\n        \"\"\n      ],\n      \"sizing\": \"80\"\n    }\n  ]\n}\n[/block]\n\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/telegram\">github</a> to create your custom Telegram bots.","excerpt":"","slug":"telegram-integration","type":"basic","title":"Telegram"}
* [Overview](#overview) * [Video](#video) * [Creating a Bot in Telegram](#creating-a-bot-in-telegram) * [Integrating API.AI Agent with Telegram Bot](#integrating-apiai-agent-with-telegram-bot) * [Testing Your Bot ](#testing-your-bot) * [Hosting Your Telegram Bot with Heroku](#hosting-your-telegram-bot-with-heroku) * [Creating a Bot in Telegram](#hosting-your-telegram-bot-with-heroku) * [Testing Your Bot](#section-testing-your-bot) * [Hosting Bots on Your Server](#hosting-bots-on-your-server) [block:api-header] { "type": "basic", "title": "Overview" } [/block] **API.AI Telegram Integration** allows you to easily create <a href="https://core.telegram.org/bots" target="_blank">Telegram bots</a> 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 Telegram. Or you can follow the steps described in the documentation [below](#creating-a-bot-in-telegram). [block:embed] { "html": "<iframe class=\"embedly-embed\" src=\"//cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fcjhcdi61Ugw%3Ffeature%3Doembed&url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dcjhcdi61Ugw&image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fcjhcdi61Ugw%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=cjhcdi61Ugw&feature=youtu.be", "title": "Build Telegram bots with Api.ai", "favicon": "https://s.ytimg.com/yts/img/favicon-vflz7uhzw.ico", "image": "https://i.ytimg.com/vi/cjhcdi61Ugw/hqdefault.jpg" } [/block] [block:api-header] { "type": "basic", "title": "Creating a Bot in Telegram" } [/block] Log in to your Telegram account and go to <a href="https://telegram.me/botfather" target="_blank">https://telegram.me/botfather</a>. You’ll be redirected to the Telegram application. Here’s how it may look like in the Telegram desktop version: [block:image] { "images": [ { "image": [ "https://files.readme.io/966mIJlzSQmXVIYXpPGI_Telegram-BotFather-step1.png", "Telegram-BotFather-step1.png", "1592", "1246", "#6a8eac", "" ], "sizing": "80" } ] } [/block] After clicking on 'Start', a list of commands appears. Select **/newbot**. [block:image] { "images": [ { "image": [ "https://files.readme.io/sI0y7agdT1CKHuYN9wzI_Telegram-BotFather-newbot.png", "Telegram-BotFather-newbot.png", "1602", "1244", "#688dab", "" ], "sizing": "80" } ] } [/block] Type in your **bot name** and click 'Send'. For this example, we've chosen the name "WeatherBot" because we want our bot to provide weather forecast. [block:image] { "images": [ { "image": [ "https://files.readme.io/Cs7hwzomQhaxvIZDzKHk_Telegram-BotFather-botname.png", "Telegram-BotFather-botname.png", "1598", "1242", "#688dac", "" ], "sizing": "80" } ] } [/block] You’ll be prompted to choose a **username** for your bot. Note that it must end in ‘bot’. [block:image] { "images": [ { "image": [ "https://files.readme.io/ZoLS3OyS2WoeDuMwCbIc_Telegram-BotFather-username.png", "Telegram-BotFather-username.png", "1592", "1244", "#0f414f", "" ], "sizing": "80" } ] } [/block] Copy the Telegram **access token**: [block:image] { "images": [ { "image": [ "https://files.readme.io/TwY5hhyQcWJRKBudD340_Telegram-BotFather-token.png", "Telegram-BotFather-token.png", "1592", "1238", "#698eac", "" ], "sizing": "80" } ] } [/block] [block:api-header] { "type": "basic", "title": "Integrating API.AI Agent with Telegram Bot" } [/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 Telegram integration, click ‘Integrations’ from the left side menu and turn Telegram integration on. [block:image] { "images": [ { "image": [ "https://files.readme.io/hyAnTCcoSvegVtjvDYnL_Telegram-integration-enable.png", "Telegram-integration-enable.png", "2076", "1322", "#2c9be0", "" ], "sizing": "80" } ] } [/block] Then, insert your Telegram access token to the ‘Telegram token’ field and click ‘Start’. [block:image] { "images": [ { "image": [ "https://files.readme.io/YGKd6QxHTCYWCJwO6M0d_Telegram-integration-access-token.png", "Telegram-integration-access-token.png", "2216", "1224", "#5f65ca", "" ], "sizing": "80" } ] } [/block] You can create <a href="https://docs.api.ai/docs/concept-intents" target="_blank">intents</a>, integrate your agent with a web service via a <a href="https://docs.api.ai/docs/webhook" target="_blank">webhook</a>, or just use our built-in Small Talk from the left-hand menu. [block:api-header] { "type": "basic", "title": "Testing Your Bot" } [/block] Go to the Telegram app and search your bot by username. [block:image] { "images": [ { "image": [ "https://files.readme.io/hTpZqvzgRHaZwUqR71Ty_Telegram-search-username.png", "Telegram-search-username.png", "1598", "1356", "#123842", "" ], "sizing": "80" } ] } [/block] Select the bot from the search results and click 'Start'. [block:image] { "images": [ { "image": [ "https://files.readme.io/DhuXrx1MREeKKR68j0el_Telegram-bot-select-start.png", "Telegram-bot-select-start.png", "1598", "1240", "#6b8eac", "" ], "sizing": "80" } ] } [/block] Test your bot. In our WeatherBot example, we test it by asking questions about weather in specific locations: [block:image] { "images": [ { "image": [ "https://files.readme.io/S4QIYaZdSIC7n9KW5VEe_Telegram-bot-chat.png", "Telegram-bot-chat.png", "1604", "1240", "#688dab", "" ], "sizing": "80" } ] } [/block] [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/telegram">github</a> to create your custom Telegram bots.