Custom Telephony Starter Kit

Use the Custom Telephony Starter Kit to integrate SendPulse’s CRM system with any third-party telephony solution. It offers ready-to-use routes and PHP examples using Laravel. The kit also includes Docker to speed up deployment and the https://packagist.org/packages/sendpulse/market-rest-api package to interact with SendPulse tools.

This article will walk you through how to set up and get started with the Custom Telephony Starter Kit.

Environment requirements

The development environment must support PHP version 8.2 or higher. You can install dependencies using Composer.

Learn more: Introduction to Composer.

To maintain state and manage queues, we recommend configuring a dedicated database. You can handle local deployment with containers and a database via Docker and Docker Compose.

Before getting started, create an .env environment file in the project root and add your Marketplace application credentials, SENDPULSE_APP_ID and SENDPULSE_APP_SECRET, along with the URL to handle calls and webhooks.

Authentication

To integrate your app, you need to contact SendPulse support and provide the following application details:

  • Application name,
  • Application ID,
  • Application icon in PNG format, 64x64 px,
  • URL for call initiation.

The sendpulse/market-rest-api package encapsulates the entire authorization flow within the SendPulse Marketplace.

The install route is already implemented in the project and retrieves a code from the Marketplace using it to generate a request with the provided SENDPULSE_APP_ID and SENDPULSE_APP_SECRET.

In response, the integration receives a client_id and client_secret, which are then exchanged for the user's application access token.

Learn more: User authorization flow.

Call initiation route

After initiating a call, send a POST request to the /custom-telephony/call route to pass CRM data to the telephony solution and create the call.

Request parameters:

integrationId number Solution integration ID.
phone string Phone number in the international format.

Request body example in JSON format:

{
  "integrationId": 123,
  "phone": "+380631234567"
}

A successful server response returns the 200 OK status.

Webhook handling

Specify the set of parameters that the CRM system must process for call start, call end, and missed call events, and pass them to the /custom-telephony/webhooks route.

These parameters may vary depending on the telephony solution and may include:

call_id string Unique call ID.
event string Call start or call end event.
type string Incoming or outgoing call type.
phone string Phone number in the international format.
duration number Call duration.
is_success boolean Call initiation status.
token string Webhook authorization token.

When the CRM system receives a missed call event, it creates a task. Call end events trigger the pop-up to close.

Starter Kit and project structure

The main Custom Telephony Starter Kit PHP files are located in the app/ directory, which contains the Models, Controllers, Requests, and Repositories subdirectories.

The main routes are defined in the routes/web.php and routes/api.php files. The /api/boards API endpoint returns a list of boards in JSON format to test authentication and basic REST features.

Uninstalling the app

In the app uninstall process, a POST request to the /custom-telephony/uninstall route is sent and the app user is removed.

Learn more: Uninstall flow.

    Rate this article about "Custom Telephony Starter Kit"

    User Rating: 5 / 5 (9)

    Popular in Our Blog

    Try SendPulse today for free