# Custom Initialization and Passing Metadata

By default the chatbot script is configured to show the chatbot on load. In cases you need customization on which pages does the chatbot show on or pass specific metadata you can override the trigger function and initialize the chatbot on your webpage.

<figure><img src="/files/4loZwZVzNzmp9BAPN5H0" alt=""><figcaption></figcaption></figure>

You can find the **Trigger Function** under **Features**

### Initializing the chatbot

The chatbot works based on events passed through the script. You can fire the following event to show the chatbot on a page. You can customize when the event is sent based on the origin, button click or any other action on the page to show the chatbot.

```javascript
document.dispatchEvent(new CustomEvent("botWidgetInit", {"detail": {"origin": "support"}}));
```

### Passing Metadata

To make decisions in the flow you can pass metadata to the chatbot. This metadata live in the conversation context and is available to use in routing/api and other actions.

```javascript
let metadata = {
    "origin": "support",
    "tags": ["ios", "vip"]
}
document.dispatchEvent(new CustomEvent("botWidgetInit", {"detail": metadata}));
```


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.deepconverse.com/product-docs/chatbots/deploy/custom-initialization-and-passing-metadata.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
