Rate this page:

Custom channels: Intercom

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. For more information, go 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

Copy URL

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.

  1. Create a new application. Select the workspace where the application will run.
  2. After you create a new application, go to the Authentication section, there you can find the Access Token.
  3. Go to the Webhooks section. Enter your endpoint URL in the appropriate field.
  4. In the Webhook topics section, select conversation.user.created conversation.user.replied. You can add more topics but the above should be mandatory.

Voximplant Kit connection

Copy URL

Specify a callback URL of the server for Voximplant Kit in the custom channel settings to allow Voximplant Kit to send its events to this URL.

PHP integration

Copy URL

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:
Scenario code

Scenario code

KIT_ACCOUNT_NAME - 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.

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.

Now initialize the HTTP client to work with Intercom API in the same config.php file:

/config.php

/config.php

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:

/config.php

/config.php

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

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

/config.php

/config.php

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:

app.php

app.php

Intercom request handler:

app.php

app.php

Voximplant Kit 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

Copy URL