1.0.5 • Published 3 months ago

@parloa/twilio-helper-package v1.0.5

Weekly downloads
-
License
UNLICENSED
Repository
github
Last release
3 months ago

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

  1. Importing the Package

const twilioHelper = require('@parloa/twilio-helper-package');

  1. 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}`);
  });
  1. 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}`);
  });
  1. 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

  1. Make the required changers and merge to main branch (Make sure to increase the version in package.json)
  2. Login to npm registry
  3. Run npm publish
  4. Go to package page to check that the package version has been updated
1.0.5

3 months ago

1.0.4

4 months ago

1.0.3

5 months ago

1.0.2

5 months ago

1.0.1

6 months ago

1.0.0

6 months ago