/Facebook-Instant-Game-Bot

Messenger bot for instant game

Primary LanguageJavaScript

Instant game messenger bot

Setup

You may host multiple or maybe all of your chatbots in the same server using this guide.

In order to setup a bot for an instant game using serverpilot follow this:

Create a Subdomain(app)

In serverpilot using your prefered domain create a subdomain app Serverpilot

So here our website for the bot will be potato-bot.mywebsite.com

A folder called potato-bot will be created in the serverpilot apps folder

Uploading the files

Using a good ftp/sftp program upload the files in this repo directly to the new app folder

Edit and configure

Now our important files are

index.js
database.js
sender.js

↪️ In index.js

index.js

VERIIFY_TOKEN: You may change this verify token although it is optional in line 4 but when ever I mention the "i eat potato" you should substitute your code.

myport: Port should be different for all the apps you host in the same server. Very important: Right after you change the port also change the port in .htaccess file.

↪️ In database.js

Edit the appName for each app

database name change is only optional if you are in the same server

database.js

↪️ In sender.js

In sender.js edit token and api url sender.js

TOKEN: You get this from facebook.

See How to get token

token

apiUrl:

See How to get api url

If your admin panel installation is at

https://website.com/game

then your apiUrl is:

https://website.com/game/api/apps

Configuration is complete!!

Running! 🚀

Now connect to the server with ssh. (in putty or terminal)

Navigate to the installation folder with cd command

Install all dependencies
npm install

Run app

pm2 start index

Check if when you open the new bot url in thee browser you get this message:

webhook running in /webook

Register webhook

go to facebook developers

if you're adding chatbot for the first time use messenger product

if its not the first time add and use webhook product

Add a /webhook to your bot url

use the verify token we used above

webhook