Skip to main content

Generate Chat Text

Generates chat responses from Claude AI with conversation history support, enabling multi-turn conversational interactions.

Common Properties

  • Name - The custom name of the node.
  • Color - The custom color of the node.
  • Delay Before (sec) - Waits in seconds before executing the node.
  • Delay After (sec) - Waits in seconds after executing node.
  • Continue On Error - Automation will continue regardless of any error. The default value is false.
info

If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.

Inputs

  • Connection Id - The Claude client session identifier from Connect node (optional if API Key is provided directly).
  • System Prompt - System instructions to guide Claude's behavior throughout the conversation. This remains constant across all turns.
  • User Prompt - The message you want to send in the chat conversation. This is added to the conversation history.
  • Chat History - Previous conversation history for context. Contains all previous user and assistant messages in the conversation.

Options

Authentication

  • API Key - Claude API key (optional if using Connection ID). You can provide the API key directly instead of using a Connect node.
  • Use Robomotion AI Credits - Use Robomotion AI credits instead of your own API key.

Model Selection

  • Model - Select which Claude model to use. Options include:
    • Claude Opus 4.5 - Most capable model for complex conversations
    • Claude Opus 4 - Highly capable model for complex reasoning
    • Claude Sonnet 4.5 - Latest balanced model
    • Claude Sonnet 4 - Balanced performance and speed (default)
    • Claude 3.7 Sonnet - Latest 3.x generation Sonnet
    • Claude 3.5 Sonnet - Previous generation Sonnet
    • Claude 3.5 Haiku - Fastest model for simple conversations
    • Custom Model - Specify your own model name
  • Custom Model - Enter custom model name when Custom Model is selected.

Generation Settings

  • Max Tokens - Maximum number of tokens in the response (default: 4096).
  • Temperature - Controls randomness (0.0-1.0). Higher values make conversations more creative and varied.
  • Top P - Nucleus sampling parameter (0.0-1.0).
  • Top K - Top-k sampling parameter (1-100).
  • Stop Sequences - Stop sequences separated by commas. Generation stops when these sequences are encountered.

Extended Thinking

  • Thinking Mode - Extended thinking allows Claude to reason through complex problems:
    • Off - No extended thinking (default)
    • Auto (Budget: 10240) - Automatic thinking with default token budget
    • Custom Budget - Specify your own thinking token budget
  • Thinking Budget - Custom thinking token budget (1024-128000). Only used when Thinking Mode is Custom.

Advanced

  • Timeout (seconds) - Request timeout in seconds (default: 120).
  • Include Raw Response - Include full API response in output (default: false).

Outputs

  • Text - Claude's text response to the current message.
  • Thinking - Extended thinking output when thinking mode is enabled.
  • Chat History - Updated chat history including this exchange. Pass this to the next Generate Chat Text node to continue the conversation.
  • Raw Response - Complete API response object (when Include Raw Response is enabled).

How It Works

The Generate Chat Text node maintains a conversation with Claude by tracking message history. When executed, the node:

  1. Validates the connection or creates a temporary client using provided credentials
  2. Retrieves the previous chat history (if any)
  3. Appends all historical messages to the conversation
  4. Adds the current user message
  5. Configures the selected model and generation parameters
  6. Sends the complete conversation to Claude API
  7. Receives Claude's response
  8. Updates the chat history with the new exchange (user message + assistant response)
  9. Returns the response text and updated history

Requirements

  • Either a valid Connection Id from Connect node OR direct API Key credentials
  • Non-empty User Prompt

Error Handling

The node will return specific errors in the following cases:

  • Empty or missing User Prompt
  • Invalid Connection Id (when not using direct credentials)
  • Empty Custom Model name when Custom Model is selected
  • Temperature out of range (must be 0.0-1.0)
  • Top P out of range (must be 0.0-1.0)
  • Top K less than 1
  • Thinking budget out of range (must be 1024-128000)
  • API authentication errors (401)
  • API rate limit errors (429)
  • API service errors (500, 503)

Usage Notes

Conversation Management

  • The Chat History output must be connected to the next Generate Chat Text node to continue the conversation
  • Each call adds both the user message and Claude's response to the history
  • The history is stored as a message scope variable (e.g., msg.history)
  • To start a new conversation, simply don't provide a Chat History input

System Prompt

  • The System Prompt sets Claude's behavior for the entire conversation
  • It remains constant throughout all turns in the conversation
  • Use it to define Claude's role, personality, or guidelines

Stop Sequences

  • Stop sequences are strings that stop generation when encountered
  • Useful for controlling when Claude stops responding
  • Multiple sequences can be provided separated by commas
  • Example: "User:, Assistant:" to stop when these labels appear

