@jambonz/node-red-contrib-jambonz 2.2.73 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/examples/Authenticating sip devices.json +1 -0
  2. package/examples/Conference with LCC.json +1 -0
  3. package/{src/examples → examples}/Connecting to a dialogflow bot.json +0 -0
  4. package/examples/Create Call and Send DTMF.json +1 -0
  5. package/examples/Get Log Data.json +1 -0
  6. package/examples/Leave Queue.json +1 -0
  7. package/examples/SIP Responses.json +1 -0
  8. package/{src/examples → examples}/SIP trunking outbound call.json +0 -0
  9. package/examples/Simple IVR.json +1 -0
  10. package/examples/Simple Queue.json +1 -0
  11. package/examples/Using Redirect.json +1 -0
  12. package/examples/Voicemail using Listen into S3 bucket.json +130 -0
  13. package/examples/config.json +1 -0
  14. package/examples/gather.json +1 -0
  15. package/examples/lex.json +1 -0
  16. package/examples/messages.json +1 -0
  17. package/examples/rasa.json +1 -0
  18. package/examples/tag a call.json +1 -0
  19. package/package.json +52 -14
  20. package/resources/editor.js +414 -0
  21. package/src/data/recognizer.json +685 -1
  22. package/src/data/tts.json +2970 -1
  23. package/src/nodes/auth.html +108 -0
  24. package/src/nodes/auth.js +43 -0
  25. package/src/nodes/conference.html +121 -0
  26. package/src/nodes/conference.js +31 -0
  27. package/src/nodes/config.html +484 -0
  28. package/src/nodes/config.js +74 -0
  29. package/src/nodes/create_call.html +287 -0
  30. package/src/nodes/create_call.js +104 -0
  31. package/src/nodes/create_sms.html +106 -0
  32. package/src/nodes/create_sms.js +65 -0
  33. package/src/nodes/dequeue.html +102 -0
  34. package/src/nodes/dequeue.js +25 -0
  35. package/src/nodes/dial.html +619 -0
  36. package/src/nodes/dial.js +138 -0
  37. package/src/nodes/dialogflow.html +260 -0
  38. package/src/nodes/dialogflow.js +53 -0
  39. package/src/nodes/dtmf.html +74 -0
  40. package/src/nodes/dtmf.js +22 -0
  41. package/src/nodes/enqueue.html +90 -0
  42. package/src/nodes/enqueue.js +25 -0
  43. package/src/nodes/gather.html +322 -0
  44. package/src/nodes/gather.js +83 -0
  45. package/src/nodes/get_alerts.html +94 -0
  46. package/src/nodes/get_alerts.js +47 -0
  47. package/src/nodes/get_calls.html +59 -0
  48. package/src/nodes/get_calls.js +38 -0
  49. package/src/nodes/get_recent_calls.html +95 -0
  50. package/src/nodes/get_recent_calls.js +47 -0
  51. package/src/nodes/hangup.html +46 -0
  52. package/src/nodes/hangup.js +20 -0
  53. package/src/nodes/jambonz.html +63 -38
  54. package/src/nodes/lcc.html +256 -0
  55. package/src/nodes/lcc.js +102 -0
  56. package/src/nodes/leave.html +40 -0
  57. package/src/nodes/leave.js +21 -0
  58. package/src/nodes/lex.html +264 -0
  59. package/src/nodes/lex.js +75 -0
  60. package/src/nodes/libs.js +99 -0
  61. package/src/nodes/listen.html +341 -0
  62. package/src/nodes/listen.js +82 -0
  63. package/src/nodes/message.html +95 -0
  64. package/src/nodes/message.js +32 -0
  65. package/src/nodes/pause.html +62 -0
  66. package/src/nodes/pause.js +25 -0
  67. package/src/nodes/play.html +76 -0
  68. package/src/nodes/play.js +23 -0
  69. package/src/nodes/rasa.html +106 -0
  70. package/src/nodes/rasa.js +22 -0
  71. package/src/nodes/redirect.html +64 -0
  72. package/src/nodes/redirect.js +24 -0
  73. package/src/nodes/s3-upload.html +29 -14
  74. package/src/nodes/s3-upload.js +24 -9
  75. package/src/nodes/say.html +115 -0
  76. package/src/nodes/say.js +38 -0
  77. package/src/nodes/sip-decline.html +76 -0
  78. package/src/nodes/sip-decline.js +25 -0
  79. package/src/nodes/sip-refer.html +116 -0
  80. package/src/nodes/sip-refer.js +33 -0
  81. package/src/nodes/sip-request.html +96 -0
  82. package/src/nodes/sip-request.js +36 -0
  83. package/src/nodes/tag.html +60 -0
  84. package/src/nodes/tag.js +22 -0
  85. package/src/nodes/template.html +63 -0
  86. package/src/nodes/template.js +9 -0
  87. package/src/nodes/userauth.html +85 -0
  88. package/src/nodes/userauth.js +70 -0
  89. package/src/nodes/webhooks.js +0 -16
  90. package/src/utils/http-helpers.js +68 -0
  91. package/src/examples/Authenticating sip devices.json +0 -10
  92. package/src/nodes/http-helpers.js +0 -26
  93. package/src/nodes/jambonz.js +0 -1044
