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

# loadThreadById()

Loads an existing conversation thread by its ID, allowing users to resume a previous conversation. This method enables applications to restore chat history and continue from where the user previously left off.

## Syntax

```javascript theme={null}
instance.loadThreadById(threadId);
```

## Parameters

**threadId** `string`

The ID of the conversation thread to load. If not provided, a new thread is created when the user sends a message.

## Returns

**void**

Returns a `void` operator.

## Examples

The following example captures thread ID from send event:

```javascript theme={null}
// Capture thread ID from send event
instance.on('send', (event) => {
    const threadId = event.message.thread_id;
    console.log('Current thread:', threadId);
});
```

## Considerations

### Behavior

* **With `threadId`**: The chat loads the conversation history associated with the specified thread ID.
* **Without `threadId`**: A new conversation thread is created when the user sends their first message.
* **Invalid `threadId`**: If an invalid or deleted thread ID is provided, a console error is logged. The chat continues to function normally, allowing the user to proceed with the current conversation.

### Getting the Thread ID

Thread IDs are available through the chat event system. You can capture them from the `send` or `pre:send` events.

> [card] [Do you need practical examples?](https://www.ibm.com/docs/SSAVQO/deploy/web_chat_agent/tutorials/tutorials_lp.html)
>
> Learn how to apply the features available for embedded chat into your implementation with guidance and examples.
