Component Libraries •
Project Templates
Docs •
Install •
Tutorials •
Developer Guides •
Contribute •
Blog •
Discord
Xircuits Component Library to interface with Slack! Create Slack Bots in seconds.
Welcome to the xai-slack component library for building Slack bots! This library provides a simple way to create and manage custom Slack components bots in your workspace. In this README, you'll find the steps to set up a Slack application and start using the xai-slack library.
- Table of Contents
- Prerequisites
- Setting Up a Slack Application
- Installation
- Getting Started with Xai-Slack
- Try the Examples
Before you begin, you will need the following:
- A Slack workspace.
- Python3.8+.
- Xircuits.
- Go to the Slack API page and click "Create New App."
- Choose "From scratch" and provide a name for your app (e.g., "Xai-Slack Bot").
- Select the workspace where you want the app to be developed.
- Click "Create App."
-
Navigate to the OAuth & Permissions on the left sidebar and scroll down to the Bot Token Scopes section. Click Add an OAuth Scope.
-
add the following scopes to your app:
app_mentions:read
(To read app mentions)channels:history
(To read messages in public channels)groups:history
(To read messages in private groups)files:read
(To read file information)chat:write
(To send messages in channels)- Note: this scopes are to enable all the components. For selective components usage you can check the required scopes and events subscriptions stated each component documentation.
-
Scroll up to the top of the OAuth & Permissions page and click Install App to Workspace. You’ll be led through Slack’s OAuth UI, where you should allow your app to be installed to your development workspace.
-
Once you authorize the installation, you’ll land on the OAuth & Permissions page and see a Bot User OAuth Access Token save the generated
xoxb-
token to be used asSLACK_BOT_TOKEN
later. -
Then head over to Basic Information and scroll down under the App Token section and click Generate Token and Scopes to generate an app-level token. Add the
connections:write
scope to this token and save the generatedxapp
token to be used asSLACK_APP_TOKEN
later. -
Navigate to Socket Mode on the left side menu and toggle to enable.
-
In your Slack app settings, navigate to "Event Subscriptions" on the left side menu and toggle to enable, scroll down and click Subscribe to bot events.
-
subscribe your app to the following events:
app_mention
file_shared
message.channels
message.im
- Note: this Subscriptions are to enable all the components. For selective components usage you can check the required scopes and events subscriptions stated each component documentation.
-
Create a
.env
file and add bothSLACK_APP_TOKEN
andSLACK_BOT_TOKEN
, or you can provide these values directly to the components later on.
- Log in to your Slack workspace using the web, desktop, or mobile app.
- Invite the bot to a channel by sending /invite @YourBotName (replace "YourBotName" with the actual name of your bot) as a message in the channel.
To use this component library, ensure that you have an existing Xircuits setup. You can then install the Slack library using the component library interface, or through the CLI using:
xircuits install slack
You can also do it manually by cloning and installing it.
# base Xircuits directory
git clone https://github.com/XpressAI/xai-slack xai_components/xai_slack
pip install -r xai_components/xai_slack/requirements.txt
Now that your Slack app is set up and configured, you can begin using the xai-slack component library to build custom components for your workspace. Please follow the documentation and examples provided in the library to learn how to create, customize, and manage Slack components using xai-slack.
We have provided several example workflows to help you get started with the xai-slack component library. Give them a try and see how you can create custom Slack components for your workspace.
Check out the msg_trigger.xircuits
workflow. This example listens for keywords in conversations and responds when a trigger message is detected.
Explore the image_prediction.xircuits
workflow. In this example, the bot watches for attached images in conversations and responds with the predicted class when a trigger message is detected.
Take a look at the slack_openai.xircuits
workflow. This example leverages components from the OpenAI Component Library. The bot enables each Slack thread to have unique and contextual image creation and editing using the OpenAI models.
These examples are designed to help you understand how to use the xai-slack component library effectively in your Slack workspace. Enjoy creating and customizing your components!