{"id":656,"date":"2016-06-07T17:14:45","date_gmt":"2016-06-07T11:44:45","guid":{"rendered":"http:\/\/new.codingislove.com\/?p=656"},"modified":"2020-07-22T16:41:17","modified_gmt":"2020-07-22T11:11:17","slug":"build-facebook-messenger-bot-javascript","status":"publish","type":"post","link":"https:\/\/codingislove.com\/build-facebook-messenger-bot-javascript\/","title":{"rendered":"Develop Facebook messenger bot using Javascript &#8211; Part 1"},"content":{"rendered":"<p>Last month Facebook launched their messenger platform (beta) which provides API and tools to create a chat bot for facebook messenger. Since then many developers have started building facebook messenger bots! I love trying new stuff, So I started building one.<\/p>\n<p>I developed a Wikipedia bot for messenger to get started. We&#8217;ll be building the same bot in this tutorial.<!--more--><\/p>\n<p><strong><em>Bots for facebook messenger can be developed in any programming language<\/em><\/strong> because of API and webhooks provided by messenger platform. First let&#8217;s understand the core concept of how it works, then you can choose any language that you like.<\/p>\n<h3>Core concept<\/h3>\n<p>Its a simple concept. A facebook page is used as bot identity, we can use existing page or create a new one. When a user sends a message to that page, a HTTP POST request with message data will be made by messenger platform to an URL which we define in our app.<\/p>\n<p>All we have to do is parse the message data sent in POST request and send a reply to user using Send API provided by facebook.<\/p>\n<p>The concept of sending a HTTP POST request to a specific URL when an event happens is called as webhbook. Here the event is &#8216;When user sends a message to our page (bot)&#8217;<\/p>\n<p>Read more about webhooks here &#8211; <a href=\"https:\/\/webhooks.pbworks.com\/w\/page\/13385124\/FrontPage\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Webhooks wiki<\/a><\/p>\n<p>POST requests can be handled in any language. I used Javascript in NodeJS for this bot. You can use PHP, Python, Ruby or any language that you like. Messenger platform official documentation contains example code in Javascript (NodeJS).<\/p>\n<h3>What are we building<\/h3>\n<p>A Wikipedia bot which can be used to search Wikipedia by entering a search term. Bot returns 10 relevant search results with <code>read more<\/code> and <code>view in browser<\/code> buttons. Clicking <code>read more<\/code> returns description of the result, <code>View in browser<\/code> opens appropriate Wikipedia page in the browser.<\/p>\n<p>You can watch demo video of wiki bot below.<\/p>\n<p><iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/S7uY7T8FsJ0\" frameborder=\"0\" allowfullscreen=\"\"><\/iframe><\/p>\n<h3>Prerequisites<\/h3>\n<ol>\n<li>Facebook developer account &#8211; Just log in with your existing facebook account at <a href=\"https:\/\/developers.facebook.com\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https:\/\/developers.facebook.com<\/a><\/li>\n<li>A facebook page<\/li>\n<li>Basic Javascript knowledge, Some NodeJS experience would help.<\/li>\n<\/ol>\n<h3>Setup and tools used<\/h3>\n<p>I&#8217;m using cloud IDE <a href=\"https:\/\/c9.io\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">c9.io<\/a> for developement. Cloud9 IDE is an online integrated development environment. It supports hundreds of programming languages, including PHP, Ruby, Perl, Python, JavaScript with Node.js, and Go.<\/p>\n<p>In simple words, Cloud9 provides a virtual machine with command line access where you can install anything, write code and preview it. Virtual machine from C9 free account goes into sleep mode and 2 hours of inactivity. So we cannot deploy out app\/bot in C9. If you buy a pro account from cloud9 then you can also deploy your app.<\/p>\n<p>You can also develop in your local PC by installing NodeJS and using any text editor or IDE to write code. But you&#8217;ll need a cloud server or some shared hosting to deploy your bot.<\/p>\n<p>I&#8217;m using hook.io for deploying the bot. Hook.io is a free micro hosting service. Read more about hook.io <a href=\"https:\/\/codingislove.com\/free-microservice-hosting-hook-io\/\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a><\/p>\n<p><em>If you are new to web development and still confused then just follow the steps below and start writing code along with this tutorial.<\/em><\/p>\n<!-- \/112371330\/post-banner -->\r\n<div class=\"ad-wrapper\">\r\n<div id='div-gpt-ad-1595500140430-0' style='width: 250px; height: 250px;'>\r\n  <script>\r\n    googletag.cmd.push(function() { googletag.display('div-gpt-ad-1595500140430-0'); });\r\n  <\/script>\r\n<\/div>\r\n<\/div>\n<h3>Getting started with messenger bot development<\/h3>\n<p>We&#8217;ll Follow first few steps same as mentioned in <a href=\"https:\/\/developers.facebook.com\/docs\/messenger-platform\/quickstart\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">official documentation<\/a> as explained below.<\/p>\n<p>Go to <a href=\"https:\/\/developers.facebook.com\/apps\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">https:\/\/developers.facebook.com\/apps<\/a> and create a new app &gt; click on use basic setup.<\/p>\n<p><img decoding=\"async\" class=\"myborder\" src=\"\/\/i.imgur.com\/yIVYyQC.png\" alt=\"create fb app tutorial\"><\/p>\n<p>Now click &#8220;Add Product.&#8221; Select &#8220;Messenger.&#8221; in app dashboard.<\/p>\n<p><img decoding=\"async\" class=\"myborder\" src=\"\/\/fbcdn-dragon-a.akamaihd.net\/hphotos-ak-xpf1\/t39.2178-6\/12995587_195576307494663_824949235_n.png\" alt=\"add messenger platform\"><\/p>\n<p>In messenger settings &gt; Select the page which will be used as bot identity, A token will be generated which will be used later to send messages. If you don&#8217;t have any then create a new facebook page from <a href=\"https:\/\/www.facebook.com\/pages\/create\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a><\/p>\n<p>Now lets setup our workspace. First create a <a href=\"https:\/\/c9.io\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Cloud9 account<\/a> and login. In your dashboard click on Create new workspace &gt; enter a name &gt; select Node.Js in choose template and click Create workspace.<\/p>\n<p><em><strong>Make sure to select public workspace. Private workspaces doesn&#8217;t allow public requests and redirects to signin page which causes this error &#8211; The URL couldn&#8217;t be validated. Callback verification failed with the following errors: curl_errno = 47; curl_error = Maximum (2) redirects followed; HTTP Status Code = 302; HTTP Message = Moved Temporarily<\/strong><\/em><\/p>\n<p>If you have already created a private workspace then change it in the workspace setting from your C9 dashboard.<\/p>\n<p>A workspace with NodeJS preinstalled will be created for you. Cloud9 also provides a basic boilerplate code with some modules preinstalled, one of them is expressJS which is a popular NodeJs application framework.<\/p>\n<p>Example code in messenger platform documentation also uses express framework (Although documentation is not explained in detail) so we&#8217;ll be using the same in this tutorial. You can read more about express <a href=\"http:\/\/expressjs.com\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">here<\/a><\/p>\n<h3>Basic verification<\/h3>\n<p>In order to setup webhooks for our messenger bot, A small verification is done by messenger platform to verify ownership and make sure webhook URLs are secure. Lets finish that verification and then write code for wikipedia search.<\/p>\n<p>Open server.js, replace all the code in it with code below :<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\nvar express = require('express'); \/\/express handles routes\nvar http = require('http'); \/\/need http module to create a server\nvar app = express(); \/\/starting express\napp.set('port', process.env.PORT || 3000); \/\/set port to cloud9 specific port or 3000\napp.use(express.bodyParser()); \/\/body parser used to parse request data\napp.use(app.router);\napp.get('\/', verificationHandler);\nfunction verificationHandler(req, res) {\nconsole.log(req);\nif (req.query&#x5B;'hub.verify_token'] === 'verifycode') {\nres.send(req.query&#x5B;'hub.challenge']);\n}\nres.send('Error, wrong validation token!');\n}\nhttp.createServer(app).listen(app.get('port'), function() {\nconsole.log('Express server listening on port ' + app.get('port'));\n});\n<\/pre>\n<p><strong>Note: I&#8217;ve used express 3.x in this tutorial, If you are using 4.x version then code has to be changed slightly.<\/strong><\/p>\n<p>In command line type node server.js<\/p>\n<p><img decoding=\"async\" src=\"\/\/i.imgur.com\/ULC5zWr.png\" alt=\"Start node server\"><\/p>\n<p>A Node Server starts listening for any requests.<\/p>\n<p>Go to preview &gt; Preview running application &gt; Copy URL<\/p>\n<p>Now go back to Messenger platfrom in fb developers account and click on setup webhooks &gt; paste copied URL in webhook URL and <code>verifycode<\/code> in Verify Token as shown in image below. Select all subscription fields.<\/p>\n<p><img decoding=\"async\" src=\"\/\/i.imgur.com\/vzpEDSy.png\" alt=\"Messenger bot verification\"><\/p>\n<p>Now when you click verify and save, messenger platform makes a <code>GET<\/code> request to your webhook URL along with parameters <code>hub.verify_token<\/code> and <code>hub.challenge<\/code><\/p>\n<p><code>hub.verify_token<\/code> will have value &#8220;verifycode&#8221; as we mentioned in webhook settings and <code>hub.challenge<\/code> will have some auto generated code.<\/p>\n<p>GET request made by messenger platform will look something similar to <span style=\"color:#42b72a\">https:\/\/messengerbot-ranjithkumar8352.c9users.io\/?hub.verify_token=verifycode&amp;hub.challenge=somefbgeneratedcode<\/span> and expects a response with value of <code>hub.challenge<\/code><\/p>\n<p>If you look at the code, we check if value of <code>hub.verify_token<\/code> is equal to <code>verifycode<\/code> and then respond with value of <code>hub.challenge<\/code>.<\/p>\n<p>This is just a webhook verification and has nothing to do with bot. so don&#8217;t think too much about this.<\/p>\n<!-- \/112371330\/post-rectange -->\r\n<div class=\"ad-wrapper\">\r\n<div id='div-gpt-ad-1595415581471-0' style='width: 300px; height: 250px;'>\r\n  <script>\r\n    googletag.cmd.push(function() { googletag.display('div-gpt-ad-1595415581471-0'); });\r\n  <\/script>\r\n<\/div>\r\n<\/div>\n<p>When you click Verify and save, Verification should be completed. In webhooks section select the page for which you want to subscribe your webhook. Now whenever someone sends a message to this page, a POST request is made to your webhook URL.<\/p>\n<p>We&#8217;ll be writing code for reading messages sent by a user, responding with wiki results or a help message in the next part of this tutorial linked below.<\/p>\n<p><a href=\"https:\/\/codingislove.com\/build-facebook-chat-bot-javascript\/\">Develop Facebook chat bot using Javascript &#8211; Part 2<\/a><\/p>\n<p><em>If you have and questions or feedback, comment below.<\/em><\/p>\n<script>(function() {\n\twindow.mc4wp = window.mc4wp || {\n\t\tlisteners: [],\n\t\tforms: {\n\t\t\ton: function(evt, cb) {\n\t\t\t\twindow.mc4wp.listeners.push(\n\t\t\t\t\t{\n\t\t\t\t\t\tevent   : evt,\n\t\t\t\t\t\tcallback: cb\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n})();\n<\/script><!-- Mailchimp for WordPress v4.10.7 - https:\/\/wordpress.org\/plugins\/mailchimp-for-wp\/ --><form id=\"mc4wp-form-1\" class=\"mc4wp-form mc4wp-form-177 mc4wp-form-theme mc4wp-form-theme-red\" method=\"post\" data-id=\"177\" data-name=\"Subscribe to Coding is Love\" ><div class=\"mc4wp-form-fields\"><p>\r\n  <strong><a style=\"cursor:pointer\" onclick=\"OneSignal.push(function() {OneSignal.registerForPushNotifications()});\">Get notified when there's a new post by clicking on<img decoding=\"async\" style=\"transform:scale(0.75,0.75)\" src=\"https:\/\/i.imgur.com\/lTEcCYt.png\" alt=\"notification-bell\"\/>in bottom left<\/a><\/strong>\r\n<\/p>\r\n\r\n<p>\r\n  <strong>Need some help? Post your questions on our <a href=\"https:\/\/forum.codingislove.com\" target=\"_blank\">forum<\/a><\/strong>\r\n<\/p>\r\n<!--<br>\r\n<script id=\"mNCC\" language=\"javascript\">\r\n   medianet_width = \"300\";\r\n   medianet_height = \"250\";\r\n   medianet_crid = \"892699656\";\r\n   medianet_versionId = \"111299\";\r\n   (function() {\r\n       var isSSL = 'https:' == document.location.protocol;\r\n       var mnSrc = (isSSL ? 'https:' : 'http:') + '\/\/contextual.media.net\/nmedianet.js?cid=8CUWS5M33' + (isSSL ? '&https=1' : '');\r\n       document.write('<scr' + 'ipt type=\"text\/javascript\" id=\"mNSC\" src=\"' + mnSrc + '\"><\/scr' + 'ipt>');\r\n   })();\r\n<\/script>\r\n<p>\r\n    Liked this post? Join our newsletter to get more stuff like this in your inbox.\r\n<\/p>\r\n<p>\r\n\t<label>Email address: <\/label>\r\n\t<input type=\"email\" name=\"EMAIL\" placeholder=\"Your email is safe with us!\" required \/>\r\n<\/p>\r\n<p>\r\n\t<input type=\"submit\" value=\"Sign up\" \/>\r\n<\/p>\r\n--><\/div><label style=\"display: none !important;\">Leave this field empty if you're human: <input type=\"text\" name=\"_mc4wp_honeypot\" value=\"\" tabindex=\"-1\" autocomplete=\"off\" \/><\/label><input type=\"hidden\" name=\"_mc4wp_timestamp\" value=\"1776843506\" \/><input type=\"hidden\" name=\"_mc4wp_form_id\" value=\"177\" \/><input type=\"hidden\" name=\"_mc4wp_form_element_id\" value=\"mc4wp-form-1\" \/><div class=\"mc4wp-response\"><\/div><\/form><!-- \/ Mailchimp for WordPress Plugin -->\n<!-- \/112371330\/after-post -->\r\n<div class=\"ad-wrapper\">\r\n<div id='div-gpt-ad-1595272670647-0' style='width: 750px; height: 100px;'>\r\n  <script>\r\n    googletag.cmd.push(function() { googletag.display('div-gpt-ad-1595272670647-0'); });\r\n  <\/script>\r\n<\/div>\r\n<\/div>\n<div style=\"margin-top: 15px; margin-bottom: 15px;\" class=\"sharethis-inline-share-buttons\" ><\/div>","protected":false},"excerpt":{"rendered":"<p>Last month Facebook launched their messenger platform (beta) which provides API and tools to create a chat bot for facebook messenger. Since then many developers&hellip; <\/p>\n","protected":false},"author":1,"featured_media":2562,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[3],"tags":[24,25,8,23],"class_list":["post-656","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-bot","tag-chat-bot","tag-coding","tag-facebook-messenger"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Develop Facebook messenger bot using Javascript - Part 1 - Coding is Love<\/title>\n<meta name=\"description\" content=\"A complete tutorial on building messenger bots for facebook. Learn how to build Wikipedia bot using NodeJS.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/codingislove.com\/build-facebook-messenger-bot-javascript\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Develop Facebook messenger bot using Javascript - Part 1 - Coding is Love\" \/>\n<meta property=\"og:description\" content=\"A complete tutorial on building messenger bots for facebook. Learn how to build Wikipedia bot using NodeJS.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/codingislove.com\/build-facebook-messenger-bot-javascript\/\" \/>\n<meta property=\"og:site_name\" content=\"Coding is Love\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/facebook.com\/codingislove\/\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/ranjithkumar10\" \/>\n<meta property=\"article:published_time\" content=\"2016-06-07T11:44:45+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-07-22T11:11:17+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/codingislove.com\/wp-content\/uploads\/2015\/12\/codinglovenew.png\" \/>\n\t<meta property=\"og:image:width\" content=\"300\" \/>\n\t<meta property=\"og:image:height\" content=\"225\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Ranjith kumar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/i.imgur.com\/ULC5zWr.png\" \/>\n<meta name=\"twitter:creator\" content=\"@codingislove\" \/>\n<meta name=\"twitter:site\" content=\"@codingislove\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ranjith kumar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/codingislove.com\/build-facebook-messenger-bot-javascript\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/codingislove.com\/build-facebook-messenger-bot-javascript\/\"},\"author\":{\"name\":\"Ranjith kumar\",\"@id\":\"https:\/\/codingislove.com\/#\/schema\/person\/ecb142505163b016d59bfbe662af587e\"},\"headline\":\"Develop Facebook messenger bot using Javascript &#8211; Part 1\",\"datePublished\":\"2016-06-07T11:44:45+00:00\",\"dateModified\":\"2020-07-22T11:11:17+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/codingislove.com\/build-facebook-messenger-bot-javascript\/\"},\"wordCount\":1232,\"commentCount\":20,\"publisher\":{\"@id\":\"https:\/\/codingislove.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/codingislove.com\/build-facebook-messenger-bot-javascript\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/codingislove.com\/wp-content\/uploads\/2016\/06\/yXiuFdQ1-1.png\",\"keywords\":[\"bot\",\"chat bot\",\"coding\",\"facebook messenger\"],\"articleSection\":[\"Coding Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/codingislove.com\/build-facebook-messenger-bot-javascript\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/codingislove.com\/build-facebook-messenger-bot-javascript\/\",\"url\":\"https:\/\/codingislove.com\/build-facebook-messenger-bot-javascript\/\",\"name\":\"Develop Facebook messenger bot using Javascript - Part 1 - Coding is Love\",\"isPartOf\":{\"@id\":\"https:\/\/codingislove.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/codingislove.com\/build-facebook-messenger-bot-javascript\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/codingislove.com\/build-facebook-messenger-bot-javascript\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/codingislove.com\/wp-content\/uploads\/2016\/06\/yXiuFdQ1-1.png\",\"datePublished\":\"2016-06-07T11:44:45+00:00\",\"dateModified\":\"2020-07-22T11:11:17+00:00\",\"description\":\"A complete tutorial on building messenger bots for facebook. Learn how to build Wikipedia bot using NodeJS.\",\"breadcrumb\":{\"@id\":\"https:\/\/codingislove.com\/build-facebook-messenger-bot-javascript\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/codingislove.com\/build-facebook-messenger-bot-javascript\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/codingislove.com\/build-facebook-messenger-bot-javascript\/#primaryimage\",\"url\":\"https:\/\/codingislove.com\/wp-content\/uploads\/2016\/06\/yXiuFdQ1-1.png\",\"contentUrl\":\"https:\/\/codingislove.com\/wp-content\/uploads\/2016\/06\/yXiuFdQ1-1.png\",\"width\":560,\"height\":315},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/codingislove.com\/build-facebook-messenger-bot-javascript\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Coding is Love\",\"item\":\"https:\/\/codingislove.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Coding Tutorials\",\"item\":\"https:\/\/codingislove.com\/category\/tutorials\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Develop Facebook messenger bot using Javascript &#8211; Part 1\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/codingislove.com\/#website\",\"url\":\"https:\/\/codingislove.com\/\",\"name\":\"Coding is Love\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/codingislove.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/codingislove.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/codingislove.com\/#organization\",\"name\":\"Coding is Love\",\"url\":\"https:\/\/codingislove.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/codingislove.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/codingislove.com\/wp-content\/uploads\/2015\/12\/codinglovenew.png\",\"contentUrl\":\"https:\/\/codingislove.com\/wp-content\/uploads\/2015\/12\/codinglovenew.png\",\"width\":300,\"height\":225,\"caption\":\"Coding is Love\"},\"image\":{\"@id\":\"https:\/\/codingislove.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/facebook.com\/codingislove\/\",\"https:\/\/x.com\/codingislove\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/codingislove.com\/#\/schema\/person\/ecb142505163b016d59bfbe662af587e\",\"name\":\"Ranjith kumar\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/codingislove.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/f5486247269539c638227e6213187139cc7460eeb16d789fa757485f1d2b87f0?s=96&d=wavatar&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/f5486247269539c638227e6213187139cc7460eeb16d789fa757485f1d2b87f0?s=96&d=wavatar&r=g\",\"caption\":\"Ranjith kumar\"},\"description\":\"A CA- by education, self taught coder by passion, loves to explore new technologies and believes in learn by doing.\",\"sameAs\":[\"https:\/\/www.facebook.com\/ranjithkumar10\",\"https:\/\/www.instagram.com\/livin_on_d_edge\/\",\"https:\/\/www.linkedin.com\/in\/ranjithkumar10\",\"https:\/\/www.youtube.com\/c\/codingislove01\"],\"url\":\"https:\/\/codingislove.com\/author\/ranjithkumar10\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Develop Facebook messenger bot using Javascript - Part 1 - Coding is Love","description":"A complete tutorial on building messenger bots for facebook. Learn how to build Wikipedia bot using NodeJS.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/codingislove.com\/build-facebook-messenger-bot-javascript\/","og_locale":"en_US","og_type":"article","og_title":"Develop Facebook messenger bot using Javascript - Part 1 - Coding is Love","og_description":"A complete tutorial on building messenger bots for facebook. Learn how to build Wikipedia bot using NodeJS.","og_url":"https:\/\/codingislove.com\/build-facebook-messenger-bot-javascript\/","og_site_name":"Coding is Love","article_publisher":"https:\/\/facebook.com\/codingislove\/","article_author":"https:\/\/www.facebook.com\/ranjithkumar10","article_published_time":"2016-06-07T11:44:45+00:00","article_modified_time":"2020-07-22T11:11:17+00:00","og_image":[{"width":300,"height":225,"url":"https:\/\/codingislove.com\/wp-content\/uploads\/2015\/12\/codinglovenew.png","type":"image\/png"}],"author":"Ranjith kumar","twitter_card":"summary_large_image","twitter_image":"https:\/\/i.imgur.com\/ULC5zWr.png","twitter_creator":"@codingislove","twitter_site":"@codingislove","twitter_misc":{"Written by":"Ranjith kumar","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/codingislove.com\/build-facebook-messenger-bot-javascript\/#article","isPartOf":{"@id":"https:\/\/codingislove.com\/build-facebook-messenger-bot-javascript\/"},"author":{"name":"Ranjith kumar","@id":"https:\/\/codingislove.com\/#\/schema\/person\/ecb142505163b016d59bfbe662af587e"},"headline":"Develop Facebook messenger bot using Javascript &#8211; Part 1","datePublished":"2016-06-07T11:44:45+00:00","dateModified":"2020-07-22T11:11:17+00:00","mainEntityOfPage":{"@id":"https:\/\/codingislove.com\/build-facebook-messenger-bot-javascript\/"},"wordCount":1232,"commentCount":20,"publisher":{"@id":"https:\/\/codingislove.com\/#organization"},"image":{"@id":"https:\/\/codingislove.com\/build-facebook-messenger-bot-javascript\/#primaryimage"},"thumbnailUrl":"https:\/\/codingislove.com\/wp-content\/uploads\/2016\/06\/yXiuFdQ1-1.png","keywords":["bot","chat bot","coding","facebook messenger"],"articleSection":["Coding Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/codingislove.com\/build-facebook-messenger-bot-javascript\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/codingislove.com\/build-facebook-messenger-bot-javascript\/","url":"https:\/\/codingislove.com\/build-facebook-messenger-bot-javascript\/","name":"Develop Facebook messenger bot using Javascript - Part 1 - Coding is Love","isPartOf":{"@id":"https:\/\/codingislove.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/codingislove.com\/build-facebook-messenger-bot-javascript\/#primaryimage"},"image":{"@id":"https:\/\/codingislove.com\/build-facebook-messenger-bot-javascript\/#primaryimage"},"thumbnailUrl":"https:\/\/codingislove.com\/wp-content\/uploads\/2016\/06\/yXiuFdQ1-1.png","datePublished":"2016-06-07T11:44:45+00:00","dateModified":"2020-07-22T11:11:17+00:00","description":"A complete tutorial on building messenger bots for facebook. Learn how to build Wikipedia bot using NodeJS.","breadcrumb":{"@id":"https:\/\/codingislove.com\/build-facebook-messenger-bot-javascript\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/codingislove.com\/build-facebook-messenger-bot-javascript\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codingislove.com\/build-facebook-messenger-bot-javascript\/#primaryimage","url":"https:\/\/codingislove.com\/wp-content\/uploads\/2016\/06\/yXiuFdQ1-1.png","contentUrl":"https:\/\/codingislove.com\/wp-content\/uploads\/2016\/06\/yXiuFdQ1-1.png","width":560,"height":315},{"@type":"BreadcrumbList","@id":"https:\/\/codingislove.com\/build-facebook-messenger-bot-javascript\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Coding is Love","item":"https:\/\/codingislove.com\/"},{"@type":"ListItem","position":2,"name":"Coding Tutorials","item":"https:\/\/codingislove.com\/category\/tutorials\/"},{"@type":"ListItem","position":3,"name":"Develop Facebook messenger bot using Javascript &#8211; Part 1"}]},{"@type":"WebSite","@id":"https:\/\/codingislove.com\/#website","url":"https:\/\/codingislove.com\/","name":"Coding is Love","description":"","publisher":{"@id":"https:\/\/codingislove.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/codingislove.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/codingislove.com\/#organization","name":"Coding is Love","url":"https:\/\/codingislove.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codingislove.com\/#\/schema\/logo\/image\/","url":"https:\/\/codingislove.com\/wp-content\/uploads\/2015\/12\/codinglovenew.png","contentUrl":"https:\/\/codingislove.com\/wp-content\/uploads\/2015\/12\/codinglovenew.png","width":300,"height":225,"caption":"Coding is Love"},"image":{"@id":"https:\/\/codingislove.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/facebook.com\/codingislove\/","https:\/\/x.com\/codingislove"]},{"@type":"Person","@id":"https:\/\/codingislove.com\/#\/schema\/person\/ecb142505163b016d59bfbe662af587e","name":"Ranjith kumar","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codingislove.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/f5486247269539c638227e6213187139cc7460eeb16d789fa757485f1d2b87f0?s=96&d=wavatar&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f5486247269539c638227e6213187139cc7460eeb16d789fa757485f1d2b87f0?s=96&d=wavatar&r=g","caption":"Ranjith kumar"},"description":"A CA- by education, self taught coder by passion, loves to explore new technologies and believes in learn by doing.","sameAs":["https:\/\/www.facebook.com\/ranjithkumar10","https:\/\/www.instagram.com\/livin_on_d_edge\/","https:\/\/www.linkedin.com\/in\/ranjithkumar10","https:\/\/www.youtube.com\/c\/codingislove01"],"url":"https:\/\/codingislove.com\/author\/ranjithkumar10\/"}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/codingislove.com\/wp-content\/uploads\/2016\/06\/yXiuFdQ1-1.png","amp_enabled":true,"_links":{"self":[{"href":"https:\/\/codingislove.com\/wp-json\/wp\/v2\/posts\/656","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codingislove.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codingislove.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codingislove.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codingislove.com\/wp-json\/wp\/v2\/comments?post=656"}],"version-history":[{"count":0,"href":"https:\/\/codingislove.com\/wp-json\/wp\/v2\/posts\/656\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codingislove.com\/wp-json\/wp\/v2\/media\/2562"}],"wp:attachment":[{"href":"https:\/\/codingislove.com\/wp-json\/wp\/v2\/media?parent=656"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codingislove.com\/wp-json\/wp\/v2\/categories?post=656"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codingislove.com\/wp-json\/wp\/v2\/tags?post=656"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}