Add Bot to Slack
While we develop our own integration with Slack, it's possible to integrate your bot using Zapier. As at the time of writing, Zapier offers a free 14 day trial. Mottle is in no way associated with Zapier, nor do we benefit financially from it. Use at your own risk.
You can easily have your bot respond to messages in a Slack channel by creating a Zapier integration.
-
Decide if you want your bot to respond in an existing Slack channel, or a new one. Create the new channel if necessary.
-
Sign in to Zapier and click Create Zap:
-
For Trigger, select Slack and for Event select New Message Posted to Channel:
-
Click Continue and Sign in to your Slack account to connect it.
-
Ensure the correct Slack account is selected and click Continue.
-
Select the channel you'd like to use your bot in:
Ensure Trigger for Bot Messages is set to No, otherwise your bot will get into an endless loop of talking to itself
-
Click Continue.
-
Test the connection between Slack and Zapier by clicking Test Trigger.
-
When setup correctly, click Continue
-
For Action, select Webhooks by Zapier:
- For Event choose POST:
-
Click Continue.
-
For URL enter
https://api.mottle.com/connect?bot=YOUR_BOT_ID
– being careful to substituteYOUR_BOT_ID
for your bot ID. Your bot ID can be found on the Publish / API Page. -
For Payload Type select JSON.
-
For Data, we need to add two rows:
-
secret
– This should be your bot's secret key. Again, you can find this on the Publish / API Page. -
question
– Click on the field to select a dynamic variable. Select the Slack variable that starts with "Text:". It should say something likeText: @hello has joined the channel
.
It should look something like this:
-
-
The rest of the options can be left as is. Click Continue.
-
Click Test Action to test the connection to Mottle. If you've done everything correctly, you will see something like the following:
-
We're not done, so don't Publish your Zap just yet. We need to send your bot's answer back to Slack.
-
Click on the plus icon at the bottom of the screen:
- Select Slack again, and for the Event Type select Send Channel Message:
-
Click Continue.
-
Ensure the correct Slack account is selected. Click Continue again.
-
Under Action, for Channel, pick the same channel as before.
-
For Message, click the box, and then select the dynamic variable: 2. POST in Webhooks by Zapier > 2. Answer {the answer from before...}
-
For Send As Bot, you can choose whether to send as a bot or not, but we would recommend you select Yes.
-
Give your Bot a name.
-
You can also give your bot an avatar. An easy way to do this is to use an emoji. For example, type
:robot_face:
for the emoji 🤖. -
Include a link to this Zap can also be customized. We prefer setting No, but it's up to you.
-
The rest of the options can be left as is. Click Continue.
-
Click Test Action. If you now head back to Slack, and look in your chosen channel, you should see a message from your bot.
-
Click Publish Zap > Publish & Turn On to activate your bot.
-
Once activated, try sending a message in your Slack channel. In a few seconds you should receive a message back from your bot.
-
Congratulations! You've now linked your bot to Slack!
Since Zapier Webhook requests are limited to 30 seconds, you may experience occasional timeouts, particularly when the OpenAI API is under stress (OpenAI status page). Unfortunately there is no way to send this information back to the user – the query will just fail silently. We will try to address this issue when we build our own Slack integration.