This application is an AI-powered chatbot designed to help users navigate and utilize the Spack package manager tool. This innovative chatbot that employs Retrieval-Augmented Generation (RAG) technology to provide responses to user queries and can be interacted with both in Slack and Amazon Q. This solution can be applied to a variety of use cases that require knowledge integration to a chatbot. The two main selling points of this solution is: (1) having the ability to interact with the chatbot in two mediums and (2) being able to show sources in websites and documents in an S3 bucket via CloudFront.
- Slackbot and Amazon Q both share the same vector database reducing solution complexity and cost.
- Both Slackbot and Amazon Q bot provides clickable links to its sources for generating answers in their responses:
- https://spack-tutorial.readthedocs.io/en/latest/index.html
- Text files (
docuemnts/slack/*.txt) uploaded to S3 bucket via CloudFront distribution
- Automated updates of both data sources.
- Dashboard for tracking bot invocations for Slack and Amazon Q:
- Aws Console -> Amazon Q Business -> Radiuss -> Analytics dashboard
- Aws Console -> Cloudformation -> Stacks -> SlackStack -> Outputs -> AmazonQCloudwatchDashboardOutput
-
Data Stack:
- A) Documentation Data
Documentation Processing Lambdapulls in data fromRaw Documentation Bucketand does the following:- Converts
.rstfiles into markdown. - Splits the markdown text based on its title
- Generates metadata files that will be used by kendra. The metadata files contains the following attributes:
- title: section title from data split
- data_source:
documentation - _source_uri: URL from the documentation which is
https://spack.readthedocs.io/en/latest/+ file name + "#" + section title
- Converts
Documentation Processing Lambdasaves the split markdown and the metadata files intoProcessed Documentation Bucket.Documentation Processing Lambdatriggers a kendra data source sync job to crawl theProcessed Documentation Bucket.
- B) Slack Data
Slack Processing Lambda:
Slack Processing Lambdapulls in data fromRaw Slack Bucketwhich contains historical Slack data and does the following:- Generates metadata files that will be used by kendra. The metadata files contains the following attributes:
- title: section title from data split
- data_source:
slack - _source_uri: generated CloudFront URL from the
Raw Slack Bucket
- Generates metadata files that will be used by kendra. The metadata files contains the following attributes:
Slack Processing Lambdasaves historical slack data and the metadata files intoProcessed Slack Bucket.Slack Processing Lambdatriggers a kendra data source sync job to crawl theProcessed Slack Bucket.Raw Slack Bucketdata is passed into a CloudFront distribution for public access. Slack Ingest Lambda:Slack Ingest Lambdais triggered by event bridge daily.Slack Ingest Lambdapulls in the past 24 hours conversation from slackdata from slack and writes it to Raw slack dataSlack Ingest Lambdasaves conversation data intoProcessed Slack Buckettogether with its metadata.Slack Processing Lambdatriggers a kendra data source sync job to crawl theProcessed Slack Bucket.Processed Slack Bucketdata is passed into a CloudFront distribution for public access.
- A) Documentation Data
-
Amazon Q Stack: Amazon Q Business is a fully managed, generative-AI powered assistant tailored for this use case to answer questions based on the data from the data stack.
Identity Center- Provides authentication to Amazon Q.Kendraprovides context to the responses via semantic search and sources.Cloudfrontlinks are provided by kendra and propagates to the responses of Amazon Q.Public Docslinks are provided by kendra and propagates to the responses of Amazon Q.- Invocations are logged in a
CloudwatchDashboard.
- Slack
- A) Answering Questions
- Slack app invokes
API Gatewaywith the question as a part of the payload. API GatewayinvokesSlackbot Lambda.Slackbot Lambdapulls Slack token fromSecrets Manager.Slackbot Lambdapulls Slack parameters for responses fromSSM Parameter Store.Kendrais queried with the question and responds with relevant passages and sources from documentation and slack data fromCloudfront.- Public docs are returned as part of the response if the chatbot used it as a source.
- Slack data via
Cloudfrontare returned as part of the response if the chatbot used it as a source.
- Slack app invokes
- B) Reporting
0.
Metrics Lambdais triggered every day at 0:00 UTC- Everytime the
Slackbot Lambdais triggered it is captured inCloudwatchas a metric. Metrics Lambdapulls daily data fromCloudwatchMetrics Lambdapulls Slack token fromSecrets ManagerMetrics Lambdapulls slack parameters for responses fromSSM Parameter StoreMetrics Lambdasend message on slack with daily report
- Everytime the
- A) Answering Questions
- Active AWS account
- Docker
- AWS CLI
- Slack workspace
Parent Channel: Public Slack Channel where users will be interacting with the slack chatbot.Child Channel: Private Slack Channel where metrics report will be sent to.
- If building from an arm based machine (Apple M series) change the parameter for
architecutreindocumentation_processing_lambdainstacks/data.pytolambda_.Architecture.ARM_64.
- Ensure Bedrock model access for
anthropic.claude-v2:1 - Enable IAM identify Center for your account.
pip install -r requirements.txtcdk bootstrapcdk synthcdk deploy --all- Create a Slack app:
- Go to: https://api.slack.com/apps
- Select
Create an App - Select
From a manifest- Select
Spackworkspace - Select
YAMLtab and copy the contents of the app manifest and selectNext - Select
Create
- Select
- Install App
- On the left pane, under settings select
Install App - Select
Install to <workspace> - Select
Allow
- Copy Bot User OAuth Token
- Go to: AWS Console -> AWS Secrets Manager -> Secrets -> SlackAccessKey### -> Overview -> Retrieve Secret Value -> Edit
- Paste value where it says
place-holder-access-key - Click
Save
- Enter endpoint (One app is finished deploying from Step 1)
- Got to: AWS Console -> Cloudformation -> Stacks -> SlackStack -> Outputs -> SlackBotEndpointOutput (copy Value)
- Enable events
- Paste value under
Request URL
- On the bottom right of the screen select
Save Changes
- Invite bot to channels (Parent and Child):
- Select the channel
- On the upper right next to huddle click on the three dots.
- Select
edit settings - Go to
integrationstab - Select
Add an app - Under the
In your workspacetab select add the chatbot
- Enter Slack workspace information:
Obtain the following information from slack:
- Parent channel ID
- Child channel ID
Note: To obtain channel id, right-click the channel -> View Channel Details -> About -> Copy channel ID
- Slackbot member ID: Under apps -> right-click the bot -> view app details -> Copy Member ID. If Slack bot is not under apps, click
Add appsand select the slackbot.
Enter above information into AWS:
- Got to: AWS Console -> Systems Manager -> Application Management -> Parameter Store -> My parameters
- Select
/Radiuss/Spack/ChildChannelIdand edit. Enter the child channel id as the value and selectsave changes - Select
/Radiuss/Spack/ParentChannelIdand edit. Enter the parent channel id as the value and selectsave changes - Select
/Radiuss/Spack/SlackbotMemberIdand edit. Enter the Slackbot member id as the value and selectsave changes
Security: It is highly recommended that the user change the slack token periodically.
- Go to AWS Console -> Amazon Q Business -> Applications -> Radiuss -> User Access -> Manage user access
- Select
Add groups and users - Select
Add and assign new users - Select
Next - Enter information
- Select
Next - Select
Add
- Go to AWS Console -> Amazon Q Business -> Applications -> Radiuss -> User Access -> Manage user access
- Select user via radio button
- Select
Edit subscription - Select
Choose subscriptionfrom dropdown Subscription tiers are available in this link
Amazon Q: AWS Console -> Amazon Q Business -> Applications -> Radiuss -> Web experience settings -> Deployed URLSlack: Workspace -> Designated Channel -> Send a single message that starts with @SpackChatbot
cdk destroy --all- Nick Biso, Machine Learning Engineer - Amazon Web Services Inc.
- Ian Lunsford, Aerospace Cloud Consultant - Amazon Web Services Inc.
- Natasha Tchir, Machine Learning Engineer - Amazon Web Services Inc.
- Katherine Feng, Machine Learning Engineer - Amazon Web Services Inc.
See CONTRIBUTING for more information.
This library is licensed under the MIT-0 License. See the LICENSE file.



