How to Automate Tweets Search and Delivery Using a Facebook Messenger Bot

Chatbots are not only a brilliant way to expand your customer service. They also can be used many other ways, just like mobile applications are used.

In this article we’ll tell how we created a bot that can deliver selected tweets to a user.

The problem

Initially, we were looking for a simple solution to grab tweets by some filter — phrase or hashtag. The main requirement was to have it working on any smartphone or desktop to make it possible to use the software on the go.

That’s why we decided to create a chatbot — we don’t need to build client applications, instead we can concentrate on the functionality.

First of all, we wanted to give a user the ability to create, update and delete their search queries. On other side, the bot should be able to search for tweets for each query and send only the unread ones to a user.


First, we checked out if there are any similar bots for Telegram and Facebook. We found few, but also found them to be not really convenient to use. For instance, some bots can work only with hashtags and so on.

So we started outlining the requirements.

Coming up with requirements

We decided to create a Facebook Messenger bot and came up with the following requirements:

  • A user can log into their Twitter account (grabs an access token to make search requests)
  • A user can create, update, and delete their search queries
  • Bot must send new tweets to the user once per hour

The requirements are formed, so we can go on.

A quick prototype

We’ve made a quick prototype using Chatfuel, simply to figure out the user experience with the bot. After some small modifications to the initial idea we decided we can start the development.

The development stage

It was pretty fast and straightforward. JavaScript and NodeJS were used for backend. For data storage we decided to use MongoDB.

During the bot development we faced several issues, and we’d like to share them with you in our next article: “Three Most Common Bugs which Can Live in Your Facebook Messenger Bot”. Stay tuned!

That’s how Hampi was born.

Here it is:

First off, a user logs into their Twitter account. Then, the bot allows them to add a search query.

Voila! Less than a minute has passed and we have set it up it successfully. Now, as Hampi said, a user will receive new tweets each hour (of course, if there will be any new tweets that meet the query).

After the basic setup, a user can add more queries (up to 3 for free users), modify the current one (for example, turn it off) or log out from the Twitter account.

Bot support

We’re constantly improving Hampi. Here’s what we are thinking about right now:

  1. Shortify the links to the original posts. It will save a user’s traffic and make Hampi messages more readable.
  2. Investigate how we can get rid of the tweet duplication. It happens when a lot of people are sharing the same information. Now Hampi treat them as separate tweets, so we’re thinking about implementing some kind of Locality-sensitive hashing (LSH) algorithm to make it filter the tweets with the same content.
  3. Perhaps it will be wise to add some limitation functionality. For example, to let a user to set the limit of tweets they want to receive.

If have your own thoughts on this — please share them in the comments section. We’d love to get any feedback.

About SoftCraft

We’re a team of chatbot enthusiasts. In this article we wanted to show our working process with the case study of one of our projects. Want more insights on chatbot development or want to expand your services using a messenger bot — please drop us a line, we’ll be happy to chat.