DEV Community

Cover image for Day 28: Adding a Conversational AI Interface to a React App with AWS Bedrock
Eric Rodríguez
Eric Rodríguez

Posted on

Day 28: Adding a Conversational AI Interface to a React App with AWS Bedrock

Static dashboards are great, but sometimes you have a specific question that a pie chart can't answer. Today, I built a "Chat with your Data" feature using Amazon Bedrock and AWS Lambda.

The Architecture

I modified my existing Serverless stack to support interactive queries without provisioning new infrastructure.

Frontend: Added a simple

input to my React terminal component. When submitted, it fires a GET request to my Lambda Function URL with a ?query= parameter.

Backend: The Python Lambda function checks for the query parameter. If present, it bypasses the standard "Daily Summary" prompt and instead constructs a dynamic prompt containing the user's question and the last 30 days of transaction data.

The Prompt Engineering

The key was ensuring the AI didn't hallucinate. I used a strict context injection technique: "Context: [JSON Data]. User Question: [Query]. Answer based ONLY on the context."

This turns a general-purpose LLM into a hyper-specific financial analyst that knows my exact spending history.

Top comments (0)