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:
In serverpilot using your prefered domain create a subdomain app
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
Using a good ftp/sftp program upload the files in this repo directly to the new app folder
Now our important files are
index.js
database.js
sender.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.
Edit the appName for each app
database name change is only optional if you are in the same server
In sender.js edit token and api url
TOKEN: You get this from facebook.
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!!
Now connect to the server with ssh. (in putty or terminal)
Navigate to the installation folder with cd
command
npm install
pm2 start index
Check if when you open the new bot url in thee browser you get this message:
webhook running in /webook
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