Reading list Switch to dark mode

    Facebook messenger chat bot in PHP

    Updated 16 December 2016

    Facebook messenger chat bot: Facebook has introduced it’s bot platform for messenger, that provides a new platform for individuals or business so that they can interact with their customers faster and in a very interactive way.

    What is chat bot: A computer program designed to simulate a conversation with human users  especially over the internet. It has functionality ranges from normal interaction to having highly artificial intelligence.

    Requirement to start creating bot: In a basic requirement, you must have three things

    • Website or webpage hosted with an SSL certificate, else Facebook will not accept your url for the request and response to the messenger.
    • Facebook app
    • Facebook page

    Let’s create a chat bot using the Facebook messenger platform.

    First of all, create a Facebook page, visit https://www.facebook.com/pages/create and you’ll see options as below screenshot.

    Start your headless eCommerce
    now.
    Find out More

    Facebook create page

    You can select any category as per your business or individual choice. After selecting a category, you’ll asked few more options, after putting all the required information on the next screen, your Facebook page will be created as below screenshot.

    Facebook page

    Your page will look like as above screenshot after few more setting, in the page setting options. Now we have a Facebook page, now we need an app to connect this page to the messenger platform and your desired website or web page.

    To create an app, go to https://developers.facebook.com/apps and hit the button labeled add a new app and you’ll get a pop window which will ask for some details as below screenshot.

    Facebook adding app

    After hitting the button create App ID, your app will be created and you’ll be redirected to the app’s dashboard and you’ll see something like below screenshot.

    Facebook app dashboard

    Now, click on the add product button to add messenger to your app. After clicking add product button, you’ll see list of products, search for messenger and click on the get started button. On the next page, you’ll have to do two things, first is, generate token for your earlier created Facebook page and the second is,  setup of webhook, which is your website’s or webpage’s url.

    Token and webhook Setup

    After selecting the desired page, you’ll get access token to that page and this token will be used as security token between your web application and facebook application. Now click on the setup webhooks button and fill the form, put url and any randon string that suits to your business as I’ve given webkul_fb_shopbot, which will be further used to verify your given url and check all the desired options whatever you want and click on verify and save button, it will hit to your url for verification.

    06

    Put the code as below screenshot and it will verify to your webhook url and always hit this url when any customer will chat with the page.

    php code to verify webhook

    For any further support, please mail us at [email protected]

    Thanks

    . . .

    Leave a Comment

    Your email address will not be published. Required fields are marked*


    1 comments

  • TechAndSam
  • Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home