paint-brush
Journey of the Facebook bot creationby@sandeep.scet
246 reads

Journey of the Facebook bot creation

by SandeepMay 25th, 2017
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

<strong>Original Goal: Message F.R.I.E.N.D.S. dialog to my wife daily automatically.</strong>

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - Journey of the Facebook bot creation
Sandeep HackerNoon profile picture

Original Goal: Message F.R.I.E.N.D.S. dialog to my wife daily automatically.

FRIENDS is my wife’s favorite show. She is not able to get time to watch since our son is born. My original plan was to send automated message her on WhatsApp daily. The problem with WhatsApp is they do not provide any official API for messaging. This will be one of the reason of its downfall for sure. Telegram, slack, messenger etc. are providing API support to create BOT.

So I decided to move on messenger. The only problem with this approach is that I have to manually message her on Whatsapp. But when I saw a smile on her face after reading messages, it’s worth it.

I started searching for bot framework in PHP. There are many frameworks on GitHub. For every framework initial setup was required for client ID and client Secret. So I need to sign up as an application developer and configure these values. Also, I have to setup conversation reply for every dialog.



$botman->hears('Send me some dialog please', function (BotMan $bot) {$bot->reply('Checking!!!');});

Everything was planned and ready. Then I suddenly remember that freehostia do not support curl operations on the free plan. I am using freehostia for hosting of my website.

I started searching for alternative and found amazing bot platform.

Chatfuel takes care of everything related to bot configuration. No coding required.

I only have to provide JSON response as a message to their callback. Also, they provide broadcast functionality where a bot will send schedule message on specified time interval. I set up a daily reminder on a morning.

The problem of bot now sorted. Now I have to work for dialog only.

Manually adding dialog will be time-consuming. Also extracting from subtitle also not worked as hard to find good dialog programmatically. So started a searching on the internet for ready-made dialog.

My search leads me to Wikiquote link.

As my hosting provider do not support curl, I can’t get at run-time by parsing from Wikiquote on chatfuel callback. I parsed all pages locally and stored on the table. I imported that table on freehostia and wrote Callback script to select one dialog randomly from a table. Done

If you liked this, click the 💚 below so other people will see this here on Medium.