> ## 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.

# pre:restartConversation

Triggered before the conversation restarts. Use this event for alerting the user that the chat will reset, allowing them to complete any ongoing actions or save state before the restart occurs.

## Event properties

<ParamField path="type" type="string" required>
  Always `'pre:restartConversation'`.
</ParamField>

<ParamField path="interactionType" type="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()`](../methods/restartConversation) method.
</ParamField>

## Examples

This example shows how to handle the restart when triggered by the **Restart** button in the chat header:

```javascript theme={null}
function preRestartConversationHandler(event, instance) {
    console.log('pre:restartConversation event', event);
    console.log('Restart source:', event.interactionType);
    
    if (event.interactionType === 'restart_button') {
        console.log('User clicked the Restart button');
    }
}

instance.on('pre:restartConversation', preRestartConversationHandler);
```

This example shows how to handle the restart when triggered by the **New Chat** button in the sidebar:

```javascript theme={null}
function preRestartConversationHandler(event, instance) {
    console.log('pre:restartConversation event', event);
    console.log('Restart source:', event.interactionType);
    
    if (event.interactionType === 'new_chat_button') {
        console.log('User clicked the New Chat button');
    }
}

instance.on('pre:restartConversation', preRestartConversationHandler);
```

This example shows how to handle the restart when triggered programmatically through the `restartConversation()` method:

```javascript theme={null}
function preRestartConversationHandler(event, instance) {
    console.log('pre:restartConversation event', event);
    console.log('Restart source:', event.interactionType);
    
    if (event.interactionType === 'instance_method') {
        console.log('Restart triggered programmatically');
    }
}

instance.on('pre:restartConversation', preRestartConversationHandler);
```

<Card title="Do you need practical examples?" icon="text-align-start" href="https://www.ibm.com/docs/SSAVQO/deploy/web_chat_agent/tutorials/tutorials_lp.html" arrow="true" cta="Learn with walk-throughs" horizontal>
  Learn how to apply the features available for embedded chat into your implementation with guidance and examples.
</Card>
