Initializes conversations, adds messages, and generates replies. Chat reply block

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

  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:
  • 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.
Chat reply block configuration This workflow provides automated customer support while ensuring complex issues go to human agents.

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:
  • 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.
Chat reply block configuration This workflow provides a chatbot that can answer questions about the company’s products and services.

Fields

NameTypeControlDefaultDescriptionOptionsValidation
Conversation ObjectBinding--The variable that has your conversation object.--
System promptTextTextarea""A system prompt to set the context for the conversation. Can be left empty if conversation is already initialized in state.--
MessageObject--An array with messages or a variable to contain save your conversation as an object. --
Initial modelModel Id-palmyra-x5---
Initial temperatureNumber-0.7--Range: 0 to 1
Initial max tokensNumber-1024--Range: 1 to 16384
Use streamingBoolean-yesIf 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.--
ToolsTools----

End states

Below are the possible end states of the block call.
NameFieldTypeDescription
ToolstoolsdynamicRun associated tools.
Success-successIf the function doesn’t raise an Exception.
Error-errorIf the function raises an Exception.
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.