AI Chat with Amazon API Gateway (WebSockets), AWS Lambda and Amazon Bedrock

API Gateway Websocket API → AWS Lambda → Amazon Bedrock

WebSocket-Enabled AI Chat Using AWS Services.

This serverless architecture enables real-time AI chat using AWS services. A WebSocket Amazon API Gateway maintains persistent connections between clients and a Node.js AWS Lambda function.
The AWS Lambda function handles user connections/disconnections, stores connection IDs in Amazon DynamoDB, and processes messages through an Amazon Bedrock LLM.
The system includes error handling, automatic scaling, and pay-per-use pricing.
The AWS SAM template provisions all necessary resources and IAM permissions, outputting a WebSocket URL for client connections.

< Back to all patterns

GitHub icon Download this pattern (.zip)

GitHub icon View this pattern on GitHub


Clone repo

git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/apigw-websocket-lambda-bedrock-sam

Deploy

sam deploy


Testing

See the GitHub repo for detailed testing instructions.

Cleanup

sam delete

Created by:

Mike Hume

Mike Hume

AWS Senior Solutions Architect & UKPS Serverless Lead.

Follow on LinkedIn