> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vzaps.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Chatwoot

> Configure Chatwoot integration and import data with the TypeScript SDK

Use `vzaps.chatwoot` to connect a VZaps instance to Chatwoot.

Common fields on every call:

| Field           | Type     | Required | Description     |
| --------------- | -------- | -------- | --------------- |
| `instanceId`    | `string` | Yes      | Instance ID.    |
| `instanceToken` | `string` | Yes      | Instance token. |

## `chatwoot.get(instanceId, options?)`

Reads the current configuration, including `webhookUrl` and `tokenMasked` when applicable.

```ts theme={null}
const chatwoot = await vzaps.chatwoot.get('VZ...', {
  instanceToken: 'instance-token',
});

console.dir(chatwoot, { depth: null });
```

**Return:** Chatwoot config (`enabled`, `url`, `accountId`, `webhookUrl`, `tokenMasked`, etc.).

## `chatwoot.set(request)`

Creates or updates the instance Chatwoot integration.

```ts theme={null}
const saved = await vzaps.chatwoot.set({
  instanceId: 'VZ...',
  instanceToken: 'instance-token',
  enabled: true,
  url: 'https://app.chatwoot.com',
  accountId: '1',
  token: 'chatwoot-api-token',
  nameInbox: 'WhatsApp VZaps',
  signMsg: true,
  signDelimiter: '\n',
  number: '5511999999999',
  reopenConversation: true,
  conversationPending: false,
  importContacts: true,
  importMessages: true,
  daysLimitImportMessages: 30,
  autoCreate: true,
  organization: 'My company',
  logo: '',
  ignoreGroups: false,
  ignoreJids: [],
});

console.dir(saved, { depth: null });
```

**Return:** saved config (includes `webhookUrl` when generated).

Main payload fields:

| Field                     | Type      | Required | Description                                 |
| ------------------------- | --------- | -------- | ------------------------------------------- |
| `enabled`                 | `boolean` | Yes      | Enables or disables the integration.        |
| `url`                     | `string`  | Yes      | Chatwoot base URL.                          |
| `accountId`               | `string`  | Yes      | Numeric account ID.                         |
| `token`                   | `string`  | Yes      | Chatwoot API token.                         |
| `nameInbox`               | `string`  | No       | API inbox name.                             |
| `autoCreate`              | `boolean` | No       | Auto-create inbox and webhook.              |
| `importContacts`          | `boolean` | No       | Import contacts in the initial flow.        |
| `importMessages`          | `boolean` | No       | Import messages in the initial flow.        |
| `daysLimitImportMessages` | `number`  | No       | Message import window in days. Minimum `1`. |
| `ignoreGroups`            | `boolean` | No       | Ignore group messages.                      |
| `ignoreJids`              | `array`   | No       | JIDs to ignore.                             |

<Tip>
  Copy `webhookUrl` from the response into the Chatwoot API inbox when `autoCreate` does not apply it automatically.
</Tip>

## `chatwoot.delete(instanceId, options?)`

Removes the Chatwoot integration from the instance.

```ts theme={null}
await vzaps.chatwoot.delete('VZ...', {
  instanceToken: 'instance-token',
});
```

**Return:** integration removal confirmation.

## `chatwoot.triggerImport(request)`

Triggers a manual import of contacts, messages, or both.

Import contacts:

```ts theme={null}
await vzaps.chatwoot.triggerImport({
  instanceId: 'VZ...',
  instanceToken: 'instance-token',
  what: 'contacts',
});
```

**Return:** import job confirmation (`contacts`, `messages`, or `all`).

Import messages:

```ts theme={null}
await vzaps.chatwoot.triggerImport({
  instanceId: 'VZ...',
  instanceToken: 'instance-token',
  what: 'messages',
});
```

Import all:

```ts theme={null}
await vzaps.chatwoot.triggerImport({
  instanceId: 'VZ...',
  instanceToken: 'instance-token',
  what: 'all',
});
```

Accepted values for `what`: `contacts`, `messages`, `all`.