Conversation Length

  • Each message in history counts toward the context window
  • Long conversations may exceed the model's context limit
  • Consider summarizing or truncating old history for very long conversations

Examples

Example 1: Simple Multi-Turn Conversation

Turn 1:

  • Connection Id: (from Connect node)
  • User Prompt: "Hello! I'm planning a trip to Paris."
  • System Prompt: "You are a helpful travel assistant"
  • Chat History: (empty for first turn)

Output:

  • Text: "Hello! How exciting that you're planning a trip to Paris! I'd be happy to help you..."
  • Chat History: (saved to msg.history)

Turn 2:

  • Connection Id: (from Connect node)
  • User Prompt: "What are the must-see attractions?"
  • Chat History: msg.history (from Turn 1)

Output:

  • Text: "Based on our conversation about your Paris trip, here are the must-see attractions..."
  • Chat History: (updated with both turns)

Example 2: Customer Support Bot

System Prompt:

You are a customer support assistant for an e-commerce company.
Be helpful, professional, and empathetic. Always ask for order
numbers when helping with order issues.

Conversation Flow:

  1. User: "I haven't received my package"
    • Claude: Asks for order number
  2. User: "Order #12345"
    • Claude: Looks up order (via other nodes) and provides status
  3. User: "Can I get a refund?"
    • Claude: Explains refund policy and next steps

Each turn maintains context from previous messages through Chat History.


Example 3: Interview Bot with Stop Sequences

Inputs:

  • System Prompt: "You are conducting a job interview. Ask one question at a time."
  • User Prompt: "I'm ready for the interview"
  • Stop Sequences: "INTERVIEW_END"

Configuration:

  • Model: Claude Sonnet 4
  • Temperature: 0.6

The bot will ask questions one at a time, and the conversation can be stopped by including "INTERVIEW_END" in a response.


Example 4: Tutoring Session with Extended Thinking

System Prompt:

You are a math tutor. Explain concepts clearly and show your
work step by step. Use extended thinking for complex problems.

Configuration:

  • Model: Claude Opus 4.5
  • Thinking Mode: Auto
  • Max Tokens: 3000

Conversation:

  1. Student: "I don't understand quadratic equations"
    • Claude explains basics
  2. Student: "Can you show me an example?"
    • Claude provides step-by-step example with thinking
  3. Student: "What if the coefficient is negative?"
    • Claude explains with context from previous examples

Example 5: Chatbot with Personality

System Prompt:

You are a friendly AI assistant with a slightly humorous personality.
You enjoy using analogies and making complex topics easy to understand.
Keep responses conversational but informative.

Configuration:

  • Model: Claude Sonnet 4
  • Temperature: 0.7
  • Max Tokens: 500

This creates a more engaging conversational experience while maintaining the conversation context.


Example 6: Task-Oriented Conversation

System Prompt:

You are helping users complete a multi-step form. Guide them
through each field one at a time. Remember what they've already
provided.

Workflow:

  1. Claude: "Let's start with your name"
  2. User: "John Smith"
    • (Remember: name = John Smith)
  3. Claude: "Thanks John! What's your email?"
  4. User: "john@example.com"
  5. And so on...

Chat History maintains all the information collected throughout the conversation.

Best Practices

  1. Conversation Design:

    • Always provide clear System Prompts to set expectations
    • Design conversation flows before implementation
    • Plan for both happy path and error scenarios
  2. History Management:

    • Always pass Chat History between turns to maintain context
    • Store history in message scope variables (msg.history)
    • Consider conversation length and context limits
  3. Context Control:

    • Use System Prompt for consistent behavior across turns
    • Reset history (don't pass it) to start new conversations
    • Summarize or truncate very long conversations
  4. Stop Sequences:

    • Use stop sequences to control conversation flow
    • Implement clear exit conditions
    • Test stop sequences thoroughly
  5. Parameter Tuning:

    • Use moderate temperature (0.6-0.7) for natural conversations
    • Adjust based on the formality required
    • Lower temperature for consistent, professional responses
  6. Error Handling:

    • Handle API errors gracefully
    • Provide fallback responses
    • Validate user input before sending to Claude
  7. Model Selection:

    • Use Haiku for simple, fast chatbots
    • Use Sonnet for general-purpose conversations
    • Use Opus for complex, nuanced conversations
  8. Performance:

    • Monitor conversation length and token usage
    • Implement conversation timeouts if needed
    • Consider caching frequently used System Prompts
  9. User Experience:

    • Provide clear feedback during processing
    • Handle long response times gracefully
    • Implement typing indicators for better UX
  10. Testing:

    • Test various conversation paths
    • Verify history is maintained correctly
    • Test edge cases (very long messages, special characters)