Skip to main content

Delivery Agent to Customer

This example shows how to make a call from a delivery agent to a customer using a call masking number with 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 call_masking directory:

cd call_masking

And open the delivery_agent_to_customer.js file:

delivery_agent_to_customer.js

3. Configure the call parameters

Replace the value in the Delivery agent to customer code with your actual values for

  • app_id & app_secret

  • delivery_agent_number

  • call_masking_number

  • customer_number

Replace the placeholders in the code with your actual values:

const { Piopiy } = require("piopiy");
const piopiy = new Piopiy("app_id", "app_secret");

const delivery_agent_number = "Your delivery agent number"; // Example delivery agent phone number
const call_masking_number = "Your call masking number"; // Example call masking number
const customer_number = "Your customer number"; // Example customer phone number
const options = { duration: 15, timeout: 25, loop: 2 };

const pcmo_call = async () =>{

const res = await piopiy.voice.call( 'delivery_agent_number', 'call_masking_number', 'customer_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.
delivery_agent_numbernumberThe phone number of the agent receiving the call, including the country code.
call_masking_numbernumberThe call masking number provided by the Piopiy TeleCMI platform.
customer_numbernumberThe phone number of the customer being called, including the country code.
optionsobjectAn object containing optional parameters (duration, timeout & loop).

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.

4. Run the code

Execute the code using Node.js:

node call_masking/delivery_agent_to_customer.js

5. Expected call flow

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

1. Initial call to Delivery agent: The call is initiated to the delivery agent's number first.

2. Delivery agent answers call: Once the agent answers the call, the call will automatically connect to the customer's number.

You can handle these steps programmatically using the Piopiy package. Ensure that your app_id & app_secret are correctly configured, and the delivery_agent_number, call_masking_number, and customer_number provided are valid.

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.