DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

How does AI transform chaos engineering from an experiment into a critical capability? Learn how to effectively operationalize the chaos.

Data quality isn't just a technical issue: It impacts an organization's compliance, operational efficiency, and customer satisfaction.

Are you a front-end or full-stack developer frustrated by front-end distractions? Learn to move forward with tooling and clear boundaries.

Developer Experience: Demand to support engineering teams has risen, and there is a shift from traditional DevOps to workflow improvements.

Related

  • Unlock AI Power: Generate JSON With GPT-4 and Node.js for Ultimate App Integration
  • How To Integrate Chatbot With an Android App
  • Unleashing the Power of GPT: A Comprehensive Guide To Implementing OpenAI’s GPT in ReactJS
  • Power of AI Language Models for React Developers: A Comprehensive Guide

Trending

  • KubeVirt: Can VM Management With Kubernetes Work?
  • How Security Engineers Can Help Build a Strong Security Culture
  • Engineering Resilience Through Data: A Comprehensive Approach to Change Failure Rate Monitoring
  • Monoliths, REST, and Spring Boot Sidecars: A Real Modernization Playbook
  1. DZone
  2. Data Engineering
  3. AI/ML
  4. How to Integrate a Chatbot With Facebook Messenger

How to Integrate a Chatbot With Facebook Messenger

See how to quickly integrate a chatbot to Facebook Messenger.

By 
Paul Pinard user avatar
Paul Pinard
·
Apr. 26, 19 · Tutorial
Likes (2)
Comment
Save
Tweet
Share
19.0K Views

Join the DZone community and get the full member experience.

Join For Free

When it comes to sharing your chatbot on different channels, Facebook Messenger MUST be one of your first choices — if not THE first choice! In fact, we realized many companies immediately put their bots on Facebook once in production, as it’s clearly the most user-friendly and easiest way for a customer to contact a company.

A Facebook chatbot has several advantages:

  • 24/7 availability
  • 100% answers
  • Instant answers (think about your Answer rate!)
  • Tedious tasks are automated

On the SAP Conversational AI platform, we created a step-by-step integration process for our users so that it only takes a few minutes to reveal your chatbot to your Facebook followers. Let’s dive in!

Step 1: Get Your Chatbot Ready

First of all, you’ll need a chatbot (seems legit, right?!). Note that once your chatbot is online on Facebook, you’ll be able to modify it, and any changes you make to it will appear in your Messenger chat.

For the purpose of this tutorial, we won’t go into how to create a chatbot. Instead, I warmly invite you to create your account (it’s completely free!) and read our tutorial “How to Build Your First Bot With SAP Conversational AI.” Once your “Joke Chatbot” (or whatever you’ve built) is ready, return here!

Step 2: Get Your Facebook Page Ready

Your chatbot will only be available for integration on a Facebook page (not on your personal profile). This means you have to create a Facebook page or have in mind the one you’ll use. Let’s assume your company, business, or group already has a page. (If that’s not the case, hit this link and create one.)

As I said in the introduction, having a chatbot on a Facebook page will automate private messaging once it’s connected to your page. Thus, if you decide to remove the chatbot, you’ll immediately revert to traditional person-to-person conversations (which means nothing will happen when users enter a message until you manually answer them).

Step 3: Create a Messenger Facebook App

Creating an app will help make the connection between SAP Conversational AI and your Facebook page. Without this app, you won’t be able to publish your chatbot on your Facebook page.

Click on this link, choose My Apps in the top menu, and then Add New App.

Once your app is created, you’ll have to add a Messenger “product.” There are tons of jobs a Facebook app can be dedicated to, but we specifically want a private messaging application. Go to your app’s dashboard and click Set Up in the Messenger box.

In the left-hand menu, you’ll then see Messenger under PRODUCTS.

Step 4: Get Your Page Token and App Secret

Now that we’ve created a Messenger app, we need to link it to your Facebook page (by default, a Facebook app is an independent entity). With this connection, you’ll be given a token, which is basically a unique code that says “OK, this is the code of the Messenger app of the page X.”

In the left-hand menu, click Settings just below the product Messenger.

Choose the page you want your chatbot to appear on.

For security reasons, you’ll probably need to allow the app to interact with your Facebook page. Click the blue Edit Permissions button, select your page, and check the different boxes.

Once the permissions are given, a token will be generated.

Go back to the Connect tab in your SAP Conversational AI chatbot, choose Messenger, and paste your token in the Page token field in step 4.

We’re halfway there!

Let’s now get our “app secret,” which is like a password for your app.

In the left-hand menu, go to Settings > Basic.

For privacy, the app secret is hidden. Click Show and copy and paste it to the App secret field on your chatbot’s Connect tab (similar to what you just did with the page token).

Click Update channel under the SAP Conversational AI form.

Step 5: Connect SAP Conversational AI to Your App

It’s time to connect our platform to Messenger!

On the Products > Messenger > Settings page, go to the Webhooks section and click Subscribe To Events.

In the pop-up window, enter the values for Callback URL and Verify token that you’ll find in step 4 of your chatbot’s Connect tab.

Also select the checkboxes shown below:

Once your page has reloaded, select your page in the list so that it can access your webhook.

Step 6: Test and Publish the Messenger Chatbot

Now you can test your bot as an administrator (you can also grant some test roles using Roles > Test Users in the left-hand menu). Your bot won’t be publicly accessible until you change the status, so take your time to test it and make sure everything is just fine before releasing it to the world!

Once you’re happy with your bot, if you change the toggle to ON (in the top right corner), you’ll be redirected to the settings and prompted to provide some extra information before your bot is published. (Tip: You can also access the settings under Settings > Basic in the left-hand menu.)

Very last step: Facebook will want to verify and test your Messenger chatbot. Here’s what they say about this step in their documentation:

"When you are ready to release your bot to the public, you must submit it to our team for review and approval. This review process allows us to ensure your Messenger bot abides by our policies and functions as expected before it is made available to everyone on Messenger." — Facebook Documentation

In the left-hand menu, go to Products > Messenger > Settings and click Add to Submission in the pages_messaging block.

It won’t take long for the Facebook review team to look at your bot and give you the green light to publish it!

Conclusion

I hope you enjoyed this tutorial. And remember, you’re very welcome to contact us if you need help through the comment section below or via Stack Overflow.

If you’re looking for another tutorial to improve your chatbot building skills and connect it to Amazon Alexa, you can check out this article.

Happy bot building!

Facebook Messenger Chatbot app Integration

Published at DZone with permission of Paul Pinard. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Unlock AI Power: Generate JSON With GPT-4 and Node.js for Ultimate App Integration
  • How To Integrate Chatbot With an Android App
  • Unleashing the Power of GPT: A Comprehensive Guide To Implementing OpenAI’s GPT in ReactJS
  • Power of AI Language Models for React Developers: A Comprehensive Guide

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • [email protected]

Let's be friends: