Facebook Messenger Bot

I was browsing Facebook Dev website and stumbled upon their bot api. Jaw dropping! :scream: Has anyone created a facebook messenger bot? ie a chat bot that response to text inputs? I’m playing with it for my side project and so far I’m hooked!

One thing is sure, regex is used extensively!

My backend for this is Rails.

You may want to consider going beyond the “command line” approach here, if you want your bot to be exposeable to your customers. (If it’s just a remote administration command line for you, of course, then go for it.) I did a talk at Fusion and Hydrahack about this: slides and notes are at, and I believe at some point @FusionAndy and the team are releasing videos. The summary: try to make your thing easy to talk to, without trying to pretend it’s a human. If people really understood “delete income with id 9” then they’d just use the Terminal for everything, right? Lead people gently to the right place; don’t require them to learn “computerese”, especially when computerese here is essentially just SQL in a pretty frock. (More of my writing on this topic: No UI is Some UI.)

This is a good thing, what you’re doing here! I’d love to see more people do this, but equally importantly I’d love to see more people doing it well. And then you can give your bot a Telegram back end as well as FB Messenger and I can use it too :slight_smile:


Kind words @sil. It’s my first attempt. I didn’t liked “delete with id 9” myself but it’s just to test it out. I’ll have look on those slides later when on a bigger screen.

Sure thing; obviously this was experimentation and that’s cool :slight_smile: Just wanted to get some thoughts in on how you might go about this stuff…

1 Like

I have a (very basic) chatbot I’m developing – it asks you silly quiz questions (eg. “Baths or showers?”) then based on your answers (and some very arbitrary hard-coded preferences/tags), recommends you a TV show to watch.

The bot is “dumb” in the sense that it doesn’t parse any input from the user, it all works from Facebook’s callback buttons:

This was because the goal of the bot is to test whether people want to get TV recommendations via a chatbot, rather than testing whether we can intelligently parse their preferences from a chat, which is pointless if nobody wants to do it in the first place.

What I can say it: don’t use regex for parsing messages! (owned by Facebook) is a great tool for detecting entities in messages and training an engine to work out what your users want – it’s designed specifically for Facebook bots.



Will take look!

Ya. If you can lead people through a journey like a Choose Your Own Adventure with buttons then that’s certainly easier!

The approach would be “human ask, then bot do” kind of thing.

Depending on your intended application, there’s another approach you might want to look into:

What this does is convert a regular HTML form into a chat bot. It’s not intelligent but provides another way of getting people to fill in forms which might be more helpful to them. I’m personally thinking it might be useful for something we’re doing at work.

No, no really. What I’m doing has nothing to do with forms or html. Basically the bot performs controller/model actions based on their intent.

So basically when I asked “What’s my account balance or profit margins for this year”, I get an answer based on my income etc.

Thanks for the website, @mattpointblank :hugs: This was what I really need.

1 Like

I’ve found out that has many bugs for my intents and conversation so it’s very frustrating at this simple stage. seems to be a winner in my case though to get it to work properly with my model, I had to use other gems.

I’m trying to understand the difference between both but so far, stands out the best with less or no bugs. Sometimes it gives the wrong intent but I guess that’s where bot training comes in. So “delete income with id 9” now becomes:

  • delete my recent income/expense
  • destroy my income dated from last year to today etc…
  • what was my last/previous income/expense? (the reply), ok… delete that

Flipping hell! How cool is that?

I got carried away in creating this bot which led me not to request regular feedback. The aim is to create an interfaceless bot and Facebook seems to limit their api to what I want to do.

A typical accounting system allows you to Create, Read, Update and Delete everything that you’ve inputted. So my bot can do few except to change the payment type such as ebay, paypal etc

Facebook allows up to three buttons so I though I’d show the most important. Not sure where to put a delete button, although I could have the user delete with an intent “delete my last income/expense”, delete all income/expense from x time", but what if they what to delete a specific income/expense? That one puzzles me. I could have the user edit that income/expense amount to zero, then let them call delete and it’s find all that is zero?

I have two accountants testing this bot but they want it to be over complicated: to add journal, dividend etc shyt! Are all that needed? It’s just a simple bot; not made for everyone nor to replace your bookkeeping/accounting software.

Anyone wants to test and give their own opinion? You must have a facebook account, sorry. Just pm me and I’ll add you as a tester.

PS: You can change your mind with this bot and start another action:

You: “Could you please add an income for today?”
Bot: “Sure, what’s the amount?”
You: “Nevermind”
Bot: “Ok, cancelling”

Been reading a lot that a bot should be as if your are dealing with a person so I try to make it that way. It’s not perfect but I’ll get there.

Proudly sponsored by Bytemark