Skip to main content

Outbound Dialer

This example shows how to make an outbound dialer using the Piopiy package.

Steps to run the code

1. Prerequisites

Before you start, ensure you have the following:

2. Clone Repository

First, clone the repository by running the following command:

git clone https://github.com/telecmi/piopiy_node_example.git

Next, navigate to the outbound_dialer directory:

cd outbound_dialer

And open the dialer_call.js file:

dialer_call.js

3. Configure the call parameters

Replace the value in the Outbound Dialer code with your actual values for

  • app_id & app_secret

  • customer_number

  • piopiy_number

  • multiple_agent_number

4. Run the code

Execute the code using Node.js:

node outbound_dialer/dialer_call.js

5. Expected call flow

When the code is executed, the call will follow these steps:

1. Initial Call to Customer: The call is initiated to the customer's number first.

2. Customer Answers Call: Once the customer answers the call, the call is routed to one of the agent numbers.

You can handle these steps programmatically using the Piopiy package. Ensure that your app_id & app_secret, customer_number, piopiy_number, and multiple_agent_number provided are valid.

Example usage

Replace the placeholders in the code with your actual values:

const { Piopiy } = require("piopiy");
const piopiy = new Piopiy("your_app_id", "your_app_secret");

const customer_number = "Your customer number"; // Your customer phone number with country code.
const piopiy_number = "Your piopiy number"; // Your piopiy number provided by the Piopiy TeleCMI platform.
const multiple_agent_number = ["Your agent phone number", "Your agent phone number"]; // Multiple agent's phone number with country code.
const options = {
duration: 10, // (Optional) Maximum duration of the call in seconds.
timeout: 20, // (Optional) Time to wait for the call to be answered.
loop: 1, // (Optional) Number of retry attempts if the call is not answered.
ring_type: "group", // (Optional) Type of ringing for the call.
};

const pcmo_call = async () =>{
const res = await piopiy.voice.call( customer_number, piopiy_number, multiple_agent_number, options )
}

pcmo_call()

Parameters type and description

These are the list of parameters and its description

Main Parameters

parameterTypeDescription
app_idnumberYour app Id provided by Piopiy TeleCMI platform.
app_secretstringYour app secret provided by Piopiy TeleCMI platform.
customer_numbernumberThe phone number of the customer being called, including the country code.
piopiy_numbernumberThe piopiy number provided by the Piopiy TeleCMI platform.
multiple_agent_numberarrayAn array of phone numbers for multiple agents, including country codes.
optionsobjectAn object containing optional parameters (duration, timeout, loop & ring_type).

Options Parameters

parameterTypeDescription
durationnumberThe maximum duration of the call in seconds,By default 5400 seconds.
timeoutnumberTime to wait for the call to be answered in seconds,By default 40 seconds.
loopnumberThe number of retry attempts if the call is not answered,By default 1.
ring_typestringThe type of ringing for the call. By default, it is single, where agents receive calls one by one. If set to group, all agents will receive calls simultaneously.

Sample response

Below is the following sample call response.


{
"data": { "status": 'progress' },
"status": 'progress',
"request_id": 'X0uoi5LT5vCMOG6CZGEdMMYD5RL9raaEFa1p1IQ9EVm',
"cmi_code": 200
}

Properties

These are the list of properties and its description

PropertyTypeDescription
statusstringThe Status of the call.
request_idstringThe Unique ID for this call.

HTTP status codes

cmi_codecmi_code typeDescription
200SuccessWe received the request.
401ErrorAuthentication failed.