Unlock the knowledge in your Slack workspace with Slack connector for Amazon Q Business
In this post, we will demonstrate how to set up Slack connector for Amazon Q Business to sync communications from both public and private channels, reflective of user permissions.
Amazon Q Business is a fully managed, generative AI-powered assistant that you can configure to answer questions, provide summaries, generate content, and complete tasks based on your enterprise data. Amazon Q Business offers over 40 built-in connectors to popular enterprise applications and document repositories, including Amazon Simple Storage Service (Amazon S3), Salesforce, Google Drive, Microsoft 365, ServiceNow, Gmail, Slack, Atlassian, and Zendesk and can help you create your generative AI solution with minimal configuration.
Nearly 100 thousand organizations use Slack to bring the right people together to securely collaborate with each other. A Slack workspace captures invaluable organizational knowledge in the form of the information that flows through it as the users communicate on it. Hence, it is valuable to make this knowledge quickly and securely available to the users.
In this post, we will demonstrate how to set up Slack connector for Amazon Q Business to sync communications from both public and private channels, reflective of user permissions. We will also guide you through the configurations needed on your Slack workspace. Additionally, you will learn how to configure the Amazon Q Business application and enable user authentication through AWS IAM Identity Center, which is a recommended service for managing a workforce’s access to AWS applications.
Data source overview
Amazon Q Business uses large language models (LLMs) to build a unified solution that connects multiple data sources. Typically, you’d need to use a natural language processing (NLP) technique called Retrieval Augmented Generation (RAG) for this. With RAG, generative AI enhances its responses by incorporating relevant information retrieved from a curated dataset. Amazon Q Business has a built-in managed RAG capability designed to reduce the undifferentiated heavy lifting involved in creating these systems. Typical of a RAG model, Amazon Q Business has two components: A retrieval component that retrieves relevant documents for the user query and a generation component that takes the query and the retrieved documents and then generates an answer to the query using an LLM.
A Slack workspace has multiple elements. It has public channels where workspace users can participate and private channels where only channel members can communicate with each other. Individuals can also directly communicate with each other in one-on-one conversations and in user groups. This communication is in the form of messages and threads of replies, with optional document attachments. Slack workspaces of active organizations are highly dynamic, with the content and collaboration evolving and growing in volume continuously.
The preceding figure shows the process flow of the solution. When you connect Amazon Q Business to a data source (in this case, Slack), what Amazon Q considers and crawls as a document varies by connector. For the Amazon Q Business Slack connector, each message, message attachment and channel post is considered a single document, However, Slack conversation threads that help you create organized discussions around specific messages are also considered and ingested as a single document, regardless of the number of participants or messages they contain.
Amazon Q Business crawls access control list (ACL) information attached to a document (user and group information) from your Slack instance. This information can be used to filter chat responses to the user’s document access level. The Slack connector supports token-based authentication. This could be a Slack bot user OAuth token or Slack user OAuth token. See the Slack connector overview to get the list of entities that are extracted, supported filters, sync modes, and file types.
User IDs (_user_id
) exist in Slack on messages and channels where there are set access permissions. They are mapped from the user emails as the IDs in Slack.
To connect your data source connector to Amazon Q Business, you must give Amazon Q Business an IAM role that has the following permissions:
- Permission to access the
BatchPutDocument
andBatchDeleteDocument
operations to ingest documents. - Permission to access the User Store API operations to ingest user and group access control information from documents.
- Permission to access your AWS Secrets Manager secret to authenticate your data source connector instance.
- (Optional) If you’re using Amazon Virtual Private Cloud (Amazon VPC), permission to access your Amazon VPC.
Solution overview
In this solution, we will show you how to create a Slack workspace with users who perform various roles within the organization. We will then show you how to configure this workspace to define a set of scopes that are required by the Amazon Q Business Slack connector to index the user communication. This will be followed by the configuration of the Amazon Q Business application and a Slack data source. Based on the configuration, when the data source is synchronized, the connector either crawls and indexes the content from the workspace that was created on or before a specific date. The connector also collects and ingests ACL information for each indexed message and document. Thus, the search results of a query made by a user includes results only from those documents that the user is authorized to read.
Prerequisites
To build the Amazon Q Business connector for Slack, you need the following:
In Slack:
- Create a Slack bot user OAuth token or Slack user OAuth token. You can choose either token to connect Amazon Q Business to your Slack data source. See the Slack documentation on access tokens for more information.
- Note your Slack workspace team ID from your Slack workspace main page URL. For example,
https://app.slack.com/client/T0123456789/...
whereT0123456789
is the team ID. - Add the OAuth scopes and read permissions.
In your AWS account:
- Create an AWS Identity and Access Management (IAM) role for your data source and, if using the Amazon Q Business API, note the ARN of the IAM role.
- Store your Slack authentication credentials in an AWS Secrets Manager secret and, if using the Amazon Q Business API, note the ARN of the secret.
- Enable and configure an IAM Identity Center instance. Amazon Q Business integrates with IAM Identity Center as a gateway to manage user access to your Amazon Q Business application. We recommend enabling and pre-configuring an Identity Center instance before you begin to create your Amazon Q Business application. Identity Center is the recommended AWS service for managing human user access to AWS resources. Amazon Q Business supports both organization and account level Identity Center instances. See Setting up for Amazon Q Business for more information.
Configure your Slack workspace
You will create one user for each of the following roles: Administrator, Data scientist, Database administrator, Solutions architect and Generic.
User name | Role |
arnav_desai | Admin |
jane_doe | Data Scientist |
pat_candella | DB Admin |
mary_major | Solutions Architect |
john_stiles | Generic User |
To showcase the ACL propagation, you will create three public channels, #general
, #customerwork
, and #random
, that any member can access including the Generic user. Also, one private channel, #anydepartment-project-private
, that can be accessed only by the users arnav_desai
, john_stiles
, mary_major
, and pat_candella
.
To create a Slack app:
- Navigate to the Slack API Your Apps page and choose Create New App.
- Select From scratch. In the next screen, select the workspace to develop your app, and then choose Create an App.
- Give the Slack app a name and select a workspace to develop your app in. Then choose Create App.
- After you’ve created your app, select it and navigate to Features and choose OAuth & Permissions.
- Scroll down to Scopes > User Token Scopes and set the OAuth scope based on the user token scopes in Prerequisites for connecting Amazon Q Business to Slack.
Note: You can configure two types of scopes in a Slack workspace:
- Bot token scope: Only the messages to which it has been explicitly added are crawled by the bot token. It is employed to grant restricted access to specific messages only.
- User token scope: Only the data shared with the member is accessible to the user token, which acts as a representative of a Slack user.
For this example, so you can search on the conversations between users, you will use the user token scope.
- After the OAuth scope for yser token has been set up as described in the Slack prerequisites, scroll up to the section OAuth Tokens for your Workspace, and choose Install to Workspace, and then choose Allow.
- This will generate a user OAuth token. Copy this token to use when configuring the Amazon Q Business Slack connector.
Configure the data source using the Amazon Q Business Slack connector
In this section, you will create an Amazon Q Business application using the console.
To create an Amazon Q Business application
- In the AWS Management Console for Amazon Q Business, choose Create Application.
- Enter an Application Name, such as
my-slack-workspace
. Leave the Service access as the default value, and select AWS IAM Identity Center for Access Management . Enter a new Tag value as required and choose Create to the Amazon Q Business Application.
- Leave the default option of Use Native retriever selected for Retrievers, leave Enterprise as the Index provisioning and leave the default value of 1 as the Number of units. Each unit in Amazon Q Business index is 20,000 documents or 200 MB of extracted text (whichever comes first). Choose Next.
- Scroll down the list of available connectors and select Slack and then choose Next.
- Enter a Data source name and a Description to identify your data source and then enter the Slack workspace team ID to connect with Amazon Q Business.
- In the Authentication section, select Create and add a new secret.
- On the dialog box that appears, enter a Secret name followed by the User OAuth Slack token that was copied from the Slack workspace.
- For the IAM role, select Create a new service role (Recommended).
- In Sync scope, choose the following:
- For select type of content to crawl, select All channels.
- Select an appropriate date for Select crawl start date.
- Leave the default value selected for Maximum file size as 50.
- You can include specific Messages, such as bot messages or archived messages to sync.
- Additionally, you can include up to 100 patterns to include or exclude filenames, types, or file paths to sync.
- For Sync mode, leave Full sync selected and for the Sync run schedule, select Run on demand.
- Leave the field mapping as is and choose Add data source.
- On the next page, choose Next.
- Enter a Data source name and a Description to identify your data source and then enter the Slack workspace team ID to connect with Amazon Q Business.
- Add the five users you created earlier, who are a part of IAM Identity Center and the Slack workspace to the Amazon Q Business application. To add users to Identity Center, follow the instructions in Add users to your Identity Center directory. When done, choose Add groups and users and choose Assign.
- When a user is added, each user is assigned the default Q Business Pro For more information on different pricing tiers, see the Amazon Q Business pricing page.
- Choose Create application to finish creating the Amazon Q Business application.
- After the application and the data source are created, select the data source and then choose Sync now to start syncing documents from your data source.
- The sync process ingests the documents from your Slack workspace to your selections in the Slack connector configuration in Amazon Q Business. The following screenshot shows the results of a successful sync, indicated by the status of Completed.
Search with Amazon Q Business
Now, you’re ready to make a few queries in Amazon Q Business.
To search using Amazon Q Business:
- Navigate to the Web experience settings tab and click on the Deployed URL.
- For this demonstration, sign in as pat_candella who has the role of DB Admin.
- Enter the password for pat_candella and choose Sign in
- Upon successful sign-in, you will be signed in to Amazon Q Business.
- In the Slack workspace, there is a public channel, the #customerwork channel that all users are members of. The
#customerwork
Slack channel is being used to communicate about an upcoming customer engagement, as shown in the following figure.
- Post the first question to Amazon Q Business.
Note that the response includes citations that refer to the conversation as well as the content of the PDF that was attached to the conversation.
Security and privacy options with Slack data connector
Next, you will create a private channel called #anydepartment-project-private with four out of the five users—arnav_desai
, john_stiles
, mary_major
and pat_candella
—and verify that the messages exchanged in a private channel are not available to non-members like jane_doe
. Note that after you create a new private channel, you need to manually re-run the sync on the data source.
The below screenshot shows the private slack channel with four out of five users and the slack conversation.
Testing security and privacy options with Slack data connector
- While signed in as pat_candella, who is part of the private #anydepartment-project-private channel, execute the following query:
- Now, sign in as jane_doe, who is not a member of the #anydepartment-project-private channel and execute the same query.
- Amazon Q Business prevents jane_doe from getting insights from information within the private channels that they aren’t part of, based on the synced ACL information.
Indexing aggregated Slack threads
Slack organizes conversations into threads, which can involve multiple users and messages. The Amazon Q Business Slack connector treats each thread as a single document, regardless of the number of participants or messages it contains. This approach allows Amazon Q Business to ingest entire conversation threads as individual units, maximizing the amount of data that can be processed within a single index unit. As a result, you can efficiently incorporate more comprehensive conversational context into your Amazon Q Business system.
The figure that follows shows a conversation between pat_candella
and jane_doe
that includes six messages in a thread. The Slack connector aggregates this message thread as a single message, thus maximizing the use of an index unit.
Because the conversation thread is aggregated as a single document within the Amazon Q Business index, you can ask questions that pertain to a single conversation thread as shown in the following figure.
Troubleshooting the sync process
- Why isn’t Amazon Q Business answering any of my questions?
If you aren’t getting answers to your questions from Amazon Q Business, verify the following:
- Permissions – Document ACLs indexed by Amazon Q Business may not allow you to query certain data entities as demonstrated in our example. If this is the case, please reach out to your Slack workspace administrator to make sure that your user has access to required documents and repeat the sync process.
- Data connector sync – A failed data source sync may prevent the documents from being indexed, meaning that Amazon Q Business would be unable to answer questions about the documents that failed to sync. Please refer to the official documentation to troubleshoot data source connectors.
- I’m receiving access errors on Amazon Q Business application. What causes this?
See Troubleshooting Amazon Q Business identity and access to diagnose and fix common issues that you might encounter when working with Amazon Q and IAM.
- How can I sync documents without ACLs?
Amazon Q Business supports crawling ACLs for document security by default. Turning off ACLs and identity crawling are no longer supported. If you want to index documents without ACLs, ensure that the documents are marked as public in your data source. Please refer to the official documentation, How Amazon Q Business connector for crawls Slack ACLs.
- My connector is unable to sync. How can I monitor data source sync progress?
Amazon Q Business provides visibility into the data sync operations. Learn more about this feature in the AWS Machine Learning blog.
Additionally, as the sync process runs, you can monitor progress or debug failures by monitoring the Amazon CloudWatch logs that can be accessed from the Details section of the Sync run history.
A sample query to determine which documents or messages were indexed from a specific slack channel, C12AB34578
, and logStream
of SYNC_RUN_HISTORY_REPORT/xxxxxxxxxxxxxxxxxxxxxxxx
would look like the following:
Choosing Run query displays the list of messages as the Amazon Q Business Index sync runs, as shown in the following figure.
Cleanup
To delete an Amazon Q Business application, you can use the console or the DeleteApplication API operation.
To delete an Amazon Q Business application using the console
- Sign in to the Amazon Q Business console.
- Select the respective the Amazon Q Business Application and choose
- Choose Delete
- In the dialog box that opens, enter
Delete
to confirm deletion, and then choose Delete. - You are returned to the service console while your application is deleted. When the deletion process is complete, the console displays a message confirming successful deletion.
To delete the IAM Identity Center instance, see Delete your IAM Identity Center instance.
Conclusion
This blog post provides a step-by-step guide on setting up the Slack connector for Amazon Q Business, enabling you to seamlessly integrate data from your Slack workspace. Moreover, we highlighted the importance of data privacy and security, demonstrating how the connector adheres to the ACLs within your Slack workspace. This feature helps ensure that private channel conversations remain confidential and inaccessible to individuals who aren’t members of those channels. By following these steps and understanding the built-in security measures, you can use the power of Amazon Q Business while maintaining the integrity and privacy of your Slack workspace.
To learn more about the Amazon Q Business connector for Slack, see Connecting Slack to Amazon Q Business. You can automate all the showcased console operations through Amazon Q Business API’s, the AWS CLI and other applicable AWS SDKs.
If you choose to converse with Amazon Q Business using Slack direct messages (DMs) to ask questions and get answers based on company data or to get help creating new content such as email drafts, summarize attached files, and perform tasks, see Deploy a Slack gateway for Amazon Q, your business expert for information about how to bring Amazon Q, your business expert, to users in Slack.
About the Authors
Akshara Shah is a Senior Solutions Architect at Amazon Web Services. She provides strategic technical guidance to help customers design and build cloud solutions. She is currently focused on machine learning and AI technologies.
Roshan Thomas is a Senior Solutions Architect at Amazon Web Services. He is based in Melbourne, Australia and works closely with enterprise customers to accelerate their journey in the cloud. He is passionate about technology and helping customers architect and build solutions on AWS.