Skip to main content

Documentation Index

Fetch the complete documentation index at: https://developer.watson-orchestrate.ibm.com/llms.txt

Use this file to discover all available pages before exploring further.

Triggered after the conversation restarts, before a new session begins. Use this event for displaying specific UI elements, sending an initial message, or resetting application state when a new session starts.

Event properties

type
string
required
Always 'restartConversation'.
interactionType
string
required
Indicates the source of the restart conversation action. Possible values:
  • 'restart_button' Restart triggered by clicking the Restart button in the chat header.
  • 'new_chat_button' Restart triggered by clicking the New Chat button in the sidebar.
  • 'instance_method' Restart triggered programmatically through the restartConversation() method. This value is automatically set when calling restartConversation().

Examples

This example shows how to handle the restart after it’s triggered by the Restart button in the chat header:
let hasRestarted = false;

function restartConversationHandler(event, instance) {
    console.log('restartConversation event', event);
    console.log('Restart source:', event.interactionType);
    
    if (event.interactionType === 'restart_button') {
        console.log('Conversation restarted through the Restart button');

        // Send a welcome message after restart
        if (!hasRestarted) {
            setTimeout(() => {
                instance.send('Hello! Starting a new conversation.');
            }, 1000);
            hasRestarted = true;
        }
    }
}

instance.on('restartConversation', restartConversationHandler);
This example shows how to handle the restart after it’s triggered by the New Chat button in the sidebar:
let hasRestarted = false;

function restartConversationHandler(event, instance) {
    console.log('restartConversation event', event);
    console.log('Restart source:', event.interactionType);
    
    if (event.interactionType === 'new_chat_button') {
        console.log('New chat started through the New Chat button');
        
        // Send a welcome message after restart
        if (!hasRestarted) {
            setTimeout(() => {
                instance.send('Hello! Starting a new conversation.');
            }, 1000);
            hasRestarted = true;
        }
    }
}

instance.on('restartConversation', restartConversationHandler);
This example shows how to handle the restart after it’s triggered programmatically through the restartConversation() method:
let hasRestarted = false;

function restartConversationHandler(event, instance) {
    console.log('restartConversation event', event);
    console.log('Restart source:', event.interactionType);
    
    if (event.interactionType === 'instance_method') {
        console.log('Conversation restarted programmatically');
        
        // Send a welcome message after restart
        if (!hasRestarted) {
            setTimeout(() => {
                instance.send('Hello! Starting a new conversation.');
            }, 1000);
            hasRestarted = true;
        }
    }
}

instance.on('restartConversation', restartConversationHandler);

Do you need practical examples?

Learn how to apply the features available for embedded chat into your implementation with guidance and examples.