This is a Facebook chat bot template project with minimal functionality. It translates Roman numbers into Arabic ones. Oh - and it is talking German only. This repository is meant to be a companion to an article published in t3n magazin (Nr. 45, 2016) but you are free to use it you like.
You should know git and node.js and have installed both.
To create your own version of this bot just:
-
Clone or copy this repository
git clone https://github.com/smartsteuer/caesar-bot.git name-of-your-bot ```
-
Change to the new directory
cd name-of-your-bot ```
-
Install the dependencies
npm install ```
-
Test if everything works.
npm test ```
At this point you are free to optimize, extend and change this bot as you like. What ever you are intending to do in the future - the first thing to do is to change the verify token Facebook is going to check your webhook with.
- Open
webhook-get.spec.js
and change the (token)[app/fb/webhook-get.spec.js#L14] to a freely selectable value. (You are going to share this value with Facebook later on) - Run
npm test
again - Fix all broken tests
You are good to go public!
Your bot is running locally - good. But we want the world to see it… (In this example we are going to deploy on heroku but you are free to choose any provider you like)
-
Be familiar with Heroku and install their toolbelt.
-
Login (if you haven't done this already)
heroku login ```
-
Create a new Heroku app
heroku create ```
-
Deploy (a.k.a. push to the heroku git) the app.
git push heroku master ```
More information on Node on Heroku can be found here: getting started
I will not go into detail here, but with your app running on Heroku you now have a URL which you can feed into the FB registration process for new messenger apps. It's general structure is straightforward and looks like this:
https://name-of-your-bot.herokuapp.com/fb
This is the webhook Facebook is going to communicate with.
For your app to work you need to set the access token which has been generated by Facebook during the registration process.
- Open the Heroku dashboard https://dashboard.heroku.com/apps
- Find and open your app
- Change to
Settings
- 'Reveal' your config vars
- Add a new var with the key set to
FB_ACCESS_TOKEN
and the value to the token you got from Facebook.
If you have anything in mind concerning this repo or the article, let us know! Use the issue tracker or contact us on twitter. Björn @waide, Eike @stagzta