<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Alena Gilevskaya on Medium]]></title>
        <description><![CDATA[Stories by Alena Gilevskaya on Medium]]></description>
        <link>https://medium.com/@gilevskaya?source=rss-63ffbbd55c7b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*_Er4r_G7mni37igEIQmXJQ.jpeg</url>
            <title>Stories by Alena Gilevskaya on Medium</title>
            <link>https://medium.com/@gilevskaya?source=rss-63ffbbd55c7b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 23:58:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gilevskaya/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Making a Messenger Bot 101—Initial setup, Launching your first bot]]></title>
            <link>https://medium.com/@gilevskaya/making-a-messenger-bot-101-initial-setup-launching-your-first-bot-5e50a6276ca9?source=rss-63ffbbd55c7b------2</link>
            <guid isPermaLink="false">https://medium.com/p/5e50a6276ca9</guid>
            <category><![CDATA[chatbots]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[bots]]></category>
            <category><![CDATA[facebook-messenger]]></category>
            <dc:creator><![CDATA[Alena Gilevskaya]]></dc:creator>
            <pubDate>Tue, 11 Apr 2017 21:14:52 GMT</pubDate>
            <atom:updated>2017-04-11T21:27:27.886Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gEvnpxwreeSH-e9FwqkPuw.png" /></figure><p>Before you’d see your messenger bot saying it’s first “Hello world!” there is a surprising ton of the initial setup. Though this setup is described in the <a href="https://developers.facebook.com/docs/messenger-platform/guides/quick-start">official documentation</a>, many people find this description confusing. In this post I‘ll try to create a better 3 steps guide, that I wish I’d had when I just started.</p><p>To check if the setup is working you will need a demo-bot source code. There is an <a href="https://github.com/fbsamples/messenger-platform-samples">official Facebook demo-bot for node.js</a>, though I recommend starting with my simplified version: <a href="https://github.com/gilevskaya/demo-bot">https://github.com/gilevskaya/demo-bot</a>. The following explanation will equally work for the both demo-bots.</p><p>To run the bot you will need the config variables:<br>💎 <strong>Page Access Token</strong><br>💎 <strong>App Secret</strong><br>💎 <strong>Webhook (Server) URL</strong></p><p>This manual will guide you through creating a Facebook Page and App, setting up the Webhook URL, getting the required variables in this process, and finally running and accessing your chatbot.</p><h3>Step 1: Facebook Page</h3><p>You will need a Facebook Page to access your bot. Even if you already have a page for your product or service you probably want to create a new page for the bot testing while it’s still in the developing phase. (When the bot will be ready you can publish it to your main page).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d4nhAw5xSFtMBam9eF0r9Q.png" /><figcaption>Creating a Facebook Page and Unpublishing it</figcaption></figure><p>Creating a Facebook page is fairly straightforward. Choose the “Create Page” option in the top right menu in your Facebook account or press <a href="https://www.facebook.com/pages/create/">this link</a>. Then Facebook will guide you through all the rest. It doesn’t matter what options and name will you choose for this page since this is just a page for the bot testing that only you and your bot development team will see.</p><p>About people not seeing your page. The first thing you need to do after you’ve created a page is unpublish it. Otherwise it will appear in your friends’ news feed and all the people will be able to access it. For unpublishing go the page Settings and edit second from the top option.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XIwXVgBwgFkyf4JBFq9CPw.png" /><figcaption>Press “Message Now” on your Facebook Page to talk with the bot</figcaption></figure><p>Now your page is ready. There is an “About” block in the right page column with a “<strong>Message Now</strong>” button inside it. It will start a dialog where your bot will live. If you’d try to send a message now, there won’t be any reply. But by the end of this manual you’ll see your bot replies here.</p><p><em>Optionally you can add a Profile Picture to your page. The same picture then will be your bot icon in the messenger.</em></p><p><em>Also optionally you can invite more members of your team to this page (in the Settings -&gt; Page Roles). As it’s unpublished and otherwise people can’t access it.</em></p><h3>Step 2: Facebook App</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pAn43FUe4fx8sUufGvQAoA.png" /><figcaption>Creating a Facebook App</figcaption></figure><p>To create a Facebook App go to the <a href="https://developers.facebook.com/apps/">https://developers.facebook.com/apps</a> and press the green “<strong>+ Add a New App</strong>” button. Type your “App Name” and “Contact Email” in the pop-up. In the case of the Messenger bot both are for internal purpose only, so you can type whatever you want and nobody will see it except other people who will work on this bot with you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GQtzUC9Zu9C2owJhRwadww.png" /><figcaption>Adding a “Messenger” Product</figcaption></figure><p>After your App is created, you’ll see the “Product Setup” page for this App. Scroll down to <strong>Messenger</strong> and press “<strong>Get Started</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ckefsdDS4fHIsY71v2esJQ.png" /><figcaption>Getting a Page Access Token</figcaption></figure><p>Now you’re on the page where you set up your bot from the Facebook side. Scroll down to the <strong>Token Generation</strong>, select the Page you’ve created on the Step 1, go through the Facebook confirmations and (yay!) your 💎 <strong>Page Access Token </strong>has been generated. (The Page you chose and generated token will disappear when you’ll refresh the page, but it still will be working.) You will also need to setup the Webhooks on this page, but we’ll come back to this later.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KFB-UoUzsX7nvWWlJkRgIA.png" /><figcaption>Getting an App Secret</figcaption></figure><p>Go to the Dashboard (first item on the left menu). Press “Show” in the App Secret field and copy the 💎 <strong>App Secret</strong>. Now you have two out of three variables required for running the demo-bot.</p><p><em>Optional: If you need to add more people from your team to access this app, similar to the Page settings, go to the “Roles” in left menu.</em></p><h3>Step 3: Webhook</h3><p>The last piece of the bot setup is the Webhook. Your bot can’t connect directly to Facebook, it works the other way around. Facebook App connects to your bot and subscribes to certain changes. For connection it requires a public URL with SSL — <a href="https://developers.facebook.com/docs/graph-api/webhooks">Webhook</a>, a link to a server (or a developer machine) where your bot runs. You need to add this Webhook to the Facebook App (you’ve created in the Step 2). Webhook URL will look like:</p><p><a href="https://yourchatbot.yourwebsite.com/webhook"><strong>https://&lt;yourchatbot.yourwebsite.com&gt;/webhook</strong></a></p><p>There is some confusion in names as Server URL and Webhook URL often refer to the same link. In this manual, I’ll call it a Webhook URL, but in the demo-bot the same link will be called a Server URL.</p><p>Getting the Webhook URL is the most tricky part, as there is a lot of different ways to do it and none of them are provided by Facebook. You will need to use some external services and the easiest way to launch your first app is to run it from your local machine and then tunnel it with the Ngrok. It will be also useful to learn how to do it because then you can use it for testing your bot before publishing.</p><p>First <a href="https://ngrok.com/download">download ngrok</a> for your platform and save it somewhere. Then launch it and make a tunnel for the localhost on the port 5000 (this port is used in the demo-bot, you can change it anytime):</p><pre>ngrok http 5000</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-FwvmEQogWXsuzw8ne9Fhg.png" /><figcaption>Ngrok output in the console</figcaption></figure><p>You’ll see two tunnel links to your local host. Copy the one with <strong>https</strong>, add <strong>/webhook</strong> to the end of this link and this will be your 💎 <strong>Webhook URL</strong>. Now you have all the config variables to run the demo bot.</p><p>Note that if you’re using free Ngrok account, this link will change everytime you restart it. So you’ll have to repeat all the steps that will go next with the new link.</p><pre><em>config/default.json</em><br>{    <br>  &quot;appSecret&quot;: &lt; 💎 <strong>App Secret </strong>&gt;,    <br>  &quot;pageAccessToken&quot;: &lt; 💎 <strong>Page Access Token </strong>&gt;,    <br>  &quot;validationToken&quot;: &lt; <strong>Random_String_For_Validation </strong>&gt;,    <br>  &quot;serverURL&quot;: &lt; 💎 <strong>Webhook (Server) URL </strong>&gt;<br>}</pre><p>Download the demo-bot source code if you haven’t already. Go to the <strong>config/default.json</strong>. Use any random string for the validation token, and App Secret, Page Access Token, Webhook URL that you got on the steps before.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cpHbzC6OQUUSpsb7SwOryw.png" /></figure><p>Run the demo-bot. Go to the <strong>localhost:5000 </strong>or your Ngrok link. You will see the “Messenger Demo” page. Keep the bot running, you’ll need it next.</p><p><em>Optionally you can go this page source code and fill the missing variables. Then you will see Messenger buttons on this page leading to your bot.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O-KUQzh6SngBHdGBg9yxUQ.png" /><figcaption>Webhook Setup button in the App setting</figcaption></figure><p>Now all that left is to do is a <strong>Webhook Setup</strong> that we skipped above. Go back to your bot App in Facebook (<a href="https://developers.facebook.com/apps/">https://developers.facebook.com/apps</a> -&gt; choose the App you’ve created -&gt; Then Messenger under Products in the left menu). Scroll to the Webhooks and press “<strong>Setup Webhooks</strong>” button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xIT6jOI2G3Qy7j1Wr-WQLQ.png" /><figcaption>Setting up the Webhook</figcaption></figure><p>Fill in your <strong>Webhook URL </strong>with the /webhook in the end, and the same <strong>Random_String_For_Validation </strong>that you wrote in the config/default.json. Check all the checkboxes in the “Subscription Fields”, press “<strong>Verify and Save</strong>”. You will need your bot running for this to work. If you don’t see the error message then everything went great.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3aA-7yli1Bs9LqXllCwP7w.png" /><figcaption>Subscribing the Webhook to the Facebook Page</figcaption></figure><p>Subscribe your Page from the Step 1 to this Webhook and you’re all set.</p><p>Try talking to your bot again. Now it will be echoing everything you send 🎉<br>And checkout the console output to see the more detailed info on what’s going on with your bot.</p><p>💚 Like if it worked for you :-) And please comment if you have any thoughts, questions, or suggestions on how to improve this manual.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5e50a6276ca9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>