Skip to content
This repository has been archived by the owner on Sep 9, 2021. It is now read-only.

smartsteuer/caesar-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Caesar Bot

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.

license

Prerequisites

You should know git and node.js and have installed both.

Setup

To create your own version of this bot just:

  1. Clone or copy this repository

git clone https://github.com/smartsteuer/caesar-bot.git name-of-your-bot ```

  1. Change to the new directory

cd name-of-your-bot ```

  1. Install the dependencies

npm install ```

  1. Test if everything works.

npm test ```

Customize

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.

  1. 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)
  2. Run npm test again
  3. Fix all broken tests

You are good to go public!

Deployment

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)

  1. Be familiar with Heroku and install their toolbelt.

  2. Login (if you haven't done this already)

heroku login ```

  1. Create a new Heroku app

heroku create ```

  1. 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

Register your app with Facebook

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.

Configuration

For your app to work you need to set the access token which has been generated by Facebook during the registration process.

  1. Open the Heroku dashboard https://dashboard.heroku.com/apps
  2. Find and open your app
  3. Change to Settings
  4. 'Reveal' your config vars
  5. Add a new var with the key set to FB_ACCESS_TOKEN and the value to the token you got from Facebook.

Feedback

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

About

Companion repository for an article

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published