We lean pretty heavily on Slack for our day-to-day communication at Zapier. You could even say we push the boundaries of how much work can get done in Slack during our quarterly no meeting week.
Something that helps us get the most out of Slack is using Zapier to connect our favorite apps—giving us more capability inside an already powerful platform.
One of my favorites I've connected recently? ChatGPT. By integrating ChatGPT and Slack, I can create ChatGPT-powered assistants that can answer employees' questions across a range of topics inside Slack.
And, because you can upload your own company files to these bot assistants, your teams can get help with accounting, content specifics, office budgets, and more—all without switching context.
In this blog post, we'll walk through two different ways to bring the power of ChatGPT—and GPT-4, if you're a ChatGPT Plus user—into your Slack workspace.
A ChatGPT reply bot (assistant) that sends replies with a response from ChatGPT (and your own company files) in a thread whenever a prompt is posted in a particular channel
A ChatGPT slash command bot that sends prompts and fetches responses in any channel
This workflow requires a multi-step Zap, which is available on a paid Zapier plan or during a free trial. Learn more about multi-step Zaps.
Before you begin
Make sure you set up a free OpenAI account before getting started. Once you've opened your account, click the settings tab in the top right corner and select View API keys.
Then, click the + Create new secret key button to generate your API key. Make sure to copy the key while you're here. You'll need it later when connecting your OpenAI account to Zapier.
You'll also need to create your assistant within OpenAI.
To do this, head over to https://platform.openai.com/assistants. This is where all the assistants you create are stored, including the assistant ID, instructions, and date created.
To create a new assistant, click +Create in the top right corner.
Now it's time to configure your assistant. Once you've given your assistant a name, you should provide it with the specific instructions relevant to its role.
For the focus of this tutorial, I want to create a content assistant that can help answer my team's questions on blog content, including voice, tone, and guidelines for uploading content to the CMS. But you can create an assistant that covers any other role.
Here's my example:
Next, select the OpenAI model you want to use. Because we'll be using the file retrieval tool, we'll select gpt-4-1106-preview.
Note: The Retrieval tool requires gpt-3.5-turbo-1106 or gpt-4-1106-preview models.
Under Tools, you can select either a code interpreter or a retrieval function. The retrieval function allows your assistant to respond to users' questions with knowledge from documents or files you upload. To enable this function, toggle the gray switch.
Finally, you can upload the files to your assistant's knowledge base by clicking Add file. For the purpose of this tutorial, I'll be uploading three documents that contain instructions about the Zapier blog's style, voice, and CMS instructions.
Once you're finished uploading your files, click Save. You're now ready to begin!
Create a ChatGPT reply bot in Slack
With Zapier, you can create automated workflows (we call them Zaps) that send information between different apps. You can create a Zap from scratch or use a template to get started quickly.
Getting started with a template is easy. Click on the Zap template below, which will take you to the Zap editor. You'll be prompted to create a Zapier account if you don't have one already. Once that's done, just follow the instructions below to set up your Zap.
New to Zapier? It's workflow automation software that lets you focus on what matters. Combine user interfaces, data tables, and logic with thousands of apps to build and automate anything you can imagine. Sign up for free.
Set up your Slack trigger
Time to set up your trigger—the event that starts your Zap. Choose Slack for your trigger app and New Message Posted to Channel as your event. If you're using the Zap template, this will already be selected for you.
Connect your Slack account if you haven't already. Click on Choose an account… and click + Connect a new account, or select an account from the dropdown menu if you've connected Slack to Zapier before.
Click Continue. Next, select the channel you want your ChatGPT assistant to answer questions in. Click the dropdown menu to see the list of channels in your selected Slack account.
Click Continue.
Now, you need to test your trigger. Zapier will find a recently posted message in your chosen channel and use it to set up the rest of your Zap.
Click Test trigger. Once the trigger is working properly, click Continue.
Set up your ChatGPT action
Now let's set up your action—the event your Zap will perform once it's triggered. Choose ChatGPT as your action app and Conversation with Assistant as your action event. If you're using the Zap template, this will already be selected for you. Click Continue.
Next, a pop-up window will appear asking for the OpenAI API key that you copied earlier. Paste it into the API Key field, and click Yes, Continue to ChatGPT.
Now it's time to set up your action. You can pull in data from your Slack step by clicking inside the Message field and picking an option from the Insert Data dropdown. In our case, we'll want to pull in a sample question posted in our Slack channel of choice:
Now it's time to select the assistant you previously set up in OpenAI. Click inside the Assistant field and pick the right one from the Insert Data dropdown.
For this example, you don't need to add any information into the Assistant Name, Assistant Instructions, and Model fields, as you've already configured this information within OpenAI. You'd only fill out these fields if you want to create a new assistant every time your Zap runs, or if you want specific instructions to override the existing assistant you created in OpenAI.
Next, under Tools, select the Retrieval functionality from the dropdown.
You can also include a conversation ID which will allow the assistant to remember a conversation. If left blank, you can still talk to your assistant in Slack, it just won't remember the conversation.
Once you've customized this step, click Continue.
Next, you'll test your action. Click Test & Review or Test & Continue, and Zapier will pull the response from your assistant, according to how you customized your fields.
Once your action is working, click the + button below your action step.
If you're using the Zap template, this will already be added for you.
Set up your Slack action
Now, you'll set up the step that sends your ChatGPT response to Slack. Choose Slack for your action app and Send Channel Message for your action event. Again, if you're using the Zap template, this will be set up for you.
Again, you'll be asked to connect your Slack account. Connect the Slack account where you want the message to be posted. In most cases, this will be the same Slack account you connected earlier.
Click Continue.
Now it's time to set up how the message from your ChatGPT assistant will look in Slack and where it'll be posted. Select the Slack channel from your previous Slack step.
Add any other context you want to the Message Text field, and make sure to include Full Response from the data dropdown, as that contains your response from ChatGPT.
You can also customize where the message comes from, such as from a bot or yourself. If you choose a bot, you can customize things like the bot name and the icon that appears next to it.
If you'd like your bot to reply in a thread rather than in your Slack channel (and I recommend this), navigate down to the Thread field. Click in the field and select the timestamp (shown in Zapier as Ts) of the parent message in the dropdown to let Zapier know which message to create a thread for.
Once you've customized your message, click Continue.
Now it's time to test your action. Click Test action. Zapier will post a message in your chosen Slack channel to make sure your Zap is working.
If everything looks good with the message thread Zapier posted to your question, then your Zap is ready to use. If something looks off or your test fails, go back and adjust until your message looks how you'd like it to.
Build a ChatGPT slash command bot
Now you know how to integrate ChatGPT with Slack so that it replies to particular channel messages, but what if you don't want to limit yourself to just one channel? With a slash command bot, you can send prompts from any channel in your Slack account.
Create your Slack app and set up your webhook trigger
To create a command bot in Slack, you'll need to start by building a Slack app. Don't worry, it's not as intimidating as it sounds. First, go to api.slack.com/apps and click Create an App. Then, give your app a name, and pick the Slack account where you want to use your bot.
Next, add slash commands to your bot by selecting the Slash Commands button, then clicking Create New Command.
From there, choose the word or phrase you want to use as your command. Then, you can add a short description of what the command does, as well as a usage hint that lets people know how to use it.
We still need to add the Request URL, which we'll get from Zapier's webhooks integration.
In a new tab or window, make a new Zap using Webhooks by Zapier as the trigger app and Catch Hook as the trigger event.
Click Continue. Next, your webhook URL will appear. Make sure you copy it.
With that webhook link copied, go back to your Slack slash command's setup page and paste the link into the Request URL field. Then, save your settings and install the app into your Slack workspace.
Now it's time to test your slash command. Zapier will use the information from your test throughout the rest of your Zap. Just open Slack, and type in your command followed by the prompt you'd like to send to ChatGPT.
After that, go back to the Zap editor and click Test Trigger. Zapier will pull in your test prompt from Slack, as well as other information like the channel and username.
Once you see your webhook working correctly, click Continue.
Set up your ChatGPT action
Just like the last Zap we built, it's time to set up our ChatGPT action step. Start by choosing ChatGPT as your trigger app and Conversation with Assistant as your trigger event. Click Continue.
Then, again, you'll connect your OpenAI account with Zapier and click Continue.
Next, it's time to customize how you'll send the prompt to ChatGPT. Since your prompt is just going to be what you typed into Slack, click in the Message field and select Text from the Insert Data dropdown. Then, you'll want to add your existing assistant (that you created in OpenAI) here, too.
Remember to leave the rest of the fields empty (like assistant instructions, model, and files) as these will already have been configured in OpenAI.
Under Tools, you can select Retrieval so the assistant knows to pull from your uploaded files.
You can also include a conversation ID which will allow the assistant to remember a conversation. If left blank, you can still talk to your assistant in Slack, it just won't remember the conversation.
Once you've finished customizing these fields, click Continue.
Next, click Test & Review or Test & Continue.
If everything works smoothly, click the + button below your action step.
Set up your Slack action
Now it's time to set up your Slack action step and customize how your results from ChatGPT look when they make it to Slack.
You'll follow the same steps that we did previously. Pick Slack as your action app and choose Send Channel Message as your action event. Then connect your Slack account with Zapier.
Now, to customize your message. One of the differences between this Zap and the previous one we built is that we want to be able to post ChatGPT results in any channel, not just one specific one.
In the Channel field, rather than specifying one channel, you'll want to pick Channel ID from the Custom tab of the dropdown menu. This will let your Zap know to post your ChatGPT result where your slash command was entered rather than in one specific channel.
After that, you can customize your message, as well as the name and icon of your bot, just like we did in the previous Zap. Once you're done customizing, click Continue.
Finally, it's time to test your action by clicking Test action. Zapier will send a test message to your Slack channel for you to look at. If your message looks good, you're ready to use your Zap. Or you can tinker with it until your message looks just right.
Bring the power of ChatGPT to Slack
We're still in the early days of the AI era, and there's so much to look forward to when thinking about how tools like OpenAI can work with our day-to-day lives. These two automations are just one of seemingly endless ways to use ChatGPT to make work run a little smoother.
This article was originally published in April 2023. It was most recently updated in November 2023 by Elena Alston.