Rate this page:

Custom channels. Intercom channel connection

To connect the Intercom 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. More details can be found here. Also, you must have an Intercom account where you need to generate an API token to work with the Intercom API. To integrate with Intercom, you need to have a server that will proxy requests from Intercom to Voximplant Kit and vice versa.

Intercom connection

Before we start creating a server, you need to connect the intercom and set the callback URL of the server in your personal account, where Intercom will send its events. To do this, go to the developer hub at Intercom. Create a new application. Select the workspace where the application will run:

After creating a new application, go to the Authentication section, there you can find the Access Token:

After that, you need to go to the Webhooks section. Enter your endpoint URL in the appropriate field.

In the Webhook topics section, you must select: conversation.user.created conversation.user.replied You can add more topics, but the above should be mandatory.

Voximplant Kit connection

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

PHP integration

For integration, we need the following components:

  1. Configuration with details from accounts
  2. HTTP client for working with API Voximplant Kit
  3. HTTP client to work with Intercom API
  4. Database for storing information and chats
  5. HTTP request handler from Voximplant Kit
  6. Intercom HTTP request handler Let's start with the application configuration. For configuration, we use the dotenv extension. Example .env file with configuration data:
File: .env

File: .env

KIT_ACCOUNT_NAME is the name of your Voximplant 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.

INTERCOM_API_TOKEN - API token for authentication in the Intercom service.

INTERCOM_ADMIN_ID - This is the ID of the admin in the Intercom, used as an agent when replying to a message.

Next, we initialize the HTTP client for the Voximplant Kit IM API:

Initialize the HTTP client

Initialize the HTTP client

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 Intercom API in the same config.php file:

File: /config.php

File: /config.php

Part 1

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

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

File: /config.php

File: /config.php

Part 2

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

Next, we initialize the service that will process events from Intercom and Voximplant KIT:

File: /config.php

File: /config.php

Part 3

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

Handle events from Voximplant Kit

Handle events from Voximplant Kit

Event handling from intercom:

Handle events from Intercom

Handle events from Intercom

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

First of all, it is necessary to pass authentication in Voximplant Kit and then start HTTP request handlers from Intercom and Voximplant Kit:

File: app.php

File: app.php

Part 1

Intercom request handler:

File: app.php

File: app.php

Part 2

Voximplant KIit request processor:

Process requests

Process 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