Outbound Dialer
This example shows how to make an outbound dialer using the Piopiy package.
- Node.js
- Python
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
parameter | Type | Description |
---|---|---|
app_id | number | Your app Id provided by Piopiy TeleCMI platform. |
app_secret | string | Your app secret provided by Piopiy TeleCMI platform. |
customer_number | number | The phone number of the customer being called, including the country code. |
piopiy_number | number | The piopiy number provided by the Piopiy TeleCMI platform. |
multiple_agent_number | array | An array of phone numbers for multiple agents, including country codes. |
options | object | An object containing optional parameters (duration, timeout, loop & ring_type). |
Options Parameters
parameter | Type | Description |
---|---|---|
duration | number | The maximum duration of the call in seconds,By default 5400 seconds. |
timeout | number | Time to wait for the call to be answered in seconds,By default 40 seconds. |
loop | number | The number of retry attempts if the call is not answered,By default 1. |
ring_type | string | The 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
}
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_python_example.git
Next, navigate to the outbound_dialer directory:
cd outbound_dialer
And open the dialer_call.py file:
dialer_call.py
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 Python:
python outbound_dialer/dialer_call.py
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:
from piopiy import RestClient
def make_call():
# Initialize RestClient with your API Key and Secret
piopiy = RestClient("your_app_id", "your_app_secret")
customer_number = "Customer number" # Your customer phone number with country code
piopiy_number = "Your piopiy number" # Your piopiy number provided by the Piopiy TeleCMI platform
multiple_agent_number = ["Your agent phone number", "Your agent phone number"] # Multiple agent's phone numbers with country code
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
}
try:
# Make the call
response = piopiy.voice.call(customer_number, piopiy_number, multiple_agent_number, options)
print('Success response:', response)
except Exception as error:
print('Error:', error)
if __name__ == '__main__':
make_call()
Parameters type and description
These are the list of parameters and its description
Main Parameters
parameter | Type | Description |
---|---|---|
app_id | number | Your app Id provided by Piopiy TeleCMI platform. |
app_secret | string | Your app secret provided by Piopiy TeleCMI platform. |
customer_number | number | The phone number of the customer being called, including the country code. |
piopiy_number | number | The piopiy number provided by the Piopiy TeleCMI platform. |
multiple_agent_number | array | An array of phone numbers for multiple agents, including country codes. |
options | object | An object containing optional parameters (duration, timeout, loop & ring_type). |
Options Parameters
parameter | Type | Description |
---|---|---|
duration | number | The maximum duration of the call in seconds,By default 5400 seconds. |
timeout | number | Time to wait for the call to be answered in seconds,By default 40 seconds. |
loop | number | The number of retry attempts if the call is not answered,By default 1. |
ring_type | string | The 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
Property | Type | Description |
---|---|---|
status | string | The Status of the call. |
request_id | string | The Unique ID for this call. |
HTTP status codes
cmi_code | cmi_code type | Description |
---|---|---|
200 | Success | We received the request. |
401 | Error | Authentication failed. |