# Chat2Desk connection

Chat2Desk can transmit calls and messages to ChatRex, and the bot can respond to the client in the initial dialogue or create an internal draft for the operator.

## Preparation of the token

1. In Chat2Desk, open **Settings> API**.
2. Create an administrative API token for ChatRex.
3. Allow access to the company, channels, appeals, messages, comments, tags, operators, groups, dialogues and webhooks.
4. Copy the token.

Use a separate token and issue only the necessary permissions. ChatRex stores the token in encrypted form and does not show it after saving it.

## Connection

1. In ChatRex, open **Integrations**, find **Chat2Desk** and press **Connect**.
2. Insert the API token.
3. Select mode:
   - **Send answers to customers** - the bot publishes a message in the initial dialog;
   - **Create internal drafts** — The bot adds internal commentary visible to employees.
4. Press **Connect**.
5. Wait for the company and channels to be checked. ChatRex will automatically create a signed webhook in Chat2Desk.

The connection is ready when the connected company is displayed in the card.

## How dialogues are handled

- The response is sent to the same dialog and channel from which the message came.
- In draft mode, an internal comment **ChatRex draft** is created;
- the operator’s response or translation of the request terminates the pending automatic processing by the bot;
- actions are available only within the company and the rights of the connected token.

## Actions bot

Receiving an appeal, internal comments, tags, statuses and appointments of employees are described in the article [**Actions Chat2Desk**](<../../actions/integrations/chat2desk.md>).

## Verification

1. Send a message to the Chat2Desk test channel.
2. Make sure that the appeal appears in ChatRex.
3. Check the selected mode: public response or internal draft.
4. Respond to the operator and make sure that the bot does not continue the incomplete automation.

## Shutdown

Open the Chat2Desk settings in ChatRex and click **Unplug**. ChatRex will delete the created webhook and saved connection details.
