Important
This repository is a migration of an old code repository, re-uploaded for reference and hierarchical tracking. It may not work with the latest Meta (Facebook) Instant Games guidelines. It came from an extension repository created in 2018.
@weaponsforge
20250104
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.
- npm (Install npm)
- Postgresql(Install Postgresql)
$ npm installYou 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.
BOT_VERIFY_TOKEN: create a memorable word. You'll use that to validate webhooks with your Messenger BotAPP_SECRET: paste your App Secret. This can be found in your App's settings page.USE_SECURE_COMMUNICATION: 1PAGE_ACCESS_TOKEN: leave blank for now.DATABASE_URL: connection string to your Postgres installation
- Follow the instructions on the Game Bot setup guide to setup a Facebook page that will host your game bot
- When associating the Webhooks, under the Verify Token field, input the memorable word you created for
BOT_VERIFY_TOKENabove - Once webhooks are configured, copy your Page's access token into the
PAGE_ACCESS_TOKENenvironment variable of your hosted app.
All done! Your Backend service is configured! You can run your code with
$ node indexFollow the instructions in the README.md of the client-side counterpart of this demo: