This is the last part of my 4-part series blog where I have explained how you can build your own intelligent bot using Azure. In previous blog we learnt how to write code to perform task.

Before I dive into the technicalities I want to clarify one thing. Most of the users were afraid to start Azure Subscription because it asks for credit card details. Well, yes it does because you might have to pay for some of the Azure features but not all. Also, if you are starting this for the first time Microsoft gives you 30 days trial with $200 credit which you can use for paid features. For this particular task I have used “Pay-As-You-Go” subscription and it’s been almost 2 months and I have been charged $0. Yes, that’s right; I have paid nothing.

Just make sure when you choose the plan for any resource you add select ‘F0’ if it’s an option.

Now to connect your bot with Facebook messenger you will need a Facebook Page. Well, you can keep the Page in development mode if you don’t want everyone to access it. To create the Facebook page visit here.

Fetch Facebook Page Id

Once you have created a Facebook page; go to About section of that page and copy the Page Id (shown below).

part04-gif01

Create Facebook App for your Page

Go to Facebook App page and click on “Create New App”. Enter name of your App for Facebook Page and click “Create”.

part4-pic01

Copy Facebook App Id and App Secret

Now, copy the App Id and App Secret as you will need them later.

part4-pic02

Set “Allow API Access” to Yes

Go to Advance settings and look for “Security” section. You will find an option “Allow API Access to App Settings” (shown below).

part4-pic03

Set your Facebook App with Facebook Messenger

To add Facebook Messenger to your Facebook App; go to Products then find Messenger and click on Setup. Once, messenger gets added it will take you to settings page. On this page scroll to section named “Token Generation” and click on Select Page. Select the page that you created above and a token will be generated. Copy this Token as it will be needed later.

Add Facebook Messenger to Bot Channel

Now, you will want to go back to your Bot in Azure. Click on Channels. Find Facebook and click on it. This will add Facebook Channel to your Bot.

You can connect your bot to multiple channels.

Now, once you add Facebook to your channels update all the needed Facebook credentials (shown below).

part4-pic05

If in case you have trouble finding the information then please use the links below which will help you fetch them again (also highlighted in red on this post).

 

Copy Callback URL and Verify Token on Bot’s Facebook Channel

You will also notice Azure generated the verify token for you and a callback URL. Copy this information as this will be needed later.

part4-pic06.png

Setup Webhook

What is a Webhook?

A webhook is a way for an app to provide other applications with real-time information. A webhook delivers data to other applications as it happens, meaning you get data immediately.

Below the “Token Generation” section you might have noticed a section named “Webhook”. You will find a button called Setup Webhook. Click it. This will ask you to enter the Callback URL and Verify Token. You might have copied this information from the previous step. If not then you can find how to get that information here. Paste this information in the Facebook.

Submit Facebook App for Review

Once you have got all this setup; it’s ready to be published. But to get it accessible it needs to be approved by Facebook community and for that they need Code of Conduct and Terms of Use documents. Microsoft has provided these document links for us.

Copy Microsoft’s Code of Conduct and Terms of Use link when submitting for review. Once the app is approved it will be ready for testing. You can optimally set it to be available publicly or put it in Development mode. If the app is in Development mode then it will only be available for Admins only.

Testing my bot from Facebook Messenger

part04-gif04

That’s it folks. Hope you enjoyed this 4-part series blog and hope you are having fun with it. If you have any other interesting ideas, please let me know.

Please leave your comments or feedback and don’t forget to subscribe.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: