Methods
(static) answer() → {Promise}
Answer Call
Example
await ctx.answer()
Returns:
- Type
- Promise
(static) blockDtmf() → {Promise}
Block DTMF
Example
await ctx.blockDtmf()
Returns:
- Type
- Promise
(static) bridge(destination, continue_on) → {Promise}
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}
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}
Get Variable
Example
ctx.get('myVar')
Parameters:
Name | Type | Description |
---|---|---|
Key |
string |
Returns:
Value
- Type
- string
(static) hangup() → {Promise}
Hang Up
Example
await ctx.hangup()
Returns:
- Type
- Promise
(static) header(Key, Value)
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>}
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)
Log Information
Example
ctx.log('Hello World!')
Parameters:
Name | Type | Description |
---|---|---|
Text |
string |
Returns:
null
(static) play(file) → {Promise}
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}
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)
Set Variable
Example
ctx.set('myVar', 'myVal')
Parameters:
Name | Type | Description |
---|---|---|
Key |
string | |
Value |
string |
(static) tts(text) → {Promise}
Text-To-Speech
Example
ctx.await tts('Thank you for calling.')
Parameters:
Name | Type | Description |
---|---|---|
text |
string |
Returns:
- Type
- Promise
(static) waitFor(match, failMatch) → {Promise}
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}
Wait For Hang Up
Returns:
Promise returns after the call has completed
- Type
- Promise
Type Definitions
waitForMatch(match) → {*}
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
- *