Bedrock Chatbot

intermediate

Conversational AI chatbot powered by Amazon Bedrock (Claude 3.5 Sonnet). Lambda handler with multi-turn conversation history in DynamoDB (TTL-based). REST API with session management.

Quick Start

Via CLI (recommended)

npx cdk-starter create

Then select "Bedrock Chatbot" from the prompt

Or scaffold directly

npx cdk-starter create --starter bedrock-chatbot

README

Bedrock Chatbot

Conversational AI using Amazon Bedrock (Claude 3.5 Sonnet by default). Multi-turn conversation history stored in DynamoDB with 7-day TTL.

Request Bedrock model access

Before deploying, enable model access in the AWS Console: https://console.aws.amazon.com/bedrock/home#/modelaccess

Enable: Anthropic Claude 3.5 Sonnet (or whichever model you plan to use).

Chat

curl -XPOST <ApiUrl> \
  -H 'Content-Type: application/json' \
  -d '{"sessionId": "my-session", "message": "Hello!"}'

Switch models

Change BEDROCK_MODEL_ID in lib/bedrock-chatbot-stack.ts or set the Lambda env var after deploy.

Prerequisites

  • Node.js ≥ 20
  • AWS CLI configured (aws configure)
  • CDK bootstrapped (npx cdk bootstrap)

Deploy

npm install
npx cdk diff
npx cdk deploy

Tear down

npx cdk destroy