Skip to main content

Making a Call with PCMO Actions

First you've completed the initial setup, the most important step is to But a PIOPIY number. Once the number is configured and the server is started,the call will be received for the customer’s number. When the customer answers the call, the system will first play the configured music, and then the call will be connected to the agent’s number.

1.Prerequisites

Before you start, ensure you have the following:

2.Clone the repository

Use the git clone command to clone the PIOPIY node from our TeleCMI github repository.

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

First, clone this repository to your local machine:

cd piopiy_node_example

3.Install the piopiy npm package

Once inside the project directory, install the required npm packages:

npm install

4.Code

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

const action = new PiopiyAction();

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 agent_number = "Your agent phone number"; // Your agent phone number with country code.
const options = { duration: 10, timeout: 20, loop: 1, record: true };

action.playMusic('https://example.com/your_music_file.wav');

action.call(agent_number, piopiy_number, options);

const pcmo_function = action.PCMO(); // PCMO actions to execute during the call

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

pcmo_call()

5.Configure the call parameters

Replace the value in the Basic Call code with your actual values for

6.Run the code

Execute the code using Node.js:

node sdk_example/outbound_call/call_with_pcmo.js

7. Make an Outgoing Call with PCMO

Once everything is set up, server is started,the call will be received for the customer’s number. When the customer answers the call, the system will first play the configured music, and then the call will be connected to the agent’s number.