Methods
(static) answer() → {Promise}
- Description:
Answer Call
Example
await ctx.answer()
Returns:
- Type
- Promise
(static) blockDtmf() → {Promise}
- Description:
Block DTMF
Example
await ctx.blockDtmf()
Returns:
- Type
- Promise
(static) bridge(destination, continue_on) → {Promise}
- Description:
Bridges the call with another destination, returns a promise when complete containing the bleg context.
Examples
await ctx.bridge('160')
await ctx.bridge('441234567890')
Parameters:
Name | Type | Description |
---|---|---|
destination |
string | |
continue_on |
string | Continue on true, false, 'fail', 'completed' |
Returns:
- Type
- Promise
(static) echo(delayopt) → {Promise}
- Description:
Echo
Examples
await ctx.echo()
await ctx.echo(500)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
delay |
number |
<optional> |
Value in milliseconds |
Returns:
- Type
- Promise
(static) get(Key) → {string}
- Description:
Get Variable
Example
ctx.get('myVar')
Parameters:
Name | Type | Description |
---|---|---|
Key |
string |
Returns:
Value
- Type
- string
(static) hangup() → {Promise}
- Description:
Hang Up
Example
await ctx.hangup()
Returns:
- Type
- Promise
(static) header(Key, Value)
- Description:
Get / Set Header
Examples
header('X-My-Header', 'myVal')
var value = ctx.header('X-My-Header')
Parameters:
Name | Type | Description |
---|---|---|
Key |
string | |
Value |
string |
(static) ivr(file, timeout, min, max, terminators, opts) → {Promise.<Object>}
- Description:
Interactive Voice Response - IVR
Examples
var {status, value} = await ctx.ivr('user/myGreeting.wav', 1, 5, 10)
var {status, value} = await ctx.ivr('ivr/ivr-aint_nobody_got_time_for_that.wav', 10, 10, 5)
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
file |
string | Audio Filename |
|||||||||||||||
timeout |
number | How many seconds to wait (after audio is completed) |
|||||||||||||||
min |
number | Minimum Digits to be captured |
|||||||||||||||
max |
number | Maximum Digits to be captured |
|||||||||||||||
terminators |
string | Characters to end input such as # |
|||||||||||||||
opts |
Object | Additional Options Properties
|
Returns:
- Type
- Promise.<Object>
(static) log(Text)
- Description:
Log Information
Example
ctx.log('Hello World!')
Parameters:
Name | Type | Description |
---|---|---|
Text |
string |
Returns:
null
(static) play(file) → {Promise}
- Description:
Play
Examples
await ctx.play('user/myGreeting.wav')
await ctx.play('ivr/ivr-aint_nobody_got_time_for_that.wav')
Parameters:
Name | Type | Description |
---|---|---|
file |
string |
Returns:
- Type
- Promise
(static) record(filename) → {Promise}
- Description:
Record Call
Parameters:
Name | Type | Description |
---|---|---|
filename |
string | Filename without extension |
Returns:
Promise returns after call recording has successfully started
- Type
- Promise
(static) set(Key, Value)
- Description:
Set Variable
Example
ctx.set('myVar', 'myVal')
Parameters:
Name | Type | Description |
---|---|---|
Key |
string | |
Value |
string |
(static) stopMedia() → {Promise}
- Description:
Stop Media which is currently playing.
Example
await ctx.stopMedia()
Returns:
- Type
- Promise
(static) transcribeStart(opts) → {Promise}
- Description:
Start Transcription
Parameters:
Name | Type | Description |
---|---|---|
opts |
object | Options |
Returns:
Promise returns after transcription has started
- Type
- Promise
(static) transcribestop() → {Promise}
- Description:
Stop Transcription
Returns:
Promise returns after transcription has stopped
- Type
- Promise
(static) tts(text) → {Promise}
- Description:
Text-To-Speech
Example
await ctx.tts('Thank you for calling.')
Parameters:
Name | Type | Description |
---|---|---|
text |
string |
Returns:
- Type
- Promise
(static) unblockDtmf() → {Promise}
- Description:
UnBlock DTMF
Example
await ctx.unblockDtmf()
Returns:
- Type
- Promise
(static) waitFor(match, failMatch) → {Promise}
- Description:
Wait For (DTMF Sequence)
Examples
try {
var keys = await ctx.waitFor('\d{4}' '*', 3000);
process(keys)
} catch (err) {
// Continue
}
function fn(value) {
return value > 1000;
// You can fail a match by throw new Error('fail');
}
try {
var keys = await ctx.waitFor(fn, '*');
process(keys);
} catch (err) {
// Continue
}
// Ignore any previously entered numbers, just capture look at the last part with a Regular Expression
try {
var keys = await ctx.waitFor(/00$/, '*');
process(keys);
} catch (err) {
// Continue
}
// Wait for multiple events
ctx.waitFor(/00$/, '*').then(keys => { // Do Stuff});
ctx.waitFor(/11$/, '*').then(keys => { // Do Stuff});
Parameters:
Name | Type | Description |
---|---|---|
match |
string | RegExp | waitForMatch | Positive Match |
failMatch |
string | RegExp | waitForMatch | Negative Match (How to escape menu) |
Returns:
String or RegEx in match, will return string, will return truthy result for match as a function
- Type
- Promise
(static) waitForHangup() → {Promise}
- Description:
Wait For Hang Up
Returns:
Promise returns after the call has completed
- Type
- Promise
Type Definitions
waitForMatch(match) → {*}
- Description:
Call back function
waitForMatch
to be used as match in waitFor
Parameters:
Name | Type | Description |
---|---|---|
match |
string | Text to be matched against |
Returns:
result Truthy will match
- Type
- *