Rate this page:

Custom channels: Chat2Desk

To connect the Chat2Desk channel, register a Voximplant Kit account or use an existing one. In this account, you need to create a custom channel and get an API token in the Integrations section. Also, you must have a Chat2Desk account where you need to generate an API token to work with the Chat2Desk API.

To integrate with Chat2Desk, you need to have a server that will proxy requests from Chat2Desk to Voximplant Kit and from Voximplant Kit to Chat2Desk.

Chat2Desk connection

Copy URL

To get API_TOKEN to use the Chat2Desk API, go to your Personal Account in the Settings section, then the API section and click Show.

Chat2Desk

To receive messages about new events from Chat2Desk, you need to set Callback URL. To do this, you need to make the following HTTP request:

Request

Request

YOUR_API_TOKEN - API token to work with Chat2Desk

API YOUR_SERVER_HOST - Host where your server will be accessible

Voximplant Kit connection

Copy URL

It is necessary to specify a separate server callback URL for Voximplant Kit in the custom channel settings, so Voximplant Kit will send its events to this callback URL:

Callback URL

PHP integration

Copy URL

For this integration, we need the following components:

  1. Configuration with details from accounts
  2. HTTP client for working with API Voximplant Kit
  3. HTTP client for working with API Chat2Desk
  4. Database for storing information and chats
  5. Voximplant Kit HTTP request handler
  6. HTTP request handler from Chat2Desk

Let's start with the application configuration. For configuration, we use the dotenv extension. An example of an .env file with configuration data:

.env

.env

KIT_ACCOUNT_NAME - The name of your Kit account.

KIT_API_TOKEN - API token for authentication in the Voximplant Kit service, can be obtained in the integration section.

KIT_CHANNEL_UUID - Channel UUID of custom channel in Voximplant Kit. You can get the channel UUID in the custom channel settings in the uppermost Channel UUID field.

CHAT2DESK_API_TOKEN - API token for authentication in the Chat2Desk service.

Next, let us initialize the HTTP client for the Voximplant Kit API:

/config.php

/config.php

To work with the Voximplant Kit IM API, we use the SDK, its description can be found here.

Next, we initialize the HTTP client to work with the Chat2Desk API in the same config.php file:

/config.php

/config.php

The description of the “Chat2DeskClient” class can be found at the link given at the end of this article.

Next, we initialize the component for storing information about chats:

/config.php

/config.php

A description of the "Repository" class can be found at the link given at the end of this article.

Next, we initialize the service that will process events from Chat2Desk and Voximplant Kit:

Initialize a service to process events from Chat2Desk to Voximplant Kit

Initialize a service to process events from Chat2Desk to Voximplant Kit

Here are some code snippets from the Service.php class for event handling. Event handling from Voximplant Kit:

Handle events from Voximplant Kit

Handle events from Voximplant Kit

Handling events from Chat2Desk:

Handle events from Chat2Desk

Handle events from Chat2Desk

Next, let's start writing our server that will process HTTP requests from Chat2Desk and Voximplant Kit.

First of all, you need to authenticate in Voximplant Kit and then start the HTTP request handlers from Chat2Desk and Voximplant Kit.

/app.php

/app.php

Request handler from chat2desk-incoming:

Process Chat2Desk requests

Process Chat2Desk requests

Voximplant Kit Request Processor:

Process Voximplant Kit requests

Process Voximplant Kit requests

When creating a custom channel, Voximplant Kit sends a test GET request to the specified callback URL. Let's add a handler for a test request from Voximplant Kit:

Handle a test request

Handle a test request

Additional information

Copy URL