Lack of idea to celebrate 5.20(Chinese Valentine’s Day) with your significant other?
Lack of idea to express gratitude to your dad on Father’s Day?

Try to make a Facebook Messenger Bot as a gift! You can take a look at the bot I made! The bot can chat with people and also say something sweet once you trigger something! The setup for the bot is basic, but we both find it really exciting and cool.

Out of curiosity, some of my friends asked me for several times about how to make a bot on Facebook Messenger. Hence, I am going to list the basic steps that are required to do so that you can build your own bot!

Set up the server

1.  Download and install Heroku! Simply follow the tips here!
You might need to sign up first.
Do not run “heroku create” for now, as it will be run in the following steps.

2. Install Node from here, then open up the terminal and run:

sudo npm install npm -g

Start to create

1.  Crate a new folder which will be your project folder.

2. Create Node modules in the folder by running the following command in the terminal:
(hit Enter to accept the defaults)

npm init
npm install express request body-parser --save

3. Create a js file called index.js and write your code inside:

You can just copy paste my index.js file for my project on Github (Say I love You With A Bot) and try to play around with it. I have already eliminate some of my customized code for the bot.

4. Make a file called Procfile and copy this so that Heroku knows what file to run:
(It is Procfile and it is not a typo lol)

web: node index.js

5. Commit all the code with Git then create a new Heroku instance and push the code to the cloud.

git init
git add .
git commit --message "hello world"
heroku create
git push heroku master

Set up the Facebook Support

1.  Create or configure a Facebook App or Page here 

2.  Set up the Facebook Page and config following the Facebook Messenger Development Quick Start


Make your bot for Public

1. Submit your bot for review following the guide here!
They say you might have to wait for about 5 business days, but it just took me one day. Hence, you do not have to panic!

2. When your bot hasn’t published, you can only test it using your own Facebook account. After you pass the review, you can make it public on your Facebook Developer App Dashboard.

3. However, if you just want specific people to have the access to the bot (others just cannot talk with it): 
Go to your Facebook page which is linked to the bot, and set a role for the specific people who you want to have access to the bot. After that, make your App private.

Well, take a look at my bot…



Story behind the bot…

I just finished my first year in Software Engineering, but I have tried different projects using different languages and frameworks. Among these projects, the most fantastic one that I am proud of is “Bots for Facebook Messenger & WeChat”. Indeed, I am proud of it not only because I have learnt a lot about designing and programming, but also I am able to apply what I have learnt to the real life and make people around me feel happy!

The Messenger bot was originally a gift for my boyfriend(well, boyfriend at that time). It can talk with him and trigger “surprises” to display. I made the bot using Node.js, after learning the manuals on Github and Facebook Developer Pages. Of course, the innovative idea was also an important part! For the WeChat bot, I applied an AI API which had a large Chinese library, which made the conversation between humans and the bot more interactive and creative! If you ask it about the weather of anywhere in the world, ask for interesting jokes or even simple maths problems, it can answer right away, not to mention that it can chat with you about whatever topics you like! For this one, I also learned the WeChat Developer Pages as well as the API manual. For the next step, I am going to target the WeChat bot into one that can show gratitude to my father as Father’s Day is coming!

Indeed, I am really excited about getting both bots done, since I find it wonderful to apply technology&programming to make people around me feel my love and care! I hope I can continue doing that, and I will feel happy as well when what I have made can make a difference to people’s life.

In terms of the roadblocks, I was confused and frustrated in the first few days when I searched for more than 10 different manuals about making a bot but I still could not fix my problem when setting up. Making a bot was totally new to me before, as I just finished my first year in Software Engineering. I wanted to give up, but the thought that I wanted to make a difference pushed me to continue. Finally, I successfully set up a bot and got it worked via the setup for Facebook as well as WeChat by searching in StackOverflow as well as trial and error, and I customized my own features after comparing different designs. I did feel down when I got stuck, but when it paid off I was really proud of myself!

Since I have customized the Messenger bot as a private one and only my friends on WeChat can get access to the WeChat bot, I am sorry that I cannot find a way to paste the link to my “bots” here~

Build Your Facebook Messenger Bot
Tagged on:

One thought on “Build Your Facebook Messenger Bot

  • June 18, 2017 at 11:18 pm
    LOVE U FOR MAKING THIS! <3 <3 <3 <3

Leave a Reply

Your email address will not be published. Required fields are marked *