PHP >=5.5
composer
- ngrok
- Facebook Account
For simplicity of this task, we will use built-in PHP server.
- install dependencies with
composer install
- from project's directory run in console
php -S localhost:9999
. - check local PHP server is running - in browser go to
http://localhost:9999/
- you should see a blank page.
Ngrok is local proxy allowing your PC to be accessible from Internet.
- download
ngrok
from https://ngrok.com/download and extract it in project directory. - make sure it is executable - run in console:
./ngrok
. - start
ngrok
to have public proxy -./ngrok http 9999
. - make sure everything is OK with
ngrok
by going to http://127.0.0.1:4040/inspect/http
-
Go to Messenger API platform and click
Try It now
-
Fill required steps:
- Check the checkbox
- Skip Node.JS installation
- Enter chat bot name - must start with capital letter
- Skip package download - we do not need it
- Fill url you got from
ngrok
setup - do not pressNext
, you will get an error - In another browser tab go to Facebook Apps
- Click on App with your chat bot name (You filled it in
Step 3
) - Save the
App ID
andApp Secret
- in configuration file - Go to
Messenger
inProducts
sidebar - Under
Token Generation
selectPage
with same name as your chat bot name, save thePage Access Token
in configuration - Go to previous browser tab and click
Next
inStep 5
-
If everything was according to plan, you can open Messenger, search for chat bot and he should reply to you.
In case you restarted ngrok
, you will receive a new public hostname, you need to change it in App Webhooks