RAG-Powered Terraform Support Slackbot

benchling · Tech · 2024 · source Agentic: no · promotional bias: low · summary-only (no fetched source) · extracted with prompt 0.5.6 (schema v2)

Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.

Problem

Domain: Internal infrastructure support and Terraform Cloud knowledge access

Benchling engineers needed a faster way to answer Terraform Cloud questions without manually searching a 20-page FAQ and scattered Slack threads while managing a large multi-datacenter Terraform estate.

Constraints:

Architecture

Benchling built a Terraform support Slackbot using a Slack App, API Gateway, a Python AWS Lambda, Amazon Bedrock knowledge bases, Claude 3.5 Sonnet v2 for response generation, Titan Text Embeddings v2 for embeddings, and OpenSearch Serverless for vector storage. Documentation from Confluence, Hashicorp public docs, and manually copied Slack threads is stored in S3 and ingested into the Bedrock knowledge base. The Lambda handles Slack requests, retrieves credentials from AWS Secrets Manager, calls Bedrock RetrieveAndGenerate/Retrieve APIs, and returns answers in Slack.

Diagram confidence: reconstructed (reconstructed from prose).

flowchart LR
  A["Slack App"] --> B["AWS API Gateway"]
  B --> C["AWS Lambda"]
  C --> D["AWS Secrets Manager"]
  C --> E["Amazon Bedrock"]
  E --> F["Titan Text Embeddings v2"]
  F --> H["OpenSearch Serverless"]
  E --> G["Claude 3.5 Sonnet v2"]
  I["S3 knowledge sources"] --> E
  E --> H
  C --> J["CloudWatch logs"]
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
Slack App Engineer-facing interface for Terraform Cloud questions. AWS API Gateway
AWS API Gateway Receives Slack webhook requests and routes them to Lambda. Slack App, AWS Lambda
AWS Lambda Stateless Python 3.12 function that handles requests, secrets, and Bedrock calls. AWS API Gateway, AWS Secrets Manager, Amazon Bedrock, CloudWatch logs
AWS Secrets Manager Stores Slack credentials used by the Lambda function. AWS Lambda
Amazon Bedrock RAG orchestration layer and managed model access point. AWS Lambda, Titan Text Embeddings v2, Claude 3.5 Sonnet v2, OpenSearch Serverless, S3 knowledge sources
Titan Text Embeddings v2 Embedding model for documents and queries. Amazon Bedrock, OpenSearch Serverless
Claude 3.5 Sonnet v2 Generation model for Slackbot answers. Amazon Bedrock
OpenSearch Serverless Vector database created by the Bedrock knowledge base setup. Amazon Bedrock, Titan Text Embeddings v2
S3 knowledge sources Storage for exported Confluence PDFs, crawled docs, and manually captured Slack threads. Amazon Bedrock
CloudWatch logs Operational logging retained for troubleshooting. AWS Lambda

Data flow

Terraform support documents and selected Slack-thread histories are stored for Bedrock ingestion, embedded with Titan Text Embeddings v2, and indexed in OpenSearch Serverless. A Slack user asks a Terraform Cloud question, API Gateway forwards the webhook to Lambda, Lambda retrieves secrets and calls Bedrock RetrieveAndGenerate or Retrieve, Claude 3.5 Sonnet v2 generates the response over retrieved context, and the answer returns to Slack.

3 supporting quotes
“The core components include a Slack App as the user interface, AWS API Gateway to handle incoming webhook requests, AWS Lambda running a stateless Python 3.12 function”summary, stated
“Amazon Titan Text Embeddings v2 handles the embedding of documents and queries into vector representations, while Claude 3.5 Sonnet v2”summary, stated
“The function retrieves Slack credentials from AWS Secrets Manager and communicates with Bedrock using the RetrieveAndGenerate and Retrieve API actions.”summary, stated

Why this architecture

Benchling chose a small managed-services RAG architecture because the problem was scoped internal knowledge lookup, not broad infrastructure automation. AWS Bedrock reduced infrastructure setup, Slack met engineers where they already worked, and a tightly scoped Terraform dataset reduced hallucination risk while making the prototype reusable for future internal help bots.

3 supporting quotes
“The architecture is intentionally simple and leverages AWS managed services to minimize operational overhead.”summary, stated
“Amazon Bedrock's knowledge base setup wizard automates much of the infrastructure provisioning”summary, stated
“using more tightly-scoped datasets reduces hallucination risk and improves the relevance of vector database results.”summary, stated

Models used: Claude 3.5 Sonnet v2 · Amazon Titan Text Embeddings v2 · Amazon Bedrock Knowledge Bases

Scale

Alternatives considered (roads not taken)

Continue manual search across a FAQ and Slack threads

Rejected because: Knowledge was scattered and difficult for engineers to find quickly.

“knowledge was scattered across a 20-page Confluence FAQ and numerous Slack threads, making it difficult and time-consuming for engineers to find answers”summary, stated

Use Bedrock default 300-token chunking

Rejected because: FAQ answers spanned multiple paragraphs, so default chunks cut off answers midstream.

“initially used Bedrock's default chunking of 300 tokens (approximately one paragraph), which led to substandard results because their FAQ answers often span multiple paragraphs”summary, stated

