0.8.8 • Published 2 months ago

@jambonz/realtimedb-helpers v0.8.8

Weekly downloads
121
License
MIT
Repository
github
Last release
2 months ago

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.

If standalone redis is used:

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

If redis with authentication is used:

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

If redis Sentinel is used:

const opts = {
  sentinels: [
    { host: '54.53.52.51', port: 6379 },
    { host: '54.53.52.52', port: 6379 },
    { host: '54.53.52.53', port: 6379 },
  ],
  name: 'masterNodeName',
};
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)

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

propertydescription
callSidthe Call Sid for this call
callIdthe SIP Call-ID
sipStatusthe most recent sip status - a value of 100 means this is a new call that should be added
callStatusone 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)

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)

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

const calls = await listCallInfo(accountSid);

deleteCall

deleteCall(accountSid, callSid)

Deletes a Call.

const result = await deleteCall(accountSid, callSid);

purgeCalls

purgeCalls()

Purges call data for calls that ended some time ago.

const countDeleted = await purgeCalls();

synthAudio

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

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'
});
0.8.8

2 months ago

0.8.7

7 months ago

0.8.5

11 months ago

0.8.4

11 months ago

0.8.6

11 months ago

0.7.3

11 months ago

0.8.1

11 months ago

0.8.0

11 months ago

0.8.3

11 months ago

0.8.2

11 months ago

0.6.7

1 year ago

0.7.2

1 year ago

0.7.1

1 year ago

0.7.0

1 year ago

0.6.6

1 year ago

0.6.5

1 year ago

0.6.4

1 year ago

0.5.6

1 year ago

0.5.8

1 year ago

0.5.7

1 year ago

0.5.9

1 year ago

0.6.3

1 year ago

0.6.2

1 year ago

0.6.1

1 year ago

0.6.0

1 year ago

0.4.31

2 years ago

0.4.32

2 years ago

0.4.30

2 years ago

0.4.35

2 years ago

0.4.33

2 years ago

0.4.34

2 years ago

0.5.3

1 year ago

0.5.5

1 year ago

0.5.0

2 years ago

0.5.2

1 year ago

0.5.1

2 years ago

0.4.28

2 years ago

0.4.29

2 years ago

0.4.27

2 years ago

0.4.20

2 years ago

0.4.21

2 years ago

0.4.26

2 years ago

0.4.24

2 years ago

0.4.25

2 years ago

0.4.22

2 years ago

0.4.23

2 years ago

0.4.19

2 years ago

0.4.17

2 years ago

0.4.18

2 years ago

0.4.15

2 years ago

0.4.16

2 years ago

0.4.9

2 years ago

0.4.10

2 years ago

0.4.14

2 years ago

0.4.11

2 years ago

0.4.12

2 years ago

0.4.8

3 years ago

0.4.5

3 years ago

0.4.4

3 years ago

0.4.7

3 years ago

0.4.6

3 years ago

0.4.3

3 years ago

0.4.2

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.3.0

3 years ago

0.2.22

3 years ago

0.2.21

3 years ago

0.2.20

3 years ago

0.2.19

4 years ago

0.2.18

4 years ago

0.2.17

4 years ago

0.2.16

4 years ago

0.2.15

4 years ago

0.2.14

4 years ago