Yoda Search: A Slackbot for search

Inspired from the wisdom of our great Jedi master, we present Yoda-Search, our first contribution to OSS after being longtime fans. Incidentally, it is also a great way to kick off our tech blog :)

Essentially, Yoda is a slack bot that indexes your messages in ElasticSearch so that you can search your messages past the 10,000 messages limit imposed by Slack’s free tier.

Why did we do this but?

Because, 7$ per user per month matters. — Vijay Rawat, Jedi Knight at OFB

Message search is a feature that’s part of Slack’s paid plans, starting at a minimum of 7$ per user per month. Hence, this noble thought inspired the said Jedi to use the Force and come up with a free solution to this problem.

How can you use this?

To execute a query privately, type:

/yoda [query] , for example, /yoda deployment

That queries your messages and returns matching responses from the current channel, group, or conversation. The query response is visible only to you.

For a public response, use the format:-

q:[query], for example, q:hello

This will do the same thing, but the query and response will be visible to everyone in your group and channel.

For detailed setup instructions, head over to our Github repo.

Under Da Hood: For our curious brethren

The main ingredients used here Slack’s RTM client and Elasticsearch’s JS client, wired through a simple NodeJS app which is also a simple web server.

We listen to Slack messages on channels and private groups wherever our bot is added, and direct conversations with the bot itself. All messages and files are indexed, except for the ones used to execute a search query.

A public query using the q: format is intercepted using the RTM client message listener, and the query string is searched in Elasticsearch across multiple message fields. The responses are posted on the same thread by our bot, visible to all members.

A private query using the /yoda format is a Slack slash command. This leads to Slack hitting our simple web server with an API call containing the search query. Again, we search our index and return responses, but this time as an HTTP response to Slack’s API call rather than an RTM message.

Initially, it was more of a fun project but after some time when enough messages were indexed into the system, we realised that this is awesome and we should share this with the world.

If you’re reading this, we strongly encourage you to raise issues and contribute to make the project better, because we have a long way to go :)