Inbound Call Center
- 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 inbound_call_center directory:
cd inbound_call_center
And open the inbound_call.js file:
inbound_call.js
3. Configure the call parameters
Replace the value in the Inbound Call Center
code with your actual values for
-
agent_phone_number
-
piopiy_callerid
const express = require("express");
const { PiopiyAction } = require("piopiy");
const app = express();
app.use(express.json());
app.post("/inbound-call", (req, res) => {
const action = new PiopiyAction();
const agent_phone_number = ["agent_phone_number", "agent_phone_number", "agent_phone_number"]; // Multiple agent's phone number with country code
const piopiy_callerid = "piopiy_callerid"; // 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
ring_type: "group", // (Optional) Type of ringing for the call.
};
action.call(agent_phone_number, piopiy_callerid, options);
res.send(action.PCMO());
});
app.listen(3001, () => {
console.log("Server is running on port 3001");
});
4. Run the code
Execute the code using Node.js:
node inbound_call_center/inbound_call.js
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 inbound_call_center directory:
cd inbound_call_center
And open the inbound_call.py file:
inbound_call.py
3. Configure the call parameters
Replace the value in the Inbound Call Center
code with your actual values for
-
agent_phone_number
-
piopiy_callerid
from piopiy import RestClient
def make_call():
# Initialize RestClient with your App ID and Secret
piopiy = RestClient("your_app_id", "your_app_secret")
piopiy_callerid = "piopiy_callerid" # Your piopiy number provided by the Piopiy TeleCMI platform
agent_phone_number = ["agent_phone_number", "agent_phone_number", "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(agent_phone_number, piopiy_callerid, options)
print('Success response:', response)
except Exception as error:
print('Error:', error)
if __name__ == '__main__':
make_call()
4. Run the code
Execute the code using Python:
python inbound_call_center/inbound_call.py
Here’s an explanation of each parameter in the PIOPIY:
Parameter | Value | Required | Data Type | Description |
---|---|---|---|---|
your_app_id | 2222XXX | Yes | string | This refers to the Application ID provided by PIOPIY. Used to identify which application is making the call. |
your_app_secret | ab4cbb8e-xxx-xxxx-xxxx-xxxxxxxxxxx | Yes | string | This is the APP Secret provided by PIOPIY. It authenticates and authorizes the call, ensuring only authorized apps initiate calls. |
agent_phone_number | 9198765xxxxx | Yes | number | This is the agent phone number you want to connect. Typically, it's the number of the person or agent receiving the call. |
piopiy_callerid | 9180314xxxxx | Yes | number | This is the Caller ID shown to the second participant. Can be a virtual number provided by PIOPIY. |
5. 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://customer.to.delivey.agent.ngrok.io.
6. Configure Piopiy dashboard
Log in to your Piopiy dashboard and paste the ngrok URL into the "Answer URL" input field. Ensure that the endpoint is set correctly to handle inbound calls.
https://customer.to.delivey.agent.ngrok.io/inbound
7. Expected Call Flow
When the code is executed, the call will follow these steps:
1.Initial call to Call Masking Number: The call is initiated from the customer to the call masking number.
2.Call received by Delivery Agent: The delivery agent receives the call via the call masking number.