> For the complete documentation index, see [llms.txt](https://atlas.anywhere.now/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://atlas.anywhere.now/developer-docs/webchat-front-end-events.md).

# WebChat front-end events

Use WebChat front-end lifecycle events for post-load website customization.

Use WebChat front-end lifecycle events when website code must run at a specific point in the WebChat loading sequence.

## WebChatLoaded

`WebChatLoaded` is a browser event for post-load website customization.

| Property        | Value                                 |
| --------------- | ------------------------------------- |
| Event name      | `WebChatLoaded`                       |
| Dispatch target | `window`                              |
| Event type      | Plain browser `Event`                 |
| Payload         | No `event.detail` payload is defined. |

Register the listener before calling `WebChat.load(...)` when you need to capture the event reliably. The event fires after the WebChat start sequence completes and the widget has been initialized enough for post-load API calls. It does not indicate that every external asynchronous dependency has finished.

Use `WebChatLoaded` before code that depends on WebChat being started, such as:

* `WebChat.setUser(...)`
* `WebChat.toggleStyle(...)`
* `WebChat.changeLanguage(...)`

## WebChatInitialized

`WebChatInitialized` is also dispatched on `window`.

This event indicates that the global `WebChat` API object has been assigned. It is not equivalent to the widget being loaded. Use `WebChatLoaded` for post-load customization that depends on the WebChat start sequence.

## Example

```html
<script>
  const webChatConfig = {
    // Use the WebChat configuration values supplied for the environment.
  };

  window.addEventListener('WebChatLoaded', function () {
    WebChat.setUser('customer:example-12345', 'Pat Example');
    WebChat.toggleStyle('dark');
    WebChat.changeLanguage('en');
  });

  WebChat.load(webChatConfig);
</script>
```

Use only style names, language codes, user identifiers, and configuration values supported by the WebChat package supplied for the environment.

## Related topics

* [WebChat front end](/channels-integrations/text-channels/webchat/webchat-front-end.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://atlas.anywhere.now/developer-docs/webchat-front-end-events.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
