Chat reply - Writer AI Studio
Overview
The Chat reply block is a comprehensive chat solution that can initialize conversations, add messages, and generate replies in a single block. It’s designed to handle the complete chat workflow efficiently. You can specify a conversation state variable to store the chat history, system prompt, message, and various configuration options. The block manages the conversation state and generates appropriate responses. You can also configure tools that the AI can use during the conversation, such as function tools and Knowledge Graphs.
Common use cases
- Building complete chat applications
- Creating AI assistants with conversation management
- Implementing interactive workflows with chat capabilities
- Developing conversational interfaces with tool calling
How it works
- Conversation Object: A binding variable that stores the chat history and metadata. If not provided or empty, a new conversation will be created and stored in the state.
- System prompt: Set the context or behavior for the AI. Can be left empty if conversation is already initialized in state.
- Message: Enter the user’s message as an object with
roleandcontentproperties; for example,{"role": "user", "content": "What are the best practices for using the product?"}. If you want to pass the user’s message from the Chatbot interface to the Chat reply block, you can use the@{payload}variable. - Configuration: Set model (default:
palmyra-x5), temperature (0-1), and max tokens (1-16384). - Use streaming: Choose whether to stream responses as they’re generated or wait for complete responses.
- Tools configuration: Configure tools that the AI can use during the conversation:
- Function tools: Define custom functions with parameters that the AI can call
- Graph tools: Connect to knowledge graphs for enhanced responses
- Tool routing: Control when and how tools are called during the conversation
- Tool responses: Handle and process the results returned from tool executions
- See tool calling for more information on how to configure tools.
Examples
Customer support chatbot
This example shows a customer support chatbot that can handle conversations and route to human agents if needed. Interface:
- A Chatbot block that displays the chat interface.
Blueprint flow:
- UI Trigger → Customer sends message through chat interface
- Chat reply → Processes message and generates AI response
- Classification → Determines if human agent is needed
- Conditional routing → Routes to human agent via HTTP Request block if a human agent is needed. Otherwise, the workflow starts again with the next user message.
Chat reply block configuration:
- Conversation Object:
@{chat} - System prompt:
You are a helpful customer support assistant. Be friendly and professional.
IMPORTANT: If you encounter any of the following situations, clearly indicate that you need to route to a human agent:
- Complex technical issues beyond your capabilities
- Requests for account modifications or sensitive information
- Complaints that require escalation
- Situations where you're unsure or need human judgment
- Requests for supervisor or manager assistance
When routing to human, use phrases like:
- "I need to connect you with a human agent for this request"
- "Let me escalate this to our support team"
- "This requires human assistance, let me transfer you"
- "I'll need to route this to a specialist"
For routine questions and simple requests, provide helpful responses directly.
- Message:
@{payload}. This passes the user’s message from the Chatbot interface to the Chat reply block.
Connect a chatbot to a Knowledge Graph
This example shows a chatbot that can answer questions about domain-specific knowledge within a Knowledge Graph. Interface:
- A Chatbot block that displays the chat interface.
Blueprint flow:
- UI Trigger → Customer sends message through chat interface
- Chat reply → Processes message and generates AI response. Configured with a Knowledge Graph tool to answer questions about the company’s products and services.
Chat reply block configuration:
- Conversation Object:
@{chat} - System prompt:
You are a helpful customer support assistant. Be friendly and professional. You have access to information about the company's products and services.
- Tools:
- Tool type:
Knowledge Graph - Tool name: A name to help you identify the tool in the response.
- Graph id(s): The list of Knowledge Graphs to use. You can select from a list of available Knowledge Graphs.
- Tool type:
Fields
| Name | Type | Control | Default | Description | Options | Validation |
|---|---|---|---|---|---|---|
| Conversation Object | Binding | - | - | The variable that has your conversation object. | - | - |
| System prompt | Text | Textarea | "" |
A system prompt to set the context for the conversation. Can be left empty if conversation is already initialized in state. | - | - |
| Message | Object | - | - | A message object. Content can be text string or array of objects for multimodal (text + images) with X5 model. | - | - |
| Generate reply | Boolean | - | yes |
If set to ‘yes’, the block will generate a reply from the model after adding the message. If set to ‘no’, it will only add the message to the conversation. | - | - |
| Initial model | Model Id | - | palmyra-x5 |
- | - | |
| Initial temperature | Number | - | 0.7 |
- | - | Range: 0 to 2 |
| Initial max tokens | Number | - | 1024 |
- | - | Range: 1 to 16384 |
| Use streaming | Boolean | - | yes |
If set to ‘yes’, the block will stream the reply as it is generated. If set to ‘no’, it will wait for the entire reply to be generated before returning. | - | - |
| Tools | Tools | - | {} |
- | - |
End states
Below are the possible end states of the block call.
| Name | Field | Type | Description |
|---|---|---|---|
| Tools | tools | dynamic | Run associated tools. |
| Success | - | success | The reply was generated successfully. |
| Error | - | error | There was an error generating the reply. |
The dynamic end state means that the exact values of this end state change based on how you define the block. The output of the Chat reply block is a string with the most recent response from the AI to the user’s message. You can access the output in the next block with the @{result} variable.