@parloa/twilio-helper-package
v1.0.5
Published
Library to generate calls via twilio API
Downloads
77
Maintainers
Keywords
Readme
Overview
This package is a Node.js library designed to facilitate the generation of calls using the Twilio API. It provides functions for creating and managing Twilio calls, allowing developers to easily integrate Twilio functionality into their applications.
Requirements
An npm account in the Parloa org. Make sure you are logged in with npm login.
Installation
To install the package, use the following command:
npm install @parloa/twilio-helper-package
Usage
- Importing the Package
const twilioHelper = require('@parloa/twilio-helper-package');
- Making a Twilio Call
const options = {
accountSid: 'your_account_sid',
authToken: 'your_auth_token',
fromNumber: 'your_twilio_phone_number',
toNumber: 'destination_phone_number',
textToPlay: 'text_to_say_or_mp3_url',
seconds: 5, // duration of pauses in seconds
twiMLType: 'sayAndPause', // or 'mp3'
};
twilioHelper.makeTwilioCall(options)
.then(callSid => {
console.log(`Twilio call initiated with Call SID: ${callSid}`);
})
.catch(error => {
console.error(`Error: ${error.message}`);
});
- Adding Parts to an Existing Twilio Call
const { accountSid, authToken, callSid } = options; // reuse options or provide necessary values
const ssml = '<speak>additional_text_to_say</speak>';
twilioHelper.addPartToTwilioCall(accountSid, authToken, callSid, ssml, 3)
.then(updatedCallSid => {
console.log(`Twilio call updated with additional part. Updated Call SID: ${updatedCallSid}`);
})
.catch(error => {
console.error(`Error: ${error.message}`);
});
- Waiting for a Call to Complete
twilioHelper.waitForCallToComplete(accountSid, authToken, callSid)
.then(completedCall => {
console.log(`Twilio call completed. Final Call Status: ${completedCall.status}`);
})
.catch(error => {
console.error(`Error: ${error.message}`);
});
Publishing new version
- Make the required changers and merge to main branch (Make sure to increase the version in
package.json
) - Login to npm registry
- Run
npm publish
- Go to package page to check that the package version has been updated