spotjade.blogg.se

Create chatbot tutorial php
Create chatbot tutorial php











create chatbot tutorial php
  1. Create chatbot tutorial php install#
  2. Create chatbot tutorial php code#

You should now see this answer: Define your own logic to reply to this message: Hi Go to your Facebook page and click the message button to send a message. Choose your page here and click Subscribe. For this purpose, there is a drop-down within your Webhooks setting page. Now the last step of the installation will make sure that our Facebook app is connected to the Facebook page. Connect the Facebook app to the Facebook page This happens if the URL or the token is not correct. If not you will see an error icon in the webhook URL field. If you did everything right, you have a working webhook now. env file, check all the subscription fields and click

create chatbot tutorial php

Go back to your Facebook app settings and click Setup Webhooksįill in in the public URL, the WEBHOOK_VERIFY_TOKEN from the. Now that we got the URL we need to setup the webhook. This is my URL: Connect the Facebook app to your application It doesn't matter how you do it, but you just need a secured public URL to the index.php file. (Laravel Valet is using ngrok under the hood too) Checkout out ngrok or use Laravel Valet Sharing which is my choice since I'm using Valet already. There are multiple services out there that generate a public URL to your local server. Do it locallyįor testing, it is easier when you don't have to push every change to a live server to test the code.

Create chatbot tutorial php code#

If you got a server, you could push your code there where you have public access to it. So we need a public URL to the index.php file, and there are two options here for you. In this boilerplate, it is the index.php file. Every time the user writes a message inside the FB chat, FB will send it to this URL which is the entrance point to our PHP application. This means a public URL that Facebook can talk to. On our PHP application, we need to have a webhook. Perfect! Create a webhook for the messenger app The second value is the PAGE_ACCESS_TOKEN which we already got from our messenger app. Fill something in now we will need it later. First one is the WEBHOOK_VERIFY_TOKEN which is a token you can define yourself here. Here we have two values to consider for now. In this boilerplate there is an example file included called. (e.g., test bot platform account on your local This is because this data should not be included in your repository.Īdditionally, you can use different keys in different environments. All sensible data like keys are stored there. Note: Depending on how Composer is installed on your system / project the command

Create chatbot tutorial php install#

Now we need to install the Composer dependencies: composer install Setup the Chatbot PHP Boilerplateįirst, clone the repository and remove the existing git folder. Select the created page, grant permissions and copy the generated token. Now we need to create a token to give our app access to our Facebook page. On the "Product Setup" page choose Messenger and click "Get Started." Click "Add a New App" and fill the basic app fields. Choose the settings that fit best your bot, but for testing, it is not essential. Connect the Facebook app to the Facebook pageįirst login to Facebook and create a Facebook page.Note: Currently only Facebook Messenger is supported.













Create chatbot tutorial php