# Connecting MANGO Dialogues

Integration transmits calls from the **MANGO Dialogues** channels to ChatRex and sends the bot’s responses to the same chat.

All MANGO Dialogue channels available to a selected MANGO OFFICE employee are connected via a single integration card. For answers ChatRex recommend to create a separate employee: so the message bot will be easier to distinguish from the responses of operators.

## Before connecting n

Prepare:

- ChatRex account with an active subscription and free channel space
- Virtual MANGO OFFICE PBX with MANGO Dialogues connected;
- Administrator access to MANGO OFFICE integration settings;
- **BTC code** (`vpbx_api_key`) and **Signature key** (`vpbx_api_salt`).

!!!warning
The signature key gives access to integration. Do not send it in correspondence, do not add a bot to the instructions and do not store it in a public file.
!!!

## Connecting to ChatRex

1. Open **Integrations**.
2. Press **Connect integration** and select **MANGO Dialogues**.
3. Enter **BTC Code** and **Signature Key**.
4. Press **Get employees**.
5. In the **ChatRex Response Officer** field, select the employee on whose behalf the bot will respond to customers.
6. Press **Connect**.
7. In the connected card, copy the value of the **Address for webhooks** field.

## Configure the Connector API in MANGO OFFICE

The callback address must be specified manually – ChatRex cannot register it with MANGO OFFICE automatically.

1. In MANGO OFFICE, open **Settings> Integrations → API Connector**.
2. Connect the **API Connector** if it is not already connected.
3. In the **External system address** field, insert the webhook address copied from ChatRex ****.
4. Save the settings.

Use the address completely and unchanged. It is unique for connected integration.

## Designation of a botoo channel

1. In ChatRex, open **My Bots** and press **Change** opposite the desired bot.
2. Go to **Channels and Launch**.
3. Add the connected channel **MANGO Dialogues**.
4. If necessary, set the conditions and launch time.
5. Save the changes.

## Verification

1. Write a test text message to one of the MANGO Dialogue channels.
2. Make sure the dialog appears in **Chats**ChatRex.
3. Check that the bot's response came to the original chat on behalf of the selected employee.

If the bot does not respond, check:

- the correctness of the BAC code and the signature key;
- Whether an employee has been selected to respond;
- Does the **Address of the external system** match the address from ChatRex?
- Is the Connector API active in MANGO OFFICE?
- whether the channel has been added to the subscription and assigned to the bot;
- Whether the message and time are suitable for the bot launch conditions.

## Manual handling

If necessary, stop automatic processing in **Chats**ChatRex and transfer the dialogue to the employee. A separate MANGO OFFICE employee for ChatRex helps operators see what responses the bot sent.

The BBX code and signature key are stored on the ChatRex server in encrypted form. Repeated incoming events should not create repeated responses, and a message with an unknown sending result is not automatically sent a second time.
