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.