mirror of
https://github.com/jambonz/jambonz-node.git
synced 2026-07-04 19:31:48 +00:00
initial checkin
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"dial": {
|
||||
"actionHook": "http://example.com",
|
||||
"callerId": "+1312888899",
|
||||
"target": [
|
||||
{
|
||||
"type": "foo",
|
||||
"number": "sip:1617333456@sip.trunk1.com",
|
||||
"auth": {
|
||||
"user": "foo",
|
||||
"password": "bar"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"key1": "value",
|
||||
"key2": "value"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
[1, 2]
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"sip:decline": {
|
||||
"status": "hello"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"dial": {
|
||||
"actionHook": "http://example.com",
|
||||
"callerId": "+1312888899",
|
||||
"target": [
|
||||
{
|
||||
"type": "sip",
|
||||
"number": "sip:1617333456@sip.trunk1.com",
|
||||
"auth": {
|
||||
"password": "bar"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"foo": "bar"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"sip:decline": {
|
||||
"status": 480,
|
||||
"foo": "bar"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
[
|
||||
{
|
||||
"verb": "gather",
|
||||
"actionHook": "https://00dd977a.ngrok.io/gather",
|
||||
"input": ["speech"],
|
||||
"timeout": 12,
|
||||
"recognizer": {
|
||||
"vendor": "google",
|
||||
"language": "en-US",
|
||||
"hints": ["sales", "support", "engineering", "human resources", "HR", "operator", "agent"]
|
||||
},
|
||||
"say": {
|
||||
"text": "Please say the name of the department that you would like to speak with. To speak to an operator, just say operator.",
|
||||
"synthesizer": {
|
||||
"vendor": "google",
|
||||
"language": "en-US"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"verb": "say",
|
||||
"text": "I'm sorry, I did not hear a response. Goodbye.",
|
||||
"synthesizer": {
|
||||
"vendor": "google",
|
||||
"language": "en-US"
|
||||
}
|
||||
},
|
||||
{
|
||||
"verb": "hangup"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"dial": {
|
||||
"actionHook": "http://example.com",
|
||||
"callerId": "+1312888899",
|
||||
"target": [
|
||||
{
|
||||
"type": "phone",
|
||||
"number": "+15083084809"
|
||||
}
|
||||
],
|
||||
"listen": {
|
||||
"url": "wss://myrecorder.example.com:4433",
|
||||
"mixType" : "stereo",
|
||||
"sampleRate": 8000,
|
||||
"passDtmf": true,
|
||||
"metadata": {
|
||||
"clientId": "12udih"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"dial": {
|
||||
"actionHook": "http://example.com",
|
||||
"callerId": "+1312888899",
|
||||
"target": [
|
||||
{
|
||||
"type": "phone",
|
||||
"number": "+15083084809"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"dial": {
|
||||
"actionHook": "http://example.com",
|
||||
"callerId": "+1312888899",
|
||||
"target": [
|
||||
{
|
||||
"type": "sip",
|
||||
"number": "sip:1617333456@sip.trunk1.com",
|
||||
"auth": {
|
||||
"username": "foo",
|
||||
"password": "bar"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"dial": {
|
||||
"actionHook": "http://example.com",
|
||||
"callerId": "+1312888899",
|
||||
"target": [
|
||||
{
|
||||
"type": "phone",
|
||||
"number": "+15083084809"
|
||||
}
|
||||
],
|
||||
"transcribe": {
|
||||
"transcriptionHook": "/transcribe",
|
||||
"recognizer": {
|
||||
"vendor": "google",
|
||||
"language" : "en-US",
|
||||
"dualChannel" : true,
|
||||
"interim": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"dial": {
|
||||
"actionHook": "http://example.com",
|
||||
"callerId": "+1312888899",
|
||||
"target": [
|
||||
{
|
||||
"type": "user",
|
||||
"name": "spike@sip.example.com"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"pause": {
|
||||
"length": 3
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"say": {
|
||||
"text": ["hi there", "John"],
|
||||
"synthesizer": {
|
||||
"vendor": "google",
|
||||
"language": "en-US"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"say": {
|
||||
"text": "hi there",
|
||||
"synthesizer": {
|
||||
"vendor": "google",
|
||||
"language": "en-US"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"sip:decline": {
|
||||
"status": 480,
|
||||
"reason": "Gone Fishin",
|
||||
"headers": {
|
||||
"Retry-After": 300
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
const test = require('blue-tape');
|
||||
const assert = require('assert');
|
||||
|
||||
const fetchData = (json) => {
|
||||
const keys = Object.keys(json);
|
||||
return json[keys[0]];
|
||||
}
|
||||
|
||||
test('unit tests', (t) => {
|
||||
const WebhookResponse = require('..').WebhookResponse;
|
||||
|
||||
let app = new WebhookResponse();
|
||||
app.sip_decline(fetchData(require('./data/good/sip-decline')));
|
||||
t.pass('sip_decline: passes');
|
||||
app.say(fetchData(require('./data/good/say')));
|
||||
t.pass('say: passes');
|
||||
app.say(fetchData(require('./data/good/say-text-array')));
|
||||
t.pass('say: passes with array of text');
|
||||
app.pause(fetchData(require('./data/good/pause')));
|
||||
t.pass('pause: passes with array of text');
|
||||
app.dial(fetchData(require('./data/good/dial-sip')));
|
||||
t.pass('dial: passes with target sip');
|
||||
app.dial(fetchData(require('./data/good/dial-phone')));
|
||||
t.pass('dial: passes with target phone');
|
||||
app.dial(fetchData(require('./data/good/dial-user')));
|
||||
t.pass('dial: passes with target user');
|
||||
app.dial(fetchData(require('./data/good/dial-listen')));
|
||||
t.pass('dial: passes with embedded listen');
|
||||
|
||||
|
||||
//let payload = app.toJSON();
|
||||
//console.log(payload);
|
||||
//let task = makeTask(logger, require('./data/good/sip-decline'));
|
||||
//t.ok(task.name === 'sip:decline', 'parsed sip:decline');
|
||||
|
||||
//t.throws(errInvalidInstruction, /malformed jambonz application payload/, 'throws error for invalid instruction');
|
||||
//t.throws(errUnknownProperty, /unknown property/, 'throws error for invalid instruction');
|
||||
//t.throws(errMissingProperty, /missing value/, 'throws error for missing required property');
|
||||
//t.throws(errInvalidType, /invalid data type/, 'throws error for invalid data type');
|
||||
//t.throws(errBadEnum, /must be one of/, 'throws error for invalid enum');
|
||||
//t.throws(errBadPayload, /malformed jambonz application payload/, 'throws error for invalid payload with multiple keys');
|
||||
//t.throws(errBadPayload2, /malformed jambonz application payload/, 'throws error for invalid payload that is not an object');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
const errInvalidInstruction = () => makeTask(logger, require('./data/bad/unknown-instruction'));
|
||||
const errUnknownProperty = () => makeTask(logger, require('./data/bad/unknown-property'));
|
||||
const errMissingProperty = () => makeTask(logger, require('./data/bad/missing-required-property'));
|
||||
const errInvalidType = () => makeTask(logger, require('./data/bad/invalid-type'));
|
||||
const errBadEnum = () => makeTask(logger, require('./data/bad/bad-enum'));
|
||||
const errBadPayload = () => makeTask(logger, require('./data/bad/bad-payload'));
|
||||
const errBadPayload2 = () => makeTask(logger, require('./data/bad/bad-payload2'));
|
||||
Reference in New Issue
Block a user