Skip to main content

Making a Basic Call

First you've completed the initial setup, the most important step is to But a PIOPIY number. After configuring the number, the customer can initiate a call to the PIOPIY number, and the call will be directed to the assigned agent for response.

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 express = require("express");
const { PiopiyAction } = require("piopiy");
const app = express();
app.use(express.json());

app.post("/basic", (req, res) => {
const action = new PiopiyAction();
const agent_number = "Your agent phone number"; // Your agent's phone number with country code
const piopiy_number = "Your piopiy number"; // Your piopiy number provided by the Piopiy TeleCMI platform.

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
record: true, // (Optional) Whether to record the call
};

action.call(agent_number, piopiy_number, options);
res.send(action.PCMO());
});

app.listen(3001, () => { console.log(`Server is running on port 3001`) })

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/inbound_call/basic.js

7.Create a public URL using ngrok​

To expose your local server to the internet, use ngrok to create a public URL:

ngrok http 3001

Copy the URL provided by ngrok. This URL will look something like https://inbound.basic.call.ngrok.io.

8. Configure the Answer URL​

Enter the ngrok URL into the answer URL field. For example, if your ngrok URL is https://inbound.basic.call.ngrok.io, set the answer URL to:

https://inbound.basic.call.ngrok.io/basic

Then click the MAP APP button to configure it successfully.

answer url

9. Make an Incoming Call​

Once everything is set up, have the customer make an incoming call to receive the call on the agent's number.