Overview
The Bedrock Agent powers the AI chat functionality in Workshop Cloud Chat. It processes user messages and returns intelligent responses using Amazon Bedrock’s agent runtime.Make sure you have configured AWS credentials before setting up the Bedrock agent.
Required Parameters
The AWS region where your Bedrock agent is deployed.Example:
us-east-1, us-west-2Placeholder: us-east-1The unique identifier for your Bedrock agent.Example:
ABCDEFGHIJPlaceholder: XXXXXXXXXXThe alias ID for the agent version you want to use.Example:
TSTALIASID (test alias), or a production alias IDPlaceholder: TSTALIASIDOptional session identifier for maintaining conversation context.
- If left empty, a new UUID is automatically generated for each page load
- Provide a custom session ID to maintain conversation history across different contexts
- The session is rotated on each page load if agent is configured
Si se deja vacío, se genera automáticamenteConfiguration Steps
Open Configuration Dialog
Click the gear icon (⚙) next to “Chat con Agente (Amazon Bedrock)” in the main chat panel.The configuration dialog titled “Configuración de chat y credenciales” will open.
Configure AWS Credentials
If not already configured, enter your AWS credentials in the “Credenciales AWS” section:
- AWS Access Key ID (required)
- AWS Secret Access Key (required)
- AWS Session Token (optional)
Enter Bedrock Agent Details
In the “Agente Bedrock” section, provide your agent configuration:From
src/pages/index.astro:1010-1017:Save Configuration
Click the “Guardar” button to save your configuration.The settings are persisted to browser localStorage.
How It Works
Session Management
The application automatically generates a new session ID on page load when agent is configured: Fromsrc/pages/index.astro:1172-1177:
Chat API Request
When you send a message, the application makes a POST request to/api/chat with:
From src/pages/api/chat.ts:9-18:
Bedrock Client Initialization
The API creates a Bedrock Agent Runtime client: Fromsrc/pages/api/chat.ts:31-38:
Invoking the Agent
The agent is invoked with the latest user message: Fromsrc/pages/api/chat.ts:53-58:
Processing the Response
The streaming response is decoded and returned: Fromsrc/pages/api/chat.ts:60-72:
Validation Logic
The chat section is enabled only when all required configuration is present: Fromsrc/pages/index.astro:1525-1526:
Using the Chat Interface
View Response
The agent’s response will appear in the messages area:
- User messages appear on the right with a blue gradient background
- Agent responses appear on the left with a light blue background
- Each message shows an emoji indicator (👤 for user, 🤖 for agent)
Error Handling
The API validates all required parameters before invoking the agent: Fromsrc/pages/api/chat.ts:24-29:
Finding Your Agent Details
Open AWS Console
Navigate to the Amazon Bedrock Console.
Select Region
Ensure you’re in the correct AWS region where your agent is deployed (visible in the top-right corner).
Find Agent ID
- Click on your agent name
- The Agent ID is displayed on the agent details page
- Copy the 10-character identifier (e.g.,
ABCDEFGHIJ)
Configuration Summary
After configuration, the right panel displays a summary:src/pages/index.astro:1328-1330:
Managing Configuration
Clear Configuration
To remove all chat and credential settings:- Open the configuration dialog
- Click “Borrar configuraciones”
- This clears both AWS credentials and Bedrock agent settings
Cancel Without Saving
To close the dialog without applying changes:- Click “Cancelar sin guardar”
- The dialog closes and previous settings remain unchanged
Troubleshooting
Chat Section Disabled
Symptoms: Message input and send button are disabled, hint shows “Configura chat y credenciales para habilitar esta sección.” Solutions:- Verify AWS credentials are configured
- Ensure region, agentId, and agentAliasId are all provided
- Check the configuration summary panel for missing values
”Faltan parámetros de configuración del agente Bedrock” Error
Symptoms: API returns 400 error when sending a message. Solutions:- Re-open configuration dialog and verify all required fields are filled
- Check that no fields are empty or contain only whitespace
- Save configuration again
”No hay mensajes para enviar” Error
Symptoms: API returns 400 error even with text in the input. Solutions:- Ensure you’ve actually typed text in the message input
- Check that the message isn’t empty or only whitespace
- Try typing a different message
Agent Not Responding
Symptoms: Message is sent but no response appears. Solutions:- Enable debug mode to see the raw API response
- Check AWS console for agent status and logs
- Verify the agent alias is working and not disabled
- Check IAM permissions for Bedrock access
Best Practices
Use Test Alias for Development
Use the test alias (TSTALIASID) during development, and switch to a production alias for live use.
Monitor Agent Performance
Use Amazon CloudWatch to monitor agent invocations, latency, and errors.
Set Proper IAM Permissions
Ensure your IAM user/role has
bedrock:InvokeAgent permission for the specific agent.Review Agent Logs
Check CloudWatch logs for your agent to debug issues and understand behavior.
Next Steps
- Configure S3 Setup to enable document uploads
- Configure Knowledge Base for document synchronization
- Learn about Using the Chat Interface