Cara membuat bot like fb icon


If you just want to see the code, check it out on Github. If you're interested in more about chatbots and PHP, check out my upcoming book.

To make your first chatbot experience a good one, I built a boilerplate for working in PHP. It includes everything you need to know to connect your application to a messenger platform. You will find simple examples to reply to chat messages in different ways. Additionally this boilerplate support the NLP platform Dialogflow. This will help you to process and understand the user's intent. First login to Facebook and create a Cara membuat bot like fb icon page.

The page doesn't need to be public. Choose the settings that fit best your bot, but for testing, it is not essential. Go to the developer's app page. Click "Add a New App" and fill the basic app fields. Now we need to cara membuat bot like fb icon a token to give our app access to our Facebook page.

Select the created page, grant permissions and copy the generated token. We need that one later. This boilerplate is working with a. All sensible data like keys are stored there.

This file should be listed in your. This is because this data should not be included in your repository. Additionally, you can use different keys in different environments. In this cara membuat bot like fb icon there is an example file included called.

Rename it to use it. Next, take a look at this file. Here we have two values to consider for now. Fill something in now; we will need it later. Fill it in here. On our PHP application, we need to have a webhook. This means a public URL that Facebook can talk to.

In this boilerplate, it is the index. If you got a server, you could push your code there where you have public access to it. The URL then maybe looks like https: For testing, it is easier when you don't have to push every change to a live server to test the code.

This is why I use a local public URL. There are multiple services out there that generate a public URL to your local server. Laravel Valet is using ngrok under the hood too. It doesn't matter how you do it, but you just need a secured public URL to the index. This is my URL: Now that we got the URL we need to setup the webhook.

Go back to your Facebook app settings and click Setup Webhooks inside the Webhooks part. If you did everything right, you have a working webhook now. If not you will see an error icon in the webhook URL field. This happens if the URL or the token is not correct. Now the last step of the installation will make sure that our Facebook app is connected to the Facebook page. For this purpose, there is a drop-down within your Webhooks setting page. Choose your page here cara membuat bot like fb icon click Subscribe.

So finally we can test the whole setup. Go to your Facebook page and click the message button to send a message. Type Hi and press enter. You should now see this answer: Define your own logic to reply to this message: If you see this, then cara membuat bot like fb icon. Additionally, you can use the built-in Monolog Logger to debug the applications.

Here the user's message is being used to get an answer. In this case, the message is analyzed in the ChatbotAi method getAnswer. It is simply returning a static text with the original message. Like mentioned below, you can define your own logic to respond to the message. In the example, the method returns some hello text, if the message contains hi, hey or cara membuat bot like fb icon. Here a public API is used to return foreign exchange rates to the user. It is a simple example but good to see how to work with external APIs.

To make it work, comment out the first example and uncomment the second. NLP platforms can help you cara membuat bot like fb icon the user's intent of a message; we can use them as a service where we send the user's message to. To use Dialog flow you just need to add the parameter dialogflow to the getAnswer method. There is also an example in your index. Besides that, you also need to set up an intent in Dialogflow. I won't cover that in this tutorial, but I will show you a screenshot of the one that I use for this example.

So it will also automatically detect the language the user said. It is now also possible to make use of DialogFlow's payload responses.

If you want to reply custom Facebook payloads right from DialogFlow, then this is what you need. But it only works, when there is no text response added to the intent. Check out the changes for more details. The former story feature from wit. Right now I wouldn't recommend using wit. You should now have a simple chatbot and a perfect setup for building your own. Try to implement your logic now to respond to the user's messages. This repo should be a place where you can try this stuff out. If you plan to build a bigger chatbot, please check out my tutorials on how to use a professional bot library like BotMan to build bots for FacebookTelegram or Slack.

Sign up for my newsletter and I will let you know about more content and new projects of mine once a month. This article was cara membuat bot like fb icon in February as cara membuat bot like fb icon as the boilerplate. Let's stay in touch Sign up for my newsletter and I will let you know about more content and new projects of mine once a month.

Also, the opinions expressed here are solely her own and do not express the views or opinions of my employer. As you may have heard of, API. My step-by-step instruction uses Node. The source code on tutorial branch is on GitHub. The bot has been approved by Facebook so you can try the bot! I choose ngrok to serves a localhost to a public URL because it is simple and easy to use.

When you start ngrok, it will display a public URL of your tunnel in the terminal. We will need the URL later when setting up the Facebook app. In the screenshot, the URL is https: This is how you receive messages to your webhook via Facebook Messenger- All requests should come via postwhile the GET route is only used at the time you configure your Facebook app.

