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

How it works

  1. 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.
  2. System prompt: Set the context or behavior for the AI. Can be left empty if conversation is already initialized in state.
  3. Message: Enter the user’s message as an object with role and content properties; 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.
  4. Configuration: Set model (default: palmyra-x5), temperature (0-1), and max tokens (1-16384).
  5. Use streaming: Choose whether to stream responses as they’re generated or wait for complete responses.
  6. 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:

  1. A Chatbot block that displays the chat interface.

Blueprint flow:

  1. UI Trigger → Customer sends message through chat interface
  2. Chat reply → Processes message and generates AI response
  3. Classification → Determines if human agent is needed
  4. 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:

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.

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:

  1. A Chatbot block that displays the chat interface.

Blueprint flow:

  1. UI Trigger → Customer sends message through chat interface
  2. 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:

You are a helpful customer support assistant. Be friendly and professional. You have access to information about the company's products and services.

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.