GithubHelp home page GithubHelp logo

isabella232 / realtimedb-helpers Goto Github PK

View Code? Open in Web Editor NEW

This project forked from frisb/realtimedb-helpers

0.0 0.0 0.0 246 KB

utility functions for querying jambonz redis database

JavaScript 100.00%

realtimedb-helpers's Introduction

jambonz-realtimedb-helpers CI

A set of helper functions to access data in the jambonz in-memory database (currently implemented using redis).

This module exposes a function that should be called with redis configuration options and, optionally, a pino logger function. It then returns an object containing various useful functions for accessing and updating the database.

const opts = {
  "host": "localhost",
  "port": 3279
};
const logger = require('pino')();
const {updateCallStatus} = require('jambonz-realtimedb-helpers')(opts, logger);

Functions

  • updateCallStatus - adds or updates the call status for a given call identified by call Sid.
  • retrieveCallInfo - retrieves the call data for a call.
  • listCallInfo - retrieves all the calls for a given account
  • deleteCall - removes call data for a call.
  • purgeCalls - removes call data for all calls that completed some time ago.
  • synthAudio - retrieves generated tts audio from cache, or generates it

updateCallStatus

updateCallStatus(callInfo, serviceUrl)

returns a Promise yielding a boolean indicating success or failure of the operation.

Adds or updates the information about a call. The callInfo object must contain (at least) the following properties:

property description
callSid the Call Sid for this call
callId the SIP Call-ID
sipStatus the most recent sip status - a value of 100 means this is a new call that should be added
callStatus one of 'trying', 'ringing', 'early-media', 'in-progress', 'completed', 'failed', 'busy', 'no-answer', or 'queued'

Additionally, the serviceUrl parameter is required if the sipStatus is 100 (i.e. a new call). It must contain the service endpoint of the specific feature-server instance that is controlling this call.

When a call reaches a final state ('completed', 'failed', 'busy', or 'no-answer') the associated call data will be purged one hours later. This database is intended only to be used for live call information.

retrieveCallInfo

retrieveCallInfo(accountSid, callSid)

returns a Promise yielding the call information as an object.

Retrieves the call information associated with a given call sid, if available.

const callInfo = await retrieveCallInfo(accountSid, callSid);
if (!callInfo) {
  logger.info(`call for ${callSid} not found);
}

listCallInfo

listCallInfo(accountSid)

returns a Promise yielding an array of information about calls.

Retrieves all of the active (or recently-active) calls for an Account.

const calls = await listCallInfo(accountSid);

deleteCall

deleteCall(accountSid, callSid)

returns boolean indicating if call was successfully deleted

Deletes a Call.

const result = await deleteCall(accountSid, callSid);

purgeCalls

purgeCalls()

returns number of calls purged

Purges call data for calls that ended some time ago.

const countDeleted = await purgeCalls();

synthAudio

synthAudio({vendor, language, voice, text})

returns the path to a temporary file containing the generated audio

Generates audio for text, retrieving previously generated audio from cache if available. Audio is cached for 24 hours.

const path = await synthAudio({
  vendor: 'aws', 
  language: 'en-US', 
  voice: 'Amy', 
  text: 'This is a test'
});

realtimedb-helpers's People

Contributors

ashbrener avatar davehorton avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.