Aws AI Chat
Audience:
Low-code EngineersSkill Prerequisites:
Actions,Tokens,Connectors
Sends a message to a chat model on Amazon Bedrock and stores the reply in a token. You pick the model family (Claude, Llama or Titan), can give the model instructions, pass the earlier messages of a conversation, and let Claude or Llama run your workflows as tools.
The AWS sign-in details come from an Amazon Bedrock AI connector.
This action is part of the PlantAnApp.OpenAi add-on. The add-on is installed separately and requires the AI feature package to be licensed. If it isn't licensed, the action fails with a not-licensed error. The Amazon Bedrock AI connector type needs the same license.
Typical Use Cases
- Answer users' questions with a model hosted in your own AWS account and region
- Continue a conversation by passing the earlier messages back to the model
- Let Claude run a workflow to look something up, for example an order status, before it answers
- Stream the reply word by word to a Conversation View
Don't use it to
- Send data you aren't allowed to share with AWS or the model provider. Everything in the message, instructions and history leaves your server.
- Make decisions that must always be correct, such as approvals or calculations. Check the reply, or use normal actions and SQL.
- Get JSON replies with a schema, or control temperature and length. Use Chat instead.
- Send images or files. The action sends text only.
Related Actions
| Action Name | Description |
|---|---|
| Chat | Chats with OpenAI or Microsoft Azure OpenAI models. |
| VertexAI Chat | Chats with Google Vertex AI models. |
| Summarize Content | Summarizes long content with OpenAI. |
| Create Articles | Writes articles with OpenAI. |
| Count Tokens | Counts the tokens in a text for an OpenAI model. |
| Speech to Text (Whisper) | Turns an audio file into text with OpenAI. |
| Add Connector | Creates a connector, for example an Amazon Bedrock AI connector. |
| Test Connector | Checks that a connector's details work. |
| Execute Actions | Catches this action's errors with its On Error actions. |
Comparing the chat actions
| Chat | Aws AI Chat | VertexAI Chat | |
|---|---|---|---|
| Provider | OpenAI or Microsoft Azure OpenAI | Amazon Bedrock | Google Vertex AI |
| Connector type | OpenAI (openAi) or Microsoft Azure OpenAI (azure.openAi) | Amazon Bedrock AI (plantanapp.aws.bedrock) | Google VertexAI (vertexAi) |
| Models | OpenAI: picked from PAA's model list. Azure: your deployment. | Claude, Llama or Titan, in fixed versions | Gemini and older PaLM models from PAA's list, or any model ID with an expression |
| Temperature and maximum length | Yes | No, fixed per model | Yes |
| JSON or JSON Schema reply | Yes | No | No |
| Workflows as tools | Yes | Claude and Llama only | No |
| Streaming | Optional | Optional | Required for Gemini, not possible for PaLM |
| Ignore Errors and On Error | Yes | No | Yes |
Connecting to Amazon Bedrock
Create a connector first, in the Connectors area or with Add Connector. See Connectors.
| Connector type | Field | Description |
|---|---|---|
Amazon Bedrock AI (plantanapp.aws.bedrock) | AWS Region | The AWS region to call, for example us-east-1. Required by this action. |
Amazon Bedrock AI (plantanapp.aws.bedrock) | Access Key ID | The access key ID of an AWS user that may call Bedrock. |
Amazon Bedrock AI (plantanapp.aws.bedrock) | Access Key Secret | The secret for that access key. |
In your AWS account, the model you pick must be enabled for Bedrock in that region.
Test Connector checks the connector by asking AWS for the list of foundation models. A successful test doesn't prove that you have access to a specific model. The test also falls back to us-east-1 when the region is empty, but this action fails without a region.
Input Parameter Reference
| Parameter | Description | Supports Tokens | Default | Required |
|---|---|---|---|---|
| Connector | The Amazon Bedrock AI connector. You can also switch to an expression and use a token that holds the connector ID. | Yes | empty | Yes |
| AWS Model Id | The model family: Claude, Llama or Titan. With an expression, use one of these exact names. See Models. | Yes | Claude | No |
| Message | The new user message, for example [Question]. | Yes | empty string | Yes |
| Workflows | Workflows the model may run as tools. Claude and Llama only. See Workflows as tools. | Yes | empty | No |
| Dynamic Workflows | More workflow IDs, separated by commas or new lines. They're added to Workflows. | Yes | empty string | No |
| Stream Response | Streams the reply to a Conversation View while it's being written. Not supported with Titan. See Streaming. | No | false | No |
| Live Stream Name | The name of the live stream. It must be unique across the site. Shown when Stream Response is on. | Yes | empty string | With streaming |
| Message Stream ID | The ID of this message in the live stream. It must be unique within the live stream. Shown when Stream Response is on. | Yes | empty string | With streaming |
| Instructions | The system message. Tells the model how to behave, for example You are a helpful support assistant for [CompanyName]. | Yes | empty string | No |
| Previous Message Json | The earlier messages of the conversation, as a JSON array. See Messages and history. | Yes | empty string | No |
Output Parameters Reference
| Parameter | Description |
|---|---|
| Store Output Message | The token that gets the model's reply as text. |
| Store Entire Conversation JSON | The token that gets the whole conversation as a JSON array, including the new message and the reply. You can pass it back as Previous Message Json in the next call. The instructions aren't included. |
| Store Entire Output | Meant for the full JSON response from AWS. In 1.28 this token isn't filled. Use Store AI Debug Payloads JSON instead. |
| Store AI Debug Payloads JSON | The token that gets a JSON array with every request sent and every response received from Bedrock, with timestamps. Token counts are in the responses. Your AWS keys aren't included. |
Models
AWS Model Id picks a model family. Each family uses one fixed model version and fixed settings:
| AWS Model Id | Bedrock model | Temperature | Maximum reply length |
|---|---|---|---|
Claude | anthropic.claude-3-sonnet-20240229-v1:0 | 0.5 | 2,000 tokens |
Llama | meta.llama2-70b-chat-v1 | 0.5 | 512 tokens |
Titan | amazon.titan-text-express-v1 | 0 | 512 tokens |
You can't change these values. AWS retires older model versions over time, so check that the model is still available in your region.
Messages and history
Instructions, Previous Message Json and Message are combined in the format each model expects. For Claude, the instructions are the system prompt. For Llama and Titan, they're placed at the start of the prompt.
Previous Message Json is a JSON array of role and content pairs:
[
{ "role": "user", "content": "Hi, my printer won't print." },
{ "role": "assistant", "content": "Sorry to hear that. Is it showing an error light?" }
]
The history must follow these rules, or the action fails with The history json is invalid:
- It starts with a
usermessage. - Messages alternate: a
user(ortool) message, then anassistantmessage. So there's always an even number of messages. - Every
assistantmessage has content. - Roles aren't case-sensitive.
The easiest way to keep a conversation going is to store Store Entire Conversation JSON in a token and pass that token back as Previous Message Json next time. The stored JSON has the roles User, Assistant and, after workflow calls, Tool. You can pass it back unchanged.
Workflows as tools
Add workflows in Workflows or Dynamic Workflows to let Claude or Llama run them. The model decides whether to run one, based on the question.
- Use numeric workflow IDs. In 1.28, workflows given by GUID pass the check but aren't offered to the model.
- PAA describes the workflows to the model in its instructions, with their names, descriptions, and input and output fields.
- When the model asks for a workflow, PAA runs it in a new, separate context. The model's arguments become tokens named after the input fields. Tokens from the calling action aren't available.
- Every output field must have a value when the workflow ends. The values go back to the model, which then writes its reply.
- Each workflow call is another request to Bedrock and adds to the cost.
- Titan doesn't use workflows. They're ignored.
See Workflows for how to set up input and output fields.
Streaming
With Stream Response on, the reply is sent to a live stream while the model writes it. The action still waits for the full reply and stores it in Store Output Message.
Streaming is meant for the Conversation View:
- Fill in
Live Stream NameandMessage Stream ID, and use the same values in the Conversation View. - Add a
Statuscolumn in the Conversation View settings. It can beprocessing,doneorerror(not case-sensitive), or0,1or2. - Set the status to
processingbefore the chat action runs. Set it todoneorerrorafter it.
In 1.28, streaming works with Claude and Llama only. With Titan, the action fails.
Errors
This action has no Ignore Errors or On Error settings. When something goes wrong, for example a wrong key, a missing region, a model you don't have access to or invalid history, the action fails and the remaining actions don't run.
To handle the error yourself, put the action inside Execute Actions and use its On Error actions. There, [ExceptionMessage] holds the error, for example Invoking the anthropic.claude-3-sonnet-20240229-v1:0 chat model threw exception.