/fbinstant-tictactoe-backend

Nodejs server for FB instant game

Primary LanguageJavaScriptOtherNOASSERTION

Instant Games Server Demo

This demo contains code that demonstrates common scenarios in a backend service that supports an Instant Game client: a game bot and a storage service.

Pre-requisites

  1. npm (Install npm)
  2. Postgresql(Install Postgresql)

Install Dependencies

$ npm install

Configure environment variables

You can rename the file template.env into just .env and input test values of the variables below. This file will be used for local testing. When you host your code in the cloud, you'll need to reconfigure these variables to their production values.

  1. BOT_VERIFY_TOKEN: create a memorable word. You'll use that to validate webhooks with your Messenger Bot
  2. APP_SECRET: paste your App Secret. This can be found in your App's settings page.
  3. USE_SECURE_COMMUNICATION: 1
  4. PAGE_ACCESS_TOKEN: leave blank for now.
  5. DATABASE_URL: connection string to your Postgres installation

Create a Facebook page that will host your bot

  1. Follow the instructions on the Game Bot setup guide to setup a Facebook page that will host your game bot
  2. When associating the Webhooks, under the Verify Token field, input the memorable word you created for BOT_VERIFY_TOKEN above
  3. Once webhooks are configured, copy your Page's access token into the PAGE_ACCESS_TOKEN environment variable of your hosted app.

All done! Your Backend service is configured! You can run your code with

$ node index

Running the client-side code

Follow the instructions in the README.md of the client-side counterpart of this demo:

https://github.com/edgarjcfn/fbinstant-communication