Manage Bedrock knowledge base infrastructure entirely in Terraform

Rejected because: The AWS Terraform provider did not yet support the Bedrock knowledge base resources.

“the AWS Terraform provider doesn't support the Bedrock knowledge base resources they used, forcing manual creation through the AWS console.”summary, stated

Patterns

rag-retrieval (retrieval)

The Slackbot retrieves Terraform support context from a Bedrock knowledge base before Claude generates answers.

“The team built a RAG (Retrieval-Augmented Generation) powered Slackbot that allows engineers to ask natural language questions and receive contextual answers”summary, stated

retrieval-ranking (retrieval)

OpenSearch Serverless stores vector embeddings used by Bedrock retrieval.

“The core components include a Slack App as the user interface, AWS API Gateway to handle incoming webhook requests, AWS Lambda running a stateless Python 3.12 function, Amazon Bedrock for the LLM orchestration, and AWS OpenSearch Serverless as the vector database.”summary, stated

observability-tracing (operations)

CloudWatch logging gives the team runtime visibility into Lambda behavior.

“CloudWatch logs are retained for 90 days, providing observability into the system's behavior.”summary, stated

safety-policy-enforcement (risk)

The team performed a security and privacy risk assessment before development.

“Before development, the team conducted a security and privacy risk assessment, asking critical questions about data sensitivity”summary, stated

Tradeoffs

Use AWS managed RAG services for a prototype.

Chose Bedrock knowledge bases, OpenSearch Serverless, API Gateway, and Lambda over Building and operating a custom RAG platform.

Rationale: The managed wizard reduced what would have been days of setup to minutes.

“The team notes this reduced what would have been a multi-day setup project to a matter of minutes.”summary, stated

Tune chunking to answer shape instead of accepting defaults.

Chose Hierarchical chunking with 1500-token parents over Bedrock's 300-token default chunks.

Rationale: Long ordered FAQ answers needed enough context to stay intact, without including irrelevant material.

“token size should be near the upper limit of your longest answers, but not larger than necessary to avoid feeding irrelevant context to the LLM”summary, stated

Use Slack as the support interface.

Chose A Slackbot over A separate knowledge-base portal.

Rationale: The problem was engineers asking internal support questions, and Slack already contained both the interaction channel and historical support threads.

“Historical Slack threads documenting Terraform Cloud issues and their solutions were manually copied into text files and stored in S3.”summary, stated

Gotchas (what bit them)

Default chunking cut off multi-paragraph FAQ answers.

Root cause: Bedrock's 300-token default chunks were shorter than the team's ordered-step answers.

Resolution: Use hierarchical chunking with a 1500-token parent size, near the upper limit of the longest answers.

“default chunking of 300 tokens (approximately one paragraph), which led to substandard results because their FAQ answers often span multiple paragraphs”summary, stated
“hierarchical chunking with a parent token size of 1500 tokens (approximately 5 paragraphs) worked best for their use case.”summary, stated

Important documentation context was visual and therefore unavailable to the knowledge base.

Root cause: The knowledge base could not process images in queries or include documentation images in responses.

Resolution: Record image processing as a limitation and future production maturity requirement.

“Image Processing: The knowledge base cannot process images in queries or include images from documentation in responses. This is particularly limiting given that infrastructure documentation typically includes architecture diagrams, UI screenshots, and error message examples.”summary, stated

Manual synchronization created freshness debt.

Root cause: Data sources required manual sync operations in the prototype.

Resolution: Plan CloudWatch event cron triggers for at least weekly automated synchronization.

“Data sources require manual sync operations. The team plans to implement CloudWatch event cron triggers for at least weekly automated synchronization.”summary, stated

Slack responses lacked visible citations.

Root cause: Bedrock UI citations were not passed through to Slack.

Resolution: Add citation links to Slack responses as a future improvement.

“While the Bedrock UI shows answer citations during testing, these aren't currently passed through to Slack responses”summary, stated

Evaluation

The summary reports chunking experiments, a security/privacy risk assessment, and prototype limitations; it does not provide a quantitative production evaluation beyond the operational configuration and lessons learned.

Metrics: Chunking quality · Security/privacy risk assessment · CloudWatch logs retained for 90 days · Manual limitation inventory

3 supporting quotes
“After experimentation, they found that hierarchical chunking with a parent token size of 1500 tokens (approximately 5 paragraphs) worked best”summary, stated
“Before development, the team conducted a security and privacy risk assessment, asking critical questions about data sensitivity, the downside risk of incorrect results or hallucinations, and which models were already approved for use at Benchling.”summary, stated
“The team is transparent about several limitations of their current implementation:”summary, stated

Outcomes

The summary reports approximately 160,000 Terraform resources, five data centers, around 50 monthly infrastructure-changing engineers, a 20-page FAQ, 128MB Lambda memory, 60-second timeout, and 90-day log retention.

3 supporting quotes
“The team notes this reduced what would have been a multi-day setup project to a matter of minutes.”summary, stated
“This project serves both as a practical solution to their immediate documentation problem and as a reference implementation for future LLM-powered tools”summary, stated
“The transparency about limitations and future enhancement plans suggests a pragmatic approach to LLMOps, balancing rapid experimentation with acknowledgment of production requirements that still need to be addressed.”summary, stated