Making a Basic Call
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, it will be connected to the agent’s number.
- Node.js
- Python
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 } = require("piopiy");
const piopiy = new Piopiy("your_app_id", "your_app_secret");
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 };
const basic_call = async () => {
const res = await piopiy.voice.call( customer_number, piopiy_number, agent_number, options )
}
basic_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/basic.js
7. Make an Outgoing Call
Once everything is set up, server is started,the call will be received for the customer’s number. When the customer answers the call, it 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 Python example from our TeleCMI GitHub repository.
git clone https://github.com/telecmi/piopiy_python_example.git
First, clone this repository to your local machine:
cd piopiy_python_example
3.Install the required packages
Once inside the project directory, create a virtual environment and install the required packages:
python -m venv venv
source venv/bin/activate # On Windows, use `venv\Scripts\activate`
pip install -r requirements.txt
4.Code
from piopiy import RestClient
def main():
# Initialize the RestClient with your appid and app token
piopiy = RestClient("your_appid", "your_app_token")
try:
agent_number = "Your agent phone number" # Your agent phone number with country code.
piopiy_number = "Your piopiy number" # Your Piopiy number provided by the Piopiy TeleCMI platform.
customer_number = "Your customer number" # Your customer phone number with country code.
# Options for the call
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
}
# Make the call
response = piopiy.voice.call(customer_number, piopiy_number, agent_number, options)
print('Call connected, answer URL:', response)
except Exception as error:
print('Error:', error)
if __name__ == '__main__':
main()
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 Python:
python sdk_example/outbound_call/basic.py
7. Make an Outgoing Call
Once everything is set up, server is started,the call will be received for the customer’s number. When the customer answers the call, it will be connected to the agent’s number.