Prerequisites
Before you begin, make sure you have:- Node.js 18+ installed on your machine
- An AWS account with access to Amazon Bedrock
- AWS CLI configured (optional, but recommended)
- A Bedrock Agent already created in your AWS account
- An S3 bucket for document storage (optional, for knowledge base features)
If you don’t have a Bedrock Agent yet, you’ll need to create one in the AWS Console before proceeding. Visit the AWS Bedrock documentation to learn how to create an agent.
Installation
Install dependencies
Install the required npm packages using your preferred package manager:The application uses the following key dependencies:
astro- Web framework for building the UI@aws-sdk/client-bedrock-agent-runtime- For interacting with Bedrock agents@aws-sdk/client-bedrock-agent- For managing knowledge base sync@aws-sdk/client-s3- For document uploads
AWS Configuration
Before you can chat with your Bedrock agent, you need to configure your AWS credentials and agent settings.Open the application
Navigate to
http://localhost:4321 in your web browser. You’ll see the Workshop Cloud Chat interface with configuration options.Configure AWS credentials and Bedrock agent
Click the ⚙ settings icon next to “Asistente Bedrock · Chat con Agente” to open the configuration dialog.Fill in the following required fields:AWS Credentials:Click Guardar (Save) to apply your configuration.
- AWS Access Key ID - Your AWS access key (required)
- AWS Secret Access Key - Your AWS secret key (required)
- AWS Session Token - Only needed if using temporary credentials (optional)
- Region - The AWS region where your agent is deployed (e.g.,
us-east-1) - Agent ID - Your Bedrock agent’s unique identifier (e.g.,
XXXXXXXXXX) - Agent Alias ID - The agent alias ID (e.g.,
TSTALIASID) - Session ID - Leave empty to auto-generate (optional)
Verify configuration
After saving, check the “Resumen de configuración” panel on the right side:
- AWS: Should show “credenciales configuradas (YOUR_ACCESS_KEY_ID)”
- Agente: Should display your region, agent ID, and alias
- S3: “sin configurar” (unless you’ve configured S3)
- KB Sync: “sin configurar” (unless you’ve configured knowledge base sync)
Your First Chat Interaction
Now that everything is configured, let’s send your first message to the Bedrock agent.Send the message
Click the Enviar (Send) button or press
Enter to send your message.The application will:- Display your message in the chat window with a 👤 user icon
- Send an
InvokeAgentCommandto AWS Bedrock with your message:
- Stream the response back from the agent
- Display the agent’s reply with a 🤖 assistant icon
View the response
The agent’s response will appear in the chat window. Each message shows:
- The role (Tú for user, Agente for assistant)
- An emoji indicator (👤 or 🤖)
- The message content
Understanding Sessions
Workshop Cloud Chat uses session IDs to maintain conversation context with your Bedrock agent:- Auto-generated sessions: By default, a new session ID is created each time you reload the page
- Session persistence: Within a session, the agent remembers previous messages
- Custom sessions: You can specify a session ID in the configuration to resume a previous conversation
src/pages/api/chat.ts:51:
Sessions are managed by AWS Bedrock. Once you close the application, session history is maintained by AWS but not in the local application state.
Next Steps
Congratulations! You’ve successfully set up Workshop Cloud Chat and sent your first message. Here’s what to explore next:Upload Documents
Learn how to upload PDF documents to S3 for your knowledge base
Knowledge Base Sync
Configure and run knowledge base synchronization jobs
Environment Variables
Set up environment variables for production deployments
Deploy to AWS
Deploy your application to AWS Amplify
Troubleshooting
Chat section is disabled
If the chat section shows “Configura chat y credenciales para habilitar esta sección,” make sure:- All required fields in the configuration dialog are filled
- Your AWS credentials are valid
- Your Bedrock agent exists in the specified region
Authentication errors
- Your AWS credentials are incorrect or expired
- You need to include a session token if using temporary credentials
- The IAM user/role doesn’t have permission to invoke Bedrock agents
Agent not responding
If messages send but you receive no response:- Check that your Agent ID and Alias ID are correct
- Verify the agent is deployed and active in the AWS Console
- Enable debug mode to see the raw API response
- Check your agent’s CloudWatch logs for errors
For more detailed troubleshooting, visit the AWS Bedrock console and check your agent’s execution logs.