Skip to content

Commit 800c0e2

Browse files
authored
Merge pull request #7 from KyMidd/feature/receiver-pattern
Receiver pattern
2 parents 3eb9510 + d47df18 commit 800c0e2

File tree

6 files changed

+372
-229
lines changed

6 files changed

+372
-229
lines changed

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,14 @@ This code is discussed at length on LetsDoDevOps.com, you can find the articles
1010
- Part 5: [Building a RAG Knowledge Base of an entire Confluence wiki, and teaching our Slack Bot to Read it in Real-Time](https://www.letsdodevops.com/p/building-a-slack-bot-with-ai-capabilities)
1111
- Part 6: [Adding support for DOC/X, XLS/X, PDF, and More to Chat with your Data](https://www.letsdodevops.com/p/building-a-slack-bot-with-ai-capabilities-bdf)
1212
- Part 7: [Streaming Token Responses from AWS Bedrock to Slack using converse_stream()](https://www.letsdodevops.com/p/building-a-slack-bot-with-ai-capabilities-d2d)
13+
- Part 8: [ReRanking knowledge base responses to improve AI model response efficacy](https://www.letsdodevops.com/p/slack-ai-reranking)
14+
- Part 9: [Reducing Cost and Complexity with a Lambda Receiver Pattern](https://www.letsdodevops.com/p/building-a-slack-bot-receiver)
1315

1416
# Architecture
1517

16-
Requests are relayed from the Slack App to a private Lambda URL, which spins up quite quickly. It fetches the necessary secrets from secrets manager (authentication is via IAM role) to enable the slack app for decoding the requests, then extracts both the request, and if applicable, the slack thread, which is all encoded into the request to the AI in Bedrock. The response is relayed and posted to the thread.
18+
Requests are relayed from the Slack App to a private Lambda URL which is attached to a "receiver" lambda. This spins up quickly, and validates the message. This message is forwarded to the Vera bot, which does the actual work, and responds to Slack that the message has been received.
19+
20+
The Vera bot is triggered by the Receiver lambda. It fetches the necessary secrets from secrets manager (authentication is via IAM role) to enable the slack app for decoding the requests, then extracts both the request, and if applicable, the slack thread, which is all encoded into the request to the AI in Bedrock. The response is relayed and posted to the thread.
1721

1822
Slack User tags Bot in shared thread (bot must be invited) or DMs Bot --> Slack App sees trigger, sends webhook to Lambda URL --> Lambda reads package and extracts message and thread context, constructs AI request --> AI request to Bedrock, Bedrock creates response --> Lambda relays response back to Slack App --> Slack App posts to Slack within thread.
1923

@@ -41,9 +45,15 @@ Lambda can spin up hundreds of concurrencies without much effort, so monitoring
4145

4246
# Cost
4347

44-
Assuming 100 requests per week (will depend on your biz size, use) that take ~10 seconds total (assuming on the high end)
48+
Assuming 100 requests per week (will depend on your biz size, use) that take ~5-10 seconds total (assuming on the high end)
4549
Lambda cost: $0.03 / month
4650

4751
AI cost (depends on request complexity), assuming 1k tokens per request: $3.20/month
4852

49-
Bedrock Knowledge Bases are expensive. Though they're "serverless", they don't spin down to $0. Instead, they spin down to about ~$60/day, or about $1.8k/month. That's a lot! You can work with AWS Support to turn off "vector preload" setting on the OpenSearch serverless instances, which brings the cost down significantly - to around $35/day, or just over $1k/month. That's still a lot, but way more reasonable than $25k/yr.
53+
Total without a knowledge base: $3.23/month for ~100 requests of moderate complexity.
54+
55+
Bedrock Knowledge Bases are expensive. Though they're "serverless", they don't spin down to $0. Instead, they spin down to about ~$60/day, or about $1.8k/month. That's a lot! You can work with AWS Support to turn off "vector preload" setting on the OpenSearch serverless instances, which brings the cost down significantly - to around $35/day, or just over $1k/month. That's still a lot, but way more reasonable than $25k/yr.
56+
57+
Knowledge bases can contain lots of different "data sources" that they read and synchronize with, so you can scale out more data without accruing more cost.
58+
59+
Total with a single confluence knowledge base: ~1.1k/month.

0 commit comments

Comments
 (0)