This bot sample code is provided by Solution Fuse to help provide the broader community and those interested in bot development a starting point to getting a bot up and running in PHP while utilizing the Machaao MessengerX Platform. For more information or inquiries, please reach out to [email protected]
messengerx-php-sample : This is an echo bot which shows the basic usage of the MACHAAO send message API, it contains the php code base to get you started
Contact Machaao for registering your bot url and they will issue you an api_token ([email protected])
- Install ngrok for your OS via https://ngrok.com/download.
- Run ngrok on port 5005 with the following command, and note the generated https url
ngrok http 5005
- Clone the php script from this repo
- Move to your root directory
- run
php -S localhost:5005
this will start the php webserver in
port 5005
Update your bot url on MACHAAO with the NGROK url provided as shown below to continue development
curl --location --request POST 'https://ganglia-dev.machaao.com/v1/bots/<YOUR API-TOKEN> \
--header 'api_token: <YOUR API-TOKEN>' \
--header 'Content-Type: application/json' \
--data-raw '{
"url": "<YOUR URL>/mahaao_hook.php",
"description": "<YOUR BOT DESCRIPTION>",
"displayName": "<YOUR BOT NAME>"
}'
We are assuming you have access to a heroku account and have installed heroku command line client for your OS.
heroku login
Create a new app on Heroku and note down your heroku app name
heroku create
Create an app on Heroku, which prepares Heroku to receive your source code
Now deploy your code
git push heroku master
heroku logs --tail
Heroku treats logs as streams of time-ordered events aggregated from the output streams of all your app and Heroku components, providing a single channel for all of the events.
Update your bot url on MACHAAO with the heroku url as shown below to continue development
curl --location --request POST 'https://ganglia-dev.machaao.com/v1/bots/<YOUR API-TOKEN> \
--header 'api_token: <YOUR API-TOKEN>' \
--header 'Content-Type: application/json' \
--data-raw '{
"url": "<Your_Heroku_App_Name>.herokuapp.com/machaao_hook.php",
"description": "<YOUR BOT DESCRIPTION>",
"displayName": "<YOUR BOT NAME>"
}'