Skip to main content

Transaction Alert Call

This example shows how to make a transaction alert call 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 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

parameterTypeDescription
app_idnumberYour app Id provided by Piopiy TeleCMI platform.
app_secretstringYour app secret provided by Piopiy TeleCMI platform.
music_filestringThe music file or music file URL of the alert music file to be played.
customer_numbernumberThe phone number of the customer receiving the call, including the country code.
piopiy_numbernumberThe 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
}

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.