In today’s fast-paced digital world, streamlining workflows and boosting productivity are paramount. That’s why we’re thrilled to share an exciting integration that will take your team’s collaboration to new heights. Get ready to unlock the power of generative artificial intelligence (AI) and bring it directly into your Slack workspace.
Imagine the possibilities: Quick and efficient brainstorming sessions, real-time ideation, and even drafting documents or code snippets—all powered by the latest advancements in AI. Say goodbye to context switching and hello to a streamlined, collaborative experience that will supercharge your team’s productivity. Whether you’re leading a dynamic team, working on complex projects, or simply looking to enhance your Slack experience, this integration is a game-changer.
In this post, we show you how to unlock new levels of efficiency and creativity by bringing the power of generative AI directly into your Slack workspace using Amazon Bedrock.
Solution overview
Amazon Bedrock is a fully managed service that offers a choice of high-performing foundation models (FMs) from leading AI companies like AI21 Labs, Anthropic, Cohere, Meta, Stability AI, and Amazon through a single API, along with a broad set of capabilities to build generative AI applications with security, privacy, and responsible AI.
In the following sections, we guide you through the process of setting up a Slack integration for Amazon Bedrock. We show how to create a Slack application, configure the necessary permissions, and deploy the required resources using AWS CloudFormation.
The following diagram illustrates the solution architecture.
The workflow consists of the following steps:
- The user communicates with the Slack application.
- The Slack application sends the event to Amazon API Gateway, which is used in the event subscription.
- API Gateway forwards the event to an AWS Lambda function.
- The Lambda function invokes Amazon Bedrock with the request, then responds to the user in Slack.
Prerequisites
You need an AWS account and an AWS Identity and Access Management (IAM) role and user with permissions to create and manage the necessary resources and components for this application. If you don’t have an AWS account, see How do I create and activate a new Amazon Web Services account?
You also need an existing account with Amazon Bedrock model access provided. If you don’t have model permission, refer to Model access.
Lastly, you need a Slack account and access to create and publish apps to your Slack organization. If you don’t have one, request your company to create a Slack sandbox organization for you to experiment, or go to Slack to create a free Slack account and workspace.
Create a Slack application
The security configuration varies across organizations. To manage your Slack workspace’s settings, reach out to your Slack administrator or as administrator, complete the following steps:
- Navigate to the admin section within Slack and choose Build.
- Choose Create New App.
- For App Name, enter a name for your app (for this post, we name it
BedrockSlackIntegration
). - Choose your workspace.
- Choose Create App.
After you create the app, you can configure its permissions. - On the app details page, choose Basic Information in the navigation pane.
- Under Add features and functionality, choose Permissions
- In the Scopes section, add the scopes
im:read
,im:write
, andchat:write
.
On the Basic Information page, Bots and Permissions should now both have a green check mark.
- Under Install your app, choose Install to Workspace.
- When prompted to install, choose Allow.
- Open the Amazon Bedrock console and choose Model access in the navigation pane.
- You can select your model from the available list. For this post, we grant access to ai21.j2-ultra-v1 (Jurassic-2 Ultra).For more information about requesting model access, see Model access. Next, we deploy the code and connect with Amazon Bedrock when we get a message from Slack. For that, we need the Slack bot token to use as an input parameter for the CloudFormation template in the next section.
- On the Slack app details page, choose OAuth & Permissions in the navigation pane.
- Copy the value for Bot User OAuth Token.
Deploy resources with AWS CloudFormation
Complete the following steps to launch the CloudFormation stack:
- For Stack name, use default or enter a name of your choice.
- For SlackTokenParam, enter the bot token you copied earlier.
- Choose Next.
- Create your stack and wait a few minutes for deployment to complete.
- On the Outputs tab, copy the value for
SlackBotEndpointOutput
to use in the next steps.
In the next section, we start integrating Amazon Bedrock with Slack.
Integrate Amazon Bedrock with Slack
After you deploy your CloudFormation stack, complete the following steps:
- On the Slack app details page, choose Event Subscriptions in the navigation pane.
- Toggle Enable Events on.
The event subscription should get automatically verified.
- Under Subscribe to bot events, add the events
app_mention
andmessage.im
. - Choose Save Changes.
The integration is now complete.
Test the Slack bot
To test your bot, complete the following steps:
- Navigate to your Slack.
- Create a new group and add the app
BedrockSlackIntegration
. - Start interacting with the Amazon Bedrock bot using
@BedrockSlackIntegration.
Your interaction will look like the following screenshot.
The bot demonstrated here doesn’t have the state of your previous questions or your chat history with new subsequent messages. However, you can implement this using Amazon DynamoDB. We will cover this in a later blog post.
Summary
In this post, we delved into the seamless integration of Amazon Bedrock with the popular collaboration platform, Slack. The step-by-step guide demonstrated how to establish a direct connection between these two powerful tools, enabling you and your team to harness the full potential of generative AI directly within your Slack workspace. With this integration, you can streamline your workflow and enhance productivity, making it effortless to tap into the cutting-edge capabilities of generative AI. Whether you’re seeking to generate content, analyze data, or explore innovative ideas, this integration empowers you to do it all without leaving the familiar Slack environment.
You can further empower your team by deploying a Slack gateway for Amazon Q Business, the generative AI assistant that empowers employees based on knowledge and data in your enterprise systems. To learn more about how to use generative AI with AWS services, see Generative AI on AWS.
About the Authors
Rushabh Lokhande is a Senior Data & ML Engineer with AWS Professional Services Analytics Practice. He helps customers implement big data, machine learning, analytics solutions, and generative AI solutions. Outside of work, he enjoys spending time with family, reading, running, and playing golf.
Andrew Ang is a Senior ML Engineer with the AWS Generative AI Innovation Center, where he helps customers ideate and implement generative AI proof of concept projects. Outside of work, he enjoys playing squash and watching travel and food vlogs.
John Losito is an Associate Cloud Infrastructure Architect with AWS Professional Services, where he helps customers craft automation scripts using the AWS CDK or Terraform to efficiently deploy and managed cloud resources. Outside of work, he enjoys spending time with his family, exercising, and improving his archery skills.