
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
PIOPIY REST API client for nodejs,It support Voice,SMS,WhatsApp and MLAudio.
Piopiy API provides a comprehensive Node.js SDK for managing and controlling voice interactions using our PCMO Actions. This SDK allows developers to integrate voice functionalities such as making calls, playing audio, recording, Real Time Streaming and more into their Node.js applications.
The API requires an API Key and Secret for authentication, passed during the initialization of the Piopiy
object.
piopiy
npm packageTo use the Piopiy API, install the piopiy
package from npm:
npm install piopiy
Here’s a basic example of how to use the Piopiy API:
const {Piopiy, PiopiyAction} = require("piopiy");
const piopiy = new Piopiy("your appid", "your app token");
//Call two number with custom caller id
const basic_call = async () => {
const response = await piopiy.voice.call(
"first_phone_number",
"piopiy_callerid",
"second_phone_number",
{loop: 1, timeout: 40, duration: 30}
);
};
basic_call();
//Call and perform PCMO action
var action = new PiopiyAction();
action.playGetInput(
"https://example.com/webhook/dtmf",
"https://example.com/your_audio_file.wav",
{max_digit: 3, max_retry: 2}
);
const pcmo_call = async () => {
const response = await piopiy.voice.call(
"dest_phone_number",
"piopiy_callerid",
action.PCMO(),
{loop: 1, timeout: 40, duration: 30}
);
};
pcmo_call();
The call() method in the Piopiy Node.js SDK is designed to handle different types of call interactions. It supports connecting two numbers, handling multiple numbers, and executing PCMO (PIOPIY Call Management Object) actions during a call.
To initiate a call between two numbers:
const basic_call = async () =>{
const res = await piopiy.voice.call(9194xxxxxx, 9180xxxxxx, 9180xxxxxx, {duration: 30,timeout: 40,loop: 1,record: true})
}
basic_call()
To make a call and perform specific PCMO actions, such as playing an audio file:
const test = new PiopiyAction();
action.playMusic('https://example.com/your_music_file.wav');
const pcmo_call = async () =>{
const res = await piopiy.voice.call(9194xxxxxx,9180xxxxxx,action.PCMO(),{duration: 30,timeout: 40,loop: 1,record: true})
}
pcmo_call()
To stream audio during a call using WebSocket:
const test = new PiopiyAction();
test.stream("wss://your-websocket-url/webhook/stream",{ listen_mode: "callee", voice_quality:"8000", stream_on_answer: true});
const ai_stream = async () => {
const res = await piopiy.voice.call(9194xxxxxx,9180xxxxxx,test.PCMO(),{duration: 30,timeout: 40,loop: 1,record: true})
}
ai_stream()
To attempt connecting a call to multiple numbers sequentially:
const multi_call = async () => {
const res = await piopiy.voice.call(9194xxxxxx,9180xxxxxx,[9180xxxxx, 9196xxxx],{duration: 30,timeout: 40,loop: 1,record: true})
}
multi_call()
options
(Object) - Optionalduration
(Number): Maximum call duration in seconds.timeout
(Number): Time in seconds to wait for each call to be answered.loop
(Number): Number of retry attempts for each call.record
(Boolean): Whether to record the call.The PCMO is a powerful tool that enables you to define specific actions to be executed during a call. These actions can include playing audio files, collecting user input, speaking text, and more.
To use PCMO, you need to create an instance of the PiopiyAction
class and define the actions you want to perform. Once defined, these actions can be passed to the call()
method to be executed during the call.
const {Piopiy, PiopiyAction} = require("piopiy");
// Initialize Piopiy with your API Key and Secret
const piopiy = new Piopiy("YOUR_API_KEY", "YOUR_API_SECRET");
var action = new PiopiyAction();
Playing Audio
action.playMusic("https://example.com/your_music_file.wav");
Collecting DTMF Input
action.playGetInput(
"https://example.com/webhook/dtmf",
"https://example.com/your_audio_file.wav",
{max_digit: 3, max_retry: 2}
);
Text-to-Speech
action.speak("Hello, Welcome to Telecmi");
Setting Custom Values
action.setValue("name");
Collecting Input
action.input("https://example.com/action", {
timeout: 20,
max_digit: 4,
min_digit: 2,
});
Recording the Call
action.record();
Ending the Call
action.hangup();
Connecting to Other Numbers
action.call(9198xxxxxx, [9180xxxx, 9180xxxx], { duration: 10, timeout: 20, loop: 2, record: true });
Clearing Actions
action.clear();
After defining the desired actions, use the action.PCMO()
method to pass them to the call()
method
const pcmo_call = async () =>{
const res = await piopiy.voice.call(9194xxxxxx,9180xxxxxx,action.PCMO(),{duration: 30,timeout: 40,loop: 1,record: true})
}
pcmo_call()
playMusic(audioFileOrUrl)
audioFileOrUrl
(String): The URL or path to the audio file to be played.playGetInput(url, audioFileOrUrl, options)
url
(String): The URL to send the DTMF input to.audioFileOrUrl
(String): The URL or path to the audio file to be played.options
(Object): Optional settings:
max_digit
(Number): Maximum number of digits to capture.max_retry
(Number): Number of retry attempts.speak(text)
text
(String): The text to convert to speech.setValue(key)
key
(String): The key name for the value to set.input(url, options)
url
(String): The URL to send the input data to.options
(Object): Optional settings:
timeout
(Number): Time in seconds to wait for input.max_digit
(Number): Maximum number of digits to collect.min_digit
(Number): Minimum number of digits to collect.record()
hangup()
call(from, to, options)
from
(Number): The caller's phone number.to
(Number | Array): A single receiver's phone number or an array of phone numbers.options
(Object): Optional settings:
duration
(Number): Maximum call duration in seconds.timeout
(Number): Time to wait for each call to be answered.loop
(Number): Number of retry attempts for each number.record
(Boolean): Whether to record the call.clear()
stream(url, options)
url
(String): The WebSocket URL to stream the audio.options
(Object): Optional settings:
listen_mode
(String): Specifies whose audio is streamed. Options: 'caller'
, 'callee'
, or 'both'
.voice_quality
(String): The audio quality. Options: '8000'
, '16000'
.stream_on_answer
(Boolean): Whether to start streaming only when the call is answered. Default is true
.FAQs
PIOPIY REST API client for nodejs,It support Voice,SMS,WhatsApp and MLAudio.
The npm package piopiy receives a total of 30 weekly downloads. As such, piopiy popularity was classified as not popular.
We found that piopiy demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.