You will need later when setting up your Facebook app. You need a Facebook Page to set cara membuat bot like fb icon your chat bot. Create one from facebook. Then click Get Started. Then create an app at developers. Click Add Product from the left menu, then choose Messenger.

At the Token Generation1 choose the page you just created from the dropdown menu, and cara membuat bot like fb icon will generate a token 2 that you will need to include in your node code.

Click the Verify and Save. Otherwise, you are ready to get back to code. Continue with your webhook. Try running the code. This acts as a very simple bot, which interact the Messenger platform to receive a message and echo the message as the reply- Go to [https: If your the simple bot works correctly, it just replies the exactly what you send:.

Your entry is simply echoed back. Once you get your account, create an agent. This gives your bot an ability to have simple conversations.

Once activated, click View details then turn on the Cara membuat bot like fb icon so that you can later use this feature in your app and customize.

Try the Console at the right hand side. You can either speak cara membuat bot like fb icon type to test the Small Talk cara membuat bot like fb icon. You can always come back here to customize the conversations. It is actually possible to integrate API. You need your API. Cara membuat bot like fb icon go back to your webhook. Refer the usage on its npm doc. It is pretty simple- you just pass a text to API. What the code sample above doing is basically getting the info passed as a param sent from a user via Messenger, and pass the text content to API.

Run the node code, and try sending some messages. If everything is working, you should get replies from the bot:. When you activate the Small Talk from the Domainsyou may have noticed there are more presets cara membuat bot like fb icon Weather and Flight Schedules, etc. To use these services, it looks like you need to send inquiry to their sales peeps. However, of course as an engineer, you can always call the 3rd party APIs to add the features by yourself instead of just flipping the switch and pay.

First, to customize the conversational user interfaces, you need to understand the key concepts of API. To make your bot reply the user with a weather info, you need to create a specific Intents. What you see here are pre-defined entities. There are many entities in the list but what you need here is a collection of cities.

The city name will be highlighted. Major city names have been provided already so you do not need to create them, however if you need to define special entities that not listed there, such as types of cars, food, etc, you will need to create manually.

I am not covering how to define entities in this article this time! You need this action name on your node code later. Then 2 at Responseenter a default response. Save the Intents, and go to Fulfillment from the menu. We are going to use the API to fetch a current weather data for one location. If you deploy your bot, make sure to change your webhook endpoints on both Facebook Developer app setting and API. I hope you enjoyed the article. Now you can tailor your intents, add more features, and use the training feature for better results to make your bot more interesting!

Hey, happy new year!!! There are two major parts:

First there were desktop software products, then everything moved to the web. Then there were email-based products and even SMS-based ones.

The latest craze in software interfaces is messenger bots, and Facebook has the largest chat platform by a long shot. First, git clone the Github repository that I set up for this project:. Then, cd into it and install python dependencies: Then, in your browser, visit http: Make sure you grab the full https: You can skip through most of the setup steps.

Then create cara membuat bot like fb icon new Facebook App for your bot and give your app a name, category and contact email. Click on the Page Access Token to cara membuat bot like fb icon it to your clipboard. On the command line, in the same folder where you cloned the application, run:. This token will be used to authenticate your requests whenever you try to send a message or reply to someone.

This should open a message pane with your Page. Receiving Messages We handle incoming messages starting on line 24 inside app. In step 4, we told Facebook what message types we want our webhook to be notified about. Sending Messages In order to send a simple text message, you only need two things:. There are many more complex message types you can send, including messages with images and buttons. More information on those message types here.

These are essentially buttons that, when tapped by a user, send a postback messaging event to your webhook. You could use this for placing an order, confirming a request or lots of other things.

Whenever a user taps a postback button, your webhook is notified and can perform any sort of subsequent follow-up action necessary. You have to go through a review process before your cara membuat bot like fb icon is open to the world, ready to chat with anyone.

Facebook seems to be very thorough in their review process, and with good reason. The code for a messaging bot runs on your own servers and could change at any time, without Facebook knowing.

Go back to your Messenger App Settings page that we used in Step 4. On this page, you can also ask to be granted extra information about users, like their email or profile information. Then it all goes to the Facebook review team to sign off and give you full access to the Messenger platform. More information about the approval process here.

I'm a full-stack web developer and tech lead with 6 years of experience across many modern tech stacks. Cara membuat bot like fb icon always looking to talk to new clients and contribute to cool projects. Contact me or check out my side projects. Facebook Messenger Bot Tutorial: Get Email Updates One or two emails a month about the latest technology I'm hacking on.

And You Can Too!