Today we’ll be making a bot for Slack, one of the primary features of Montag is Bot management, and if you’re using it one of the things you’ll likely want to do soon is put a bot out there.

Montag currently has two ways to build a bot: Slack, and as an OpenAI API Shim server. We’ll focus on Slack today as it’s probably a bit clearer and easier.

To build a bot in Montag all you need is a Prompt, and some Slack API credentials.

To make a slightly more useful Bot, you will also want to have built a text collection (see our other buide on that), because then you can enhance your bot with simple Retrieval Augmented Generation with almost zero additional effort.

Step 1: Get some Slack App Credentials

First off, you need some Slack app credentials, this is an incredibly involved process which I won’t go through here, but it is fully documented right here.

You will need two tokens, an App token and Slack Token. Best practice would dictate that we encrypt these, so we’ll put them in the Montag Secrets store. The secrets store will encrypt all the data you put there when it’s at rest, so it’s relatively safe from prying eyes.

To add a secret, go to the Secrets section of the UI, and click “Create Secret”. You will need to give it a name, and then paste in the value of the token. Once you’ve done that, you can reference the secret in your bot interface configuration using the $SECRET/<name> syntax.

Step 2: Create the Bot Interface

Once you have those keys, you need to create an interface for your bot. To do that, we will go to the Bot interfaces section and click create. In this case, select the type “Slack”, and then reference the two tokens for this bot using the special $SECRET syntax, to tell montag to pull these values from the secret store instead of the raw value of the field (this doesn’t work on every field, only ones with sensitive information like tokens, secrets and keys).

With the interface saved, it’s time to create a prompt

Step 3: Create a Prompt

We’ll make a bot called Wednesday who is helpful, but really grumpy, navigate to the Prompts section, then click “Create”, you should only need to add the instructions, you can safely ignore the rest as these defaults should just work.

Instructions: you are a helpful AI Assistant and you are quite grumpy, you help users with their tasks and answer questions, but you are not happy about it.

Step 4: Create the Bot

Now, let’s actually creat the bot. Bots are just combinations of settings, navigate to the “bots” section, and then click “Create”.

In this case we only need to set up the Base Settings and LLM Settings sections, the rest can be safely ignored for another guide where we’ll enhance this bot with embeddings.

  • Name: Wednesday
  • Interface: Select the Slack interface we just created
  • LLM Settings: You can pick the OpenAI preset, assuming you’ve been following along with this guide and set the OpenAI token either as a secret, directly in the API Client congiguration, or as an environment variable.
  • Prompt: Select the prompt we just created

Now just save the bot, and you’re done!

To start the bot, navigate back to the Bot listing page, and click the “Start” button next to the bot you just created.

If it doesn’t error, you shoul now have a bot connected to Slack!

Montag bots only operate in channels, so you’ll need to invite the bot to the channel and then @mention it to get it to respond.