@@ -0,0 +1,322 @@
1
+ <!-- Javascript -->
2
+
3
+
4
+ <script type="text/javascript">
5
+ RED.nodes.registerType('gather',{
6
+ category: 'jambonz',
7
+ color: '#bbabaa',
8
+ defaults: {
9
+ name: {value: ''},
10
+ actionhook: {value: ''},
11
+ finishonkey: {value: ''},
12
+ dtmfinput: {value: 0},
13
+ speechinput: {value: 1},
14
+ numdigits: {value: ''},
15
+ timeout: {value: ''},
16
+ prompttype: {value: 'say'},
17
+ playurl: {value: ''},
18
+ playurlType: {value: 'str'},
19
+ playLoop: {value: ''},
20
+ text: {value: ''},
21
+ vendor: {value: 'default'},
22
+ lang: {value: 'default'},
23
+ voice: {value: 'default'},
24
+ xvoice: {},
25
+ xlang: {},
26
+ transcriptionvendor: {value: 'default'},
27
+ recognizerlang: {value: 'default'},
28
+ recognizeraltlang: {},
29
+ recognizeraltlangType: {val: 'str'},
30
+ interim: {value: false},
31
+ profanityfilter: {value: false},
32
+ transcriptionhints: {},
33
+ transcriptionhintsType: {val: 'str'},
34
+ separaterecog: {value: false},
35
+ useenhanced: {value: false},
36
+ words: {value: false},
37
+ punctuation: {value: false},
38
+ diarization: {value: false},
39
+ diarizationmin: {value: 2},
40
+ diarizationminType: {value: 'num'},
41
+ diarizationmax: {value: 6},
42
+ diarizationmaxType: {value: 'num'},
43
+ interactiontype: {value: 'voice_command'},
44
+ naics: {value: 0},
45
+ naicsType: {value: 'num'},
46
+ identifychannels: {value: false},
47
+ speakerlabel: {value: false},
48
+ vocabularyname: {},
49
+ vocabularynameType: {value: 'str'},
50
+ vocabularyfiltername: {},
51
+ vocabularyfilternameType: {value: 'str'},
52
+ vocabularyfiltermethod: {}
53
+ },
54
+ inputs:1,
55
+ outputs:1,
56
+ icon: "font-awesome/fa-cubes",
57
+ label: function() { return this.name || 'gather';},
58
+ oneditprepare: function() {
59
+ var node = this;
60
+ prepareTtsControls(node);
61
+ prepareSttControls(node);
62
+
63
+ $('#node-input-playurl').typedInput({
64
+ types: ['str', 'msg', 'flow', 'global', 'jsonata', 'env'],
65
+ typeField: $('#node-input-playurlType')
66
+ });
67
+ $('#node-input-transcriptionhints').typedInput({
68
+ types: ['str', 'msg', 'flow', 'global', 'jsonata', 'env'],
69
+ typeField: $('#node-input-transcriptionhintsType')
70
+ });
71
+ $('#node-input-recognizeraltlang').typedInput({
72
+ types: ['str', 'msg', 'flow', 'global', 'jsonata', 'env'],
73
+ typeField: $('#node-recognizeraltlangType')
74
+ });
75
+ $('#node-input-naics').typedInput({
76
+ types: ['num', 'msg', 'flow', 'global'],
77
+ typeField: $('#node-input-naicsType')
78
+ });
79
+
80
+ var enableSpeech = function(enabled) {
81
+ console.log(`enable speech: ${enabled}`);
82
+ if (enabled) $('#speech-input-container').show();
83
+ else $('#speech-input-container').hide();
84
+ }
85
+ var enableDtmf = function(enabled) {
86
+ console.log(`enable dtmf: ${enabled}`);
87
+ if (enabled) $('#dtmf-input-container').show();
88
+ else $('#dtmf-input-container').hide();
89
+ }
90
+
91
+ $('#node-input-speechinput').change(function() {
92
+ var doSpeech = $('#node-input-speechinput:checked').val();
93
+ enableSpeech(doSpeech);
94
+ });
95
+ $('#node-input-dtmfinput').change(function() {
96
+ var doDtmf = $('#node-input-dtmfinput:checked').val();
97
+ enableDtmf(doDtmf);
98
+ });
99
+
100
+ var onSayPlayChanged = function () {
101
+ var type = $('#node-input-prompttype').find(':selected').val();
102
+ console.log(`prompt type changed to ${type}`);
103
+ if (type === 'say') {
104
+ $('#say-container').show();
105
+ $('#play-container').hide();
106
+ }
107
+ else {
108
+ $('#play-container').show();
109
+ $('#say-container').hide();
110
+ }
111
+ }
112
+
113
+ $('#node-input-prompttype').change(onSayPlayChanged);
114
+ }
115
+ });
116
+
117
+ </script>
118
+
119
+
120
+ <!-- HTML -->
121
+
122
+ <script type="text/html" data-template-name="gather">
123
+ <div class="form-row">
124
+ <label for="node-input-name"><i class="icon-tag"></i> Name</label>
125
+ <input type="text" id="node-input-name" placeholder="Name">
126
+ </div>
127
+ <div class="form-row">
128
+ <label for="node-input-actionhook"><i class="icon-tag"></i> Action hook</label>
129
+ <input type="text" id="node-input-actionhook" placeholder="webhook with results of gather">
130
+ </div>
131
+ <fieldset>
132
+ <legend>Prompt</legend>
133
+ <div class="form-row">
134
+ <label for="node-input-prompttype"><i class="icon-tag"></i> Verb</label>
135
+ <select id="node-input-prompttype">
136
+ <option>play</option>
137
+ <option selected>say</option>
138
+ </select>
139
+ </div>
140
+
141
+ <div id="say-container">
142
+ <div class="form-row">
143
+ <label for="node-input-text"><i class="icon-tag"></i> Text</label>
144
+ <textarea id="node-input-text" rows="4" placeholder="Text or SSML to speak" style="width:70%"></textarea>
145
+ </div>
146
+ <div class="form-row">
147
+ <label for="node-input-vendor"> Vendor</label>
148
+ <select id="node-input-vendor">
149
+ <option value="default" selected>--application default--</option>
150
+ <option value="google">google</option>
151
+ <option value="aws">aws/polly</option>
152
+ <option value="microsoft">microsoft</option>
153
+ <option value="ibm">ibm</option>
154
+ <option value="nuance">nuance</option>
155
+
156
+ </select>
157
+ </div>
158
+ <div class="form-row" style="display: none;">
159
+ <label for="node-input-lang"> Lang</label>
160
+ <input type="text" id="node-input-lang">
161
+ </div>
162
+ <div class="form-row">
163
+ <label for="node-input-xlang">Language</label>
164
+ <select id="node-input-xlang">
165
+ <option value="default" selected>--application default--</option>
166
+ </select>
167
+ </div>
168
+ <div class="form-row" style="display: none;">
169
+ <label for="node-input-voice"> Voice</label>
170
+ <input type="text" id="node-input-voice">
171
+ </div>
172
+ <div class="form-row">
173
+ <label for="node-input-xvoice">Voice</label>
174
+ <select id="node-input-xvoice">
175
+ <option value="default" selected>--application default--</option>
176
+ </select>
177
+ </div>
178
+ </div>
179
+
180
+ <div id="play-container">
181
+ <div class="form-row">
182
+ <label for="node-input-playurl"> Url</label>
183
+ <input type="text" id="node-input-playurl" placeholder="url of file to play">
184
+ <input type="hidden" id="node-input-playurlType">
185
+ </div>
186
+ <div class="form-row">
187
+ <label for="node-input-playLoop"> Loop</label>
188
+ <input type="text" id="node-input-playLoop" placeholder="count">
189
+ </div>
190
+ </div>
191
+ </fieldset>
192
+ <fieldset>
193
+ <legend>DTMF Input</legend>
194
+ <div class="form-row">
195
+ <label for="node-input-dtmfinput">Accept DTMF input</label>
196
+ <input type="checkbox" id="node-input-dtmfinput">
197
+ </div>
198
+ <div id="dtmf-input-container">
199
+ <div class="form-row">
200
+ <label for="node-input-finishonkey"><i class="icon-tag"></i> Finish key</label>
201
+ <input type="text" id="node-input-finishonkey" placeholder="dtmf key to signal end of input">
202
+ </div>
203
+ <div class="form-row">
204
+ <label for="node-input-numdigits"><i class="icon-tag"></i> Num. digits</label>
205
+ <input type="text" id="node-input-numdigits" placeholder="number of digits to collect">
206
+ </div>
207
+ <div class="form-row">
208
+ <label for="node-input-numtimeout"><i class="icon-tag"></i> Timeout</label>
209
+ <input type="text" id="node-input-timeout" placeholder="dtmf timeout in secs">
210
+ </div>
211
+ </div>
212
+ </fieldset>
213
+ <fieldset>
214
+ <legend>Speech Input</legend>
215
+ <div class="form-row">
216
+ <label for="node-input-speechinput">Accept Speech input</label>
217
+ <input type="checkbox" id="node-input-speechinput">
218
+ </div>
219
+ <div id="speech-input-container">
220
+ <div class="form-row">
221
+ <label for="node-input-transcriptionvendor">Vendor</label>
222
+ <select id="node-input-transcriptionvendor">
223
+ <option value="default" selected>--application default--</option>
224
+ <option value="google">Google</option>
225
+ <option value="aws">AWS</option>
226
+ <option value="deepgram">deepgram</option>
227
+ <option value="microsoft">microsoft</option>
228
+ <option value="ibm">ibm</option>
229
+ <option value="nuance">nuance</option>
230
+
231
+ </select>
232
+ </div>
233
+ <div class="form-row">
234
+ <label for="node-input-recognizerlang"><i class="icon-tag"></i> Language</label>
235
+ <select id="node-input-recognizerlang">
236
+ </select>
237
+ </div>
238
+ <div id="google-stt-options">
239
+ <legend>Google Transcription Options</legend>
240
+ <div class="form-row">
241
+ <label for="node-input-transcriptionhints">Hints</label>
242
+ <input type="text" id="node-input-transcriptionhints" placeholder="comma-separated list of phrases">
243
+ <input type="hidden" id="node-input-transcriptionhintsType">
244
+ </div>
245
+ <div class="form-row">
246
+ <label for="node-input-recognizeraltlang">Alternative languages</label>
247
+ <input type="text" id="node-input-recognizeraltlang" placeholder="comma-separated list of add'l lang codes">
248
+ <input type="hidden" id="node-input-recognizeraltlangType">
249
+ </div>
250
+ <div class="form-row">
251
+ <label for="node-input-naics">Industry NAICS code</label>
252
+ <input type="text" id="node-input-naics">
253
+ <input type="hidden" id="node-input-naicsType">
254
+ </div>
255
+ </div>
256
+ <div id="aws-stt-options">
257
+ <legend>AWS Transcription Options</legend>
258
+ <div class="form-row">
259
+ <label for="node-input-vocabularyname">Vocabulary name</label>
260
+ <input type="text" id="node-input-vocabularyname">
261
+ <input type="hidden" id="node-input-vocabularynameType">
262
+ </div>
263
+ <div class="form-row">
264
+ <label for="node-input-vocabularyfiltername">Vocabulary filter name</label>
265
+ <input type="text" id="node-input-vocabularyfiltername">
266
+ <input type="hidden" id="node-input-vocabularyfilternameType">
267
+ </div>
268
+ <div class="form-row">
269
+ <label for="node-input-vocabularyfiltermethod">Filter method</label>
270
+ <select id="node-input-vocabularyfiltermethod">
271
+ <option value="remove" selected>Remove</option>
272
+ <option value="mask" selected>Mask</option>
273
+ <option value="tag" selected>Tag</option>
274
+ </select>
275
+ </div>
276
+ </div>
277
+ </div>
278
+ </fieldset>
279
+ </script>
280
+
281
+ <!-- Help Text -->
282
+ <script type="text/html" data-help-name="gather">
283
+ <p>Collect speech or dtmf input from the caller</p>
284
+ <h3>Inputs</h3>
285
+ <dl class="message-properties">
286
+ <dt>Action hook<span class="property-type">string</span></dt>
287
+ <dd>A webhook invoke when operation completes.</dd>
288
+ <dt>Speech<span class="property-type">boolean</span></dt>
289
+ <dd>Enable speech input.</dd>
290
+ <dt>Digits<span class="property-type">boolean</span></dt>
291
+ <dd>Enable DTMF input.</dd>
292
+ <dt>Language<span class="property-type">string</span></dt>
293
+ <dd>Language to use for speech recognition</dd>
294
+ <dt>Hints<span class="property-type">string</span></dt>
295
+ <dd>Comma-separate list of words or phrases to assist speech detection</dd>
296
+ <dt>Verb<span class="property-type">string</span></dt>
297
+ <dd>Whether to use the play or say verb to prompt the caller</dd>
298
+ <dt>Url<span class="property-type">string</span></dt>
299
+ <dd>Url of prompt to play</dd>
300
+ <dt>Text<span class="property-type">string</span></dt>
301
+ <dd>Text to speak as a prompt to caller</dd>
302
+ <dt>Vendor<span class="property-type">string</span></dt>
303
+ <dd>TTS vendor</dd>
304
+ <dt>Language<span class="property-type">string</span></dt>
305
+ <dd>TTS language</dd>
306
+ <dt>Voice<span class="property-type">string</span></dt>
307
+ <dd>TTS voice</dd>
308
+ </dl>
309
+
310
+ <h3>Outputs</h3>
311
+ <dl class="message-properties">
312
+ <dt>jambonz<span class="property-type">object</span></dt>
313
+ <dd> <code>msg.jambonz</code> will contain any previous actions provided to the input with the new <code>gather</code> action appended </dd>
314
+ </dl>
315
+
316
+ <h3>Details</h3>
317
+ The gather command is used to collect dtmf or speech input.
318
+ <h3>References</h3>
319
+ <ul>
320
+ <li><a href="https://docs.jambonz.org/jambonz/#gather">Jambonz gather reference</a></li>
321
+ </ul>
322
+ </script>
@@ -0,0 +1,83 @@
1
+ var {createHash} = require('crypto');
2
+ const bent = require('bent');
3
+ var mustache = require('mustache');
4
+ mustache.escape = function(text) {return text;};
5
+ var {appendVerb, v_resolve, v_text_resolve} = require('./libs')
6
+
7
+
8
+ module.exports = function(RED) {
9
+ /** gather */
10
+ function gather(config) {
11
+ RED.nodes.createNode(this, config);
12
+ var node = this;
13
+ node.on('input', function(msg) {
14
+
15
+ // simple properties
16
+ node.log(`config: ${JSON.stringify(config)}`);
17
+
18
+ var obj = {verb: 'gather', input: []};
19
+ if (config.actionhook) obj.actionHook = config.actionhook;
20
+
21
+ // input
22
+ if (config.speechinput) {
23
+ obj.input.push('speech');
24
+ const recognizer = {
25
+ vendor: config.transcriptionvendor,
26
+ language: config.recognizerlang
27
+ };
28
+ if (recognizer.vendor === 'google') {
29
+ var hints = v_resolve(config.transcriptionhints, config.transcriptionhintsType, this.context(), msg);
30
+ var altlangs = v_resolve(config.recognizeraltlang, config.recognizeraltlangType, this.context(), msg);
31
+ var naics = v_resolve(config.naics, config.naicsType, this.context(), msg);
32
+ Object.assign(recognizer, {
33
+ profanityFilter: config.profanityfilter,
34
+ hints: hints.length > 0 ?
35
+ hints.split(',').map((w) => w.trim()) :
36
+ []
37
+ });
38
+ if (naics) recognizer.naicsCode = parseInt(naics) || 0;
39
+ if (altlangs) {
40
+ recognizer.altLanguages = altlangs.split(',').map((e) => e.trim());
41
+ }
42
+ }
43
+ else if (recognizer.vendor === 'aws') {
44
+ var vocab = v_resolve(config.vocabularyname, config.vocabularynameType, this.context(), msg);
45
+ var vocabFilter = v_resolve(config.vocabularyfiltername, config.vocabularynameType, this.context(), msg);
46
+ Object.assign(recognizer, {
47
+ vocabularyName: vocab,
48
+ vocabularyFilterName: vocabFilter,
49
+ filterMethod: config.vocabularyfiltermethod
50
+ });
51
+ }
52
+ obj.recognizer = recognizer;
53
+ }
54
+ if (config.dtmfinput) {
55
+ obj.input.push('digits');
56
+ if (config.finishonkey && config.finishonkey.length) obj.finishOnKey = obj.finishonkey;
57
+ if (/^\d+$/.test(config.numdigits)) obj.numDigits = parseInt(config.numdigits);
58
+ if (/^\d+$/.test(config.timeout)) obj.timeout = parseInt(config.timeout);
59
+ }
60
+
61
+ // prompt
62
+ if (config.prompttype === 'say') {
63
+ obj.say = {text: v_text_resolve(node, config.text, this.context(), msg)};
64
+ if (['aws', 'google'].includes(config.vendor)) {
65
+ Object.assign(obj.say, {
66
+ synthesizer: {
67
+ vendor: config.vendor,
68
+ language: config.lang,
69
+ voice: config.voice
70
+ }
71
+ });
72
+ }
73
+ }
74
+ else obj.play = {url: v_resolve(config.playurl, config.playurlType, this.context(), msg)};
75
+
76
+ node.log(`gather: ${JSON.stringify(obj)}`);
77
+
78
+ appendVerb(msg, obj);
79
+ node.send(msg);
80
+ });
81
+ }
82
+ RED.nodes.registerType('gather', gather);
83
+ }
@@ -0,0 +1,94 @@
1
+ <!-- Javascript -->
2
+
3
+
4
+ <script type="text/javascript">
5
+ RED.nodes.registerType('get_alerts',{
6
+ category: 'jambonz',
7
+ color: '#aebfb9',
8
+ defaults: {
9
+ name: {value: ''},
10
+ server: {value: '', required: true, type: 'jambonz_auth'},
11
+ page:{value: 1},
12
+ pageType:{value: 'num'},
13
+ count:{value: 25},
14
+ countType:{value: 'num'},
15
+ days:{value: 7},
16
+ countType:{value: 'num'}
17
+ },
18
+ inputs:1,
19
+ outputs:1,
20
+ icon: "font-awesome/fa-cubes",
21
+ paletteLabel: "Get - Alerts",
22
+ label: function() { return this.name || 'Get Alerts';},
23
+ oneditprepare: () => {
24
+ var node = this;
25
+ $('#node-input-page').typedInput({
26
+ types: ['num', 'msg', 'flow', 'global', 'jsonata', 'env'],
27
+ typeField: $('#node-input-pageType')
28
+ });
29
+ $('#node-input-count').typedInput({
30
+ types: ['num', 'msg', 'flow', 'global', 'jsonata', 'env'],
31
+ typeField: $('#node-input-countType')
32
+ });
33
+ $('#node-input-days').typedInput({
34
+ types: ['num', 'msg', 'flow', 'global', 'jsonata', 'env'],
35
+ typeField: $('#node-input-daysType')
36
+ });
37
+ }
38
+ });
39
+
40
+
41
+ </script>
42
+
43
+
44
+ <!-- HTML -->
45
+
46
+ <script type="text/html" data-template-name="get_alerts">
47
+ <div class="form-row">
48
+ <label for="node-input-name"><i class="icon-tag"></i> Name</label>
49
+ <input type="text" id="node-input-name" placeholder="Name">
50
+ </div>
51
+ <div class="form-row">
52
+ <label for="node-input-server">Server</label>
53
+ <input type="text" id="node-input-server">
54
+ </div>
55
+ <div class="form-row">
56
+ <label for="node-input-page">Page</label>
57
+ <input type="text" id="node-input-page" >
58
+ <input type="hidden" id="node-input-pageType">
59
+ </div>
60
+ <div class="form-row">
61
+ <label for="node-input-count">Count</label>
62
+ <input type="text" id="node-input-count" >
63
+ <input type="hidden" id="node-input-countType">
64
+ </div>
65
+ <div class="form-row">
66
+ <label for="node-input-days">Days</label>
67
+ <input type="text" id="node-input-days" >
68
+ <input type="hidden" id="node-input-daysType">
69
+ </div>
70
+
71
+
72
+ </script>
73
+
74
+ <!-- Help Text -->
75
+
76
+ <script type="text/html" data-help-name="get_alerts">
77
+ <p>DESCRIPTION</p>
78
+ <h3>Properties</h3>
79
+ <p><code>XXXX</code> - TEXT</p>
80
+
81
+ <h3>Outputs</h3>
82
+ <dl class="message-properties">
83
+ <dt>payload<span class="property-type">object</span></dt>
84
+ <dd> <code>msg.payload</code> will contain ... </dd>
85
+ </dl>
86
+
87
+ <h3>Details</h3>
88
+ The listen verb establishes a connection to a websocket server and sends live audio for the current call.<h3>References</h3>
89
+ <ul>
90
+ <li><a href="https://docs.jambonz.org/jambonz/#listen">Jambonz listen reference</a></li>
91
+ </ul>
92
+ </script>
93
+
94
+ </script>
@@ -0,0 +1,47 @@
1
+ var {createHash} = require('crypto');
2
+ const bent = require('bent');
3
+ var mustache = require('mustache');
4
+ mustache.escape = function(text) {return text;};
5
+ var {appendVerb, v_resolve, v_text_resolve, doLCC, doCreateCall, doCreateMessage} = require('./libs')
6
+
7
+ module.exports = function(RED) {
8
+ function get_alerts(config) {
9
+ RED.nodes.createNode(this, config);
10
+ var node = this;
11
+ const server = RED.nodes.getNode(config.server);
12
+ const {accountSid, apiToken} = server.credentials;
13
+ node.on('input', async(msg, send, done) => {
14
+ const data = {
15
+ page: config.page,
16
+ count : config.count,
17
+ days : config.days
18
+ }
19
+ const params = new URLSearchParams(data).toString()
20
+ const req = bent(`${server.url}/v1/Accounts/${accountSid}/Alerts?${params}`, 'GET', 'json', {
21
+ 'Authorization': `Bearer ${apiToken}`
22
+ });
23
+ try {
24
+ const res = await req();
25
+ msg.payload = res.data
26
+ msg.total = res.total
27
+ msg.page_size = res.page_size
28
+ msg.page = res.page
29
+ } catch (err) {
30
+ if (err.statusCode) {
31
+ node.error(`create-call failed with ${err.statusCode}`);
32
+ msg.statusCode = err.statusCode;
33
+ }
34
+ else {
35
+ node.error(`Error getting alerts ${JSON.stringify(err)}`);
36
+ if (done) done(err);
37
+ else node.error(err, msg);
38
+ send(msg);
39
+ return;
40
+ }
41
+ }
42
+ send(msg);
43
+ if (done) done();
44
+ });
45
+ }
46
+ RED.nodes.registerType('get_alerts', get_alerts);
47
+ }
@@ -0,0 +1,59 @@
1
+ <!-- Javascript -->
2
+
3
+
4
+ <script type="text/javascript">
5
+ RED.nodes.registerType('get_calls',{
6
+ category: 'jambonz',
7
+ color: '#aebfb9',
8
+ defaults: {
9
+ name: {value: ''},
10
+ server: {value: '', required: true, type: 'jambonz_auth'},
11
+ },
12
+ inputs:1,
13
+ outputs:1,
14
+ icon: "font-awesome/fa-cubes",
15
+ paletteLabel: "Get - Calls",
16
+ label: function() { return this.name || 'Get Calls';},
17
+ oneditprepare: () => {
18
+ var node = this;
19
+ }
20
+ });
21
+
22
+
23
+ </script>
24
+
25
+
26
+ <!-- HTML -->
27
+
28
+ <script type="text/html" data-template-name="get_calls">
29
+ <div class="form-row">
30
+ <label for="node-input-name"><i class="icon-tag"></i> Name</label>
31
+ <input type="text" id="node-input-name" placeholder="Name">
32
+ </div>
33
+ <div class="form-row">
34
+ <label for="node-input-server">Server</label>
35
+ <input type="text" id="node-input-server">
36
+ </div>
37
+ </script>
38
+
39
+ <!-- Help Text -->
40
+
41
+ <script type="text/html" data-help-name="get_calls">
42
+ <p>DESCRIPTION</p>
43
+ <h3>Properties</h3>
44
+ <p><code>XXXX</code> - TEXT</p>
45
+
46
+ <h3>Outputs</h3>
47
+ <dl class="message-properties">
48
+ <dt>payload<span class="property-type">object</span></dt>
49
+ <dd> <code>msg.payload</code> will contain ... </dd>
50
+ </dl>
51
+
52
+ <h3>Details</h3>
53
+ The listen verb establishes a connection to a websocket server and sends live audio for the current call.<h3>References</h3>
54
+ <ul>
55
+ <li><a href="https://docs.jambonz.org/jambonz/#listen">Jambonz listen reference</a></li>
56
+ </ul>
57
+ </script>
58
+
59
+ </script>
@@ -0,0 +1,38 @@
1
+ var {createHash} = require('crypto');
2
+ const bent = require('bent');
3
+ var mustache = require('mustache');
4
+ mustache.escape = function(text) {return text;};
5
+ var {appendVerb, v_resolve, v_text_resolve, doLCC, doCreateCall, doCreateMessage} = require('./libs')
6
+
7
+ module.exports = function(RED) {
8
+ function get_calls(config) {
9
+ RED.nodes.createNode(this, config);
10
+ var node = this;
11
+ const server = RED.nodes.getNode(config.server);
12
+ const {accountSid, apiToken} = server.credentials;
13
+ node.on('input', async(msg, send, done) => {
14
+ const req = bent(`${server.url}/v1/Accounts/${accountSid}/Calls`, 'GET', 'json', {
15
+ 'Authorization': `Bearer ${apiToken}`
16
+ });
17
+ try {
18
+ const res = await req();
19
+ msg.payload = res
20
+ } catch (err) {
21
+ if (err.statusCode) {
22
+ node.error(`create-call failed with ${err.statusCode}`);
23
+ msg.statusCode = err.statusCode;
24
+ }
25
+ else {
26
+ node.error(`Error getting calls ${JSON.stringify(err)}`);
27
+ if (done) done(err);
28
+ else node.error(err, msg);
29
+ send(msg);
30
+ return;
31
+ }
32
+ }
33
+ send(msg);
34
+ if (done) done();
35
+ });
36
+ }
37
+ RED.nodes.registerType('get_calls', get_calls);
38
+ }