# External contact center solutions
___

The chatbot can manage most queries and requests from end users. In some cases, an agent is required — for example, when the end user's request is too complex for the chatbot, or when the end user asks to speak to an agent.

To enable Chatbots to transfer the chat to an agent, you can integrate Chatbots not only with the Infobip contact center solution, [Inbox](https://www.infobip.com/docs/inbox), but also with third-party Contact Center as a Service (CCaaS) or Customer Relationship Management (CRM) solutions. Example: Use Chatbots with your ticketing system, or use digital channels supported by Chatbots with your contact center solution.

This page explains how to integrate Chatbots with third-party CCaaS or CRM solutions. The integration uses the [Inbox API](https://www.infobip.com/docs/conversations-api), which is available free of charge with Chatbots.

To integrate Chatbots with the Inbox solution, see [Inbox](https://www.infobip.com/docs/inbox).

___

## Prerequisites

A translation layer that enables integration between the CCaaS solution and the Inbox API. The translation layer must be able to handle the state of the Chatbots session and the equivalent entity on the CCaaS solution — for example, interaction, ticket, or case.

The translation layer can be one of the following:

- Part of the CCaaS solution, when the CCaaS solution supports integration with the Inbox API
- A dedicated middleware application that enables integration between the CCaaS solution and the Inbox API

___

## Technical specifications

The following flow explains how to escalate a Chatbots session to an agent:

1. Inform the CCaaS solution that there is a conversation to handle.
2. Provide the conversation history and context to the CCaaS solution.
3. Deliver all new inbound messages to the CCaaS solution.
4. Enable the CCaaS solution to send outbound messages to the end user.
5. Close the Chatbots session.

### Infobip Inbox API

#### Mandatory APIs

The implementation uses the following mandatory APIs.

For account configuration

[Update Account Configuration](https://www.infobip.com/docs/api/customer-engagement/conversations/update-conversation-account-configuration)

This API subscribes to all inbound messages so that they can be transferred to the CCaaS solution.

This API does not support authentication. When subscribing to inbound messages, the resulting Post messages sent by Infobip do not include authentication credentials to gain access to the translation layer.

This API supports only one webhook configuration at a time. Overwriting a webhook removes the previous configuration.

To close a conversation

[Update Conversation](https://www.infobip.com/docs/api/customer-engagement/conversations/update-conversation)

This API enables a conversation to be closed when the agent has completed the interaction.

To obtain conversation history

<apidocslink href="customer-engagement/conversations/get-messages">Get Messages</apidocslink>

This API retrieves the history of the conversation so that it can be forwarded to the CCaaS solution.

To handle messages

<apidocslink href="customer-engagement/conversations/create-message">Create Message</apidocslink>

This API enables the translation layer to forward messages from the agent to the end user.

#### Optional APIs

The following optional APIs customize or improve the implementation.

To add context to a conversation

The following APIs add tags that provide context to the conversation. This helps the translation layer identify the relevant queue, language, or campaign in the CCaaS solution to which the conversation must be routed.

- <apidocslink href="customer-engagement/conversations/create-tag">Create Tag</apidocslink>
- <apidocslink href="customer-engagement/conversations/add-conversation-tag">Add Tag</apidocslink>
- <apidocslink href="customer-engagement/conversations/get-tags">Get Tags</apidocslink>

To handle metadata

The following APIs add metadata that provides context to the conversation for routing and prioritization. Use the relevant key:value pairs.

- <apidocslink href="customer-engagement/conversations/create-metadata">Put Metadata</apidocslink>
- <apidocslink href="customer-engagement/conversations/get-metadata">Get Metadata</apidocslink>

___

## Implementation

Carry out the instructions in each of the following sections.

### Set up to forward inbound messages

After the chatbot hands over the conversation to an agent, ensure new inbound messages are forwarded from the Inbox API to the CCaaS solution.

1. Configure the account (<apidocslink href="customer-engagement/conversations/update-conversation-account-configuration">Update Account Configuration</apidocslink>) to send all new inbound messages to the translation layer.
2. Configure the translation layer to store the authentication credentials for both Infobip and the CCaaS solution. This enables the translation layer to send and receive messages.

### Identify conversations that need external agents

Configure the chatbot to transfer the conversation to an agent.

1. On the Infobip [web interface](https://portal.infobip.com//), go to **Automation** > **Chatbots** and open your chatbot.
2. Create a new dialog to direct the end user to an agent when the chatbot cannot handle the inquiry.
3. In the new dialog, do the following:
    - Add an [**API**](https://www.infobip.com/docs/automation-studio/chatbots/chatbot-elements/core-elements#api) element to inform the translation layer that the specific ConversationID must be routed to an agent.
    - Add a [**To Agent**](https://www.infobip.com/docs/automation-studio/chatbots/chatbot-elements/core-elements#to-agent) element to end the Chatbots session and prevent the chatbot from responding to further messages from the end user.

To add context to the conversation, use tags and/or metadata. This helps the translation layer identify the relevant queue, language, or campaign in the CCaaS solution to which the conversation must be routed. Configure the chatbot to attach any required context to the conversation before it deploys the **To Agent** element.

IMPORTANT
The **To Agent** element ends the Chatbots session immediately.

### Hand over to agent

The translation layer receives the required information to pass the session from Chatbots (Inbox API) to the CCaaS solution. Configure the translation layer to do the following:

- Use <apidocslink href="customer-engagement/conversations/get-messages">Get Messages</apidocslink> to obtain the history. The history contains a maximum of 1,000 messages.
- (Optional) Obtain tags and/or metadata from the conversation.
- Route the session content to the CCaaS solution.
- Link the external entity and conversation ID.

### Handle the conversation

After the session has been handed over to the CCaaS solution, the Inbox API must forward all new inbound messages.

- Translation layer: The account configuration webhook (<apidocslink href="customer-engagement/conversations/update-conversation-account-configuration">Update Account Configuration</apidocslink>) enables the translation layer to receive and forward end user messages to the CCaaS solution.
- CCaaS solution: Do one of the following as applicable.
  - If the CCaaS solution has a webhook to subscribe to agent messages, subscribe to the messages.
  - If there is no webhook, the translation layer must poll the CCaaS solution to check whether the agent has sent new messages for open conversations.

### Close the conversation

Close the conversation to ensure the end user can start new conversations with the chatbot. Otherwise, the chatbot cannot receive the end user's messages. If the CCaaS solution also does not expect these messages, the messages could be lost.

After the agent closes the conversation or an equivalent entity (example: case, ticket, or interaction), the translation layer must use the <apidocslink href="customer-engagement/conversations/update-conversation">Update Conversation</apidocslink> API to close the conversation.
___
