Transaction Alert Call
This example shows how to make a transaction alert call 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 transaction_alert_call directory:
cd transaction_alert_call
And open the alert_call.js file:
alert_call.js
3. Configure the call parameters
Replace the value in the Transaction alert call
code with your actual values for
-
app_id & app_secret
-
music_file
-
customer_number
-
piopiy_number
Replace the placeholders in the code with your actual values:
const { Piopiy, PiopiyAction } = require("piopiy");
const piopiy = new Piopiy("your_app_id", "your_app_secret");
const action = new PiopiyAction();
const music_file = "Your example music file or music file URL"; // Example alert music file or music file URL
const customer_number = "Your customer number"; // Example customer phone number
const piopiy_number = "Your piopiy number"; // Example piopiy number
const alert_music_pcmo_function = action.PCMO(); // Use this PCMO function to play your alert music.
const options = { duration: 15, timeout: 25, loop: 2 };
action.playMusic(music_file);
const pcmo_call = async () =>{
const res = await piopiy.voice.call( customer_number, piopiy_number, alert_music_pcmo_function, options )
}
pcmo_call()
Parameters type and description
These are the list of parameters and its description
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. |
music_file | string | The music file or music file URL of the alert music file to be played. |
customer_number | number | The phone number of the customer receiving the call, including the country code. |
piopiy_number | number | The piopiy number provided by the Piopiy TeleCMI platform. |
4. Run the code
Execute the code using Node.js:
node transaction_alert_call/alert_call.js
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 transaction_alert_call directory:
cd transaction_alert_call
And open the alert_call.py file:
alert_call.py
3. Configure the call parameters
Replace the value in the Transaction alert call
code with your actual values for
-
app_id & app_secret
-
music_file
-
customer_number
-
piopiy_number
4. Run the code
Execute the code using Python:
python transaction_alert_call/alert_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, alert music is played to notify them of the transaction.
You can handle these steps programmatically using the Piopiy package. Ensure that your app_id & app_secret are correctly configured, and the music_file, customer_number and piopiy_number provided are valid.
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. |