> For the complete documentation index, see [llms.txt](https://developers.chathive.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.chathive.app/sdk/ai-form/events.md).

# Events

## on

Subscribes to emitted events, which are described below.\
This function returns a subscription id that can be used to unsubscribe.

```typescript
aiForm.on(eventName, (payload) => void);
```

## off

Unsubscribes from emitted events, which are described below.

```typescript
aiForm.off(subscriptionId);
```

## Events list

<table><thead><tr><th width="232">Event name</th><th>Description</th></tr></thead><tbody><tr><td><code>initialized</code></td><td>AI form has been initialised and is ready to be used</td></tr><tr><td><code>error</code></td><td>Unexpected error has occurred</td></tr><tr><td><code>message.inbound</code></td><td>New message is received.<br><em>Messages are send partially and need to be reconstructed</em></td></tr><tr><td><code>message.outbound</code></td><td>Message is send by the user</td></tr><tr><td><code>session.completed</code></td><td>User has filled in all necessary fields. Form session has been marked as completed</td></tr><tr><td><code>tool.called</code></td><td>Event is emitted when ever a tool is called or ended</td></tr><tr><td><code>tool.custom.event</code></td><td>Event is emitted when ever your custom event emitter tool is called</td></tr><tr><td><code>typing.started</code></td><td>Is typing is triggered by the agent</td></tr><tr><td><code>typing.stopped</code></td><td>Is typing stopped</td></tr></tbody></table>


---

# 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 dynamically by asking a question.

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

```
GET https://developers.chathive.app/sdk/ai-form/events.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
