@jambonz/node-red-contrib-jambonz 2.4.29 → 2.4.31

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jambonz/node-red-contrib-jambonz",
3
- "version": "2.4.29",
3
+ "version": "2.4.31",
4
4
  "description": "Node-RED nodes for jambonz platform",
5
5
  "keywords": [
6
6
  "node-red"
@@ -156,10 +156,10 @@
156
156
  }
157
157
  }
158
158
 
159
- function prepareSttControls(node) {
160
- var vendorElem = $('#node-input-transcriptionvendor');
161
- var languageElem = $('#node-input-recognizerlang');
162
- var mixtypeElem = $('#node-input-mixtype');
159
+ function prepareSttControls(node, vendor='#node-input-transcriptionvendor', lang='#node-input-recognizerlang', mixType='#node-input-mixtype') {
160
+ var vendorElem = $(vendor);
161
+ var languageElem = $(lang);
162
+ var mixtypeElem = $(mixType);
163
163
 
164
164
  console.log('entering prepareSttControls');
165
165
 
@@ -65,7 +65,17 @@
65
65
  vocabularynameType: {value: 'str'},
66
66
  vocabularyfiltername: {},
67
67
  vocabularyfilternameType: {value: 'str'},
68
- vocabularyfiltermethod: {}
68
+ vocabularyfiltermethod: {},
69
+ amd_actionHook : {},
70
+ amd_actionHookType: {value: 'str'},
71
+ amd_recognizer_vendor: {value: 'default'},
72
+ amd_recognizer_lang: {value: 'default'},
73
+ amd_thresholdWordCount: {},
74
+ amd_timers_decisionTimeoutMs: {},
75
+ amd_timers_greetingCompletionTimeoutMs:{},
76
+ amd_timers_noSpeechTimeoutMs: {},
77
+ amd_timers_toneTimeoutMs: {},
78
+ amd_digitCount: {},
69
79
  },
70
80
  inputs:1,
71
81
  outputs:1,
@@ -147,6 +157,7 @@
147
157
  });
148
158
 
149
159
  prepareSttControls(node);
160
+ prepareSttControls(node, '#node-input-amd_recognizer_vendor', '#node-input-amd_recognizer_lang');
150
161
 
151
162
  $('#node-input-target-container').css('min-height','180px').css('min-width','450px').editableList({
152
163
  addItem: function(container, i, opt) {
@@ -652,6 +663,55 @@
652
663
  <ol id="node-input-headers-container"></ol>
653
664
  </div>
654
665
  </fieldset>
666
+ <fieldset>
667
+ <legend>Answering Machine Detection</legend>
668
+ <div class="form-row">
669
+ <label for="node-input-amd_actionHook">actionHook</label>
670
+ <input type="text" id="node-input-amd_actionHook">
671
+ <input type="hidden" id="node-input-amd_actionHookType">
672
+ </div>
673
+ <div class="form-row">
674
+ <label for="node-input-amd_recognizer_vendor">Vendor</label>
675
+ <select id="node-input-amd_recognizer_vendor">
676
+ <option value="default" selected>--application default--</option>
677
+ <option value="google">Google</option>
678
+ <option value="aws">AWS</option>
679
+ <option value="deepgram">deepgram</option>
680
+ <option value="microsoft">microsoft</option>
681
+ <option value="ibm">ibm</option>
682
+ <option value="nuance">nuance</option>
683
+ </select>
684
+ </div>
685
+ <div class="form-row">
686
+ <label for="node-input-amd_recognizer_lang">Language</label>
687
+ <select id="node-input-amd_recognizer_lang">
688
+ </select>
689
+ </div>
690
+ <div class="form-row">
691
+ <label for="node-input-amd_thresholdWordCount">Threshold Word Count</label>
692
+ <input type="text" id="node-input-amd_thresholdWordCount">
693
+ </div>
694
+ <div class="form-row">
695
+ <label for="node-input-amd_digitCount">Digit Count</label>
696
+ <input type="text" id="node-input-amd_digitCount">
697
+ </div>
698
+ <div class="form-row">
699
+ <label for="node-input-amd_timers_decisionTimeoutMs">Decision Timeout</label>
700
+ <input type="text" id="node-input-amd_timers_decisionTimeoutMs">
701
+ </div>
702
+ <div class="form-row">
703
+ <label for="node-input-amd_timers_greetingCompletionTimeoutMs">Greeting Completion Timeout</label>
704
+ <input type="text" id="node-input-amd_timers_greetingCompletionTimeoutMs">
705
+ </div>
706
+ <div class="form-row">
707
+ <label for="node-input-amd_timers_noSpeechTimeoutMs">No-Speech Timeout</label>
708
+ <input type="text" id="node-input-amd_timers_noSpeechTimeoutMs">
709
+ </div>
710
+ <div class="form-row">
711
+ <label for="node-input-amd_timers_toneTimeoutMs">Tone Timeout</label>
712
+ <input type="text" id="node-input-amd_timers_toneTimeoutMs">
713
+ </div>
714
+ </fieldset>
655
715
  </div>
656
716
  </script>
657
717
 
package/src/nodes/dial.js CHANGED
@@ -49,7 +49,7 @@ module.exports = function(RED) {
49
49
  confirmHook: await new_resolve(RED, config.confirmhook, config.confirmhookType, node, msg),
50
50
  dialMusic: await new_resolve(RED, config.dialmusic, config.dialmusicType, node, msg),
51
51
  referHook: await new_resolve(RED, config.referhook, config.referhookType, node, msg),
52
- dtmfHook: await new_resolve(RED, config.dtmfhook, config.dtmfhookType, node, msg),
52
+ dtmfHook: await new_resolve(RED, config.dtmfhook, config.dtmfhookType, node, msg)
53
53
  };
54
54
 
55
55
  if (config.hasOwnProperty('anchormedia')) {
@@ -132,6 +132,32 @@ module.exports = function(RED) {
132
132
  delete data.dtmfHook;
133
133
  }
134
134
 
135
+ // AMD
136
+ const _amd_actionHook = await new_resolve(RED, config.amd_actionHook, config.amd_actionHookType, node, msg)
137
+ if (_amd_actionHook){
138
+ data.amd = {}
139
+ data.amd.actionHook = _amd_actionHook;
140
+ config.amd_thresholdWordCount && (data.amd.thresholdWordCount = Number(config.amd_thresholdWordCount))
141
+ config.amd_digitCount && (data.amd.digitCount = Number(config.amd_digitCount))
142
+ data.amd.timers = {
143
+ ...(config.amd_timers_decisionTimeoutMs && {decisionTimeoutMs: Number(config.amd_timers_decisionTimeoutMs)}),
144
+ ...(config.amd_timers_greetingCompletionTimeoutMs && {greetingCompletionTimeoutMs: Number(config.amd_timers_greetingCompletionTimeoutMs)}),
145
+ ...(config.amd_timers_noSpeechTimeoutMs && {noSpeechTimeoutMs: Number(config.amd_timers_noSpeechTimeoutMs)}),
146
+ ...(config.amd_timers_toneTimeoutMs && {toneTimeoutMs: Number(config.amd_timers_toneTimeoutMs)}),
147
+ }
148
+ //If none of the timer values are set remove the object
149
+ if (Object.keys(data.amd.timers).length == 0){
150
+ delete(data.amd.timers)
151
+ }
152
+ //If custom recogniser is used
153
+ if (config.amd_recognizer_vendor != 'default'){
154
+ data.amd.recognizer = {
155
+ ...(config.amd_recognizer_vendor && {vendor : config.amd_recognizer_vendor}),
156
+ ...(config.amd_recognizer_lang && {language : config.amd_recognizer_lang})
157
+ }
158
+ }
159
+ }
160
+
135
161
  node.log(`dial verb: ${JSON.stringify(data)}`);
136
162
 
137
163
  appendVerb(msg, data);
@@ -1,6 +1,14 @@
1
1
  <!-- Javascript -->
2
2
  <script type="text/javascript">
3
-
3
+
4
+ function formatjson(e) {
5
+ e.preventDefault();
6
+ e = s.getValue() || "";
7
+ try {
8
+ e = JSON.stringify(JSON.parse(e), null, 4)
9
+ } catch (e) {}
10
+ s.getSession().setValue(e || "", -1)
11
+ }
4
12
 
5
13
  RED.nodes.registerType('generic',{
6
14
  category: 'jambonz',
@@ -8,20 +16,32 @@
8
16
  defaults: {
9
17
  name: {value: ''},
10
18
  verb: {required: true},
11
- data: {value: '{}'},
12
- dataType: {value: 'json'},
19
+ data: { value: '',
20
+ validate: function(v) {
21
+ return (typeof(JSON.parse(v)) == 'object')
22
+ }
23
+ },
13
24
  },
14
25
  inputs:1,
15
26
  outputs:1,
16
27
  icon: "font-awesome/fa-cubes",
17
28
  label: function() { return this.name || 'generic';},
18
29
  oneditprepare: function() {
19
- $('#node-input-data').typedInput({
20
- default: $('#node-input-dataType').val(),
21
- types: ['json','msg', 'flow', 'global', 'jsonata', 'env'],
22
- typeField: $('#node-input-dataType')
23
- });
24
- }
30
+ this.editor = RED.editor.createEditor({
31
+ id: 'node-input-data-editor',
32
+ mode: 'ace/mode/json',
33
+ value: this.data
34
+ });
35
+ },
36
+ oneditsave: function() {
37
+ this.data = this.editor.getValue();
38
+ this.editor.destroy();
39
+ delete this.editor;
40
+ },
41
+ oneditcancel: function() {
42
+ this.editor.destroy();
43
+ delete this.editor;
44
+ }
25
45
  });
26
46
  </script>
27
47
 
@@ -35,11 +55,12 @@
35
55
  <label for="node-input-verb">Verb</label>
36
56
  <input type="text" id="node-input-verb" placeholder="verb">
37
57
  </div>
38
- <div class="form-row">
39
- <label for="node-input-data">Attributes</label>
40
- <input type="text" id="node-input-data">
41
- <input type="hidden" id="node-input-dataType">
42
- </div>
58
+ <div class="form-row" style="position: relative; height: 250px;">
59
+ <label for="node-input-data"><i class="fa fa-code"></i> Attributes</label>
60
+ <div style="position: absolute; right: 0; bottom: 0; top: 0; left: 100px;">
61
+ <div id="node-input-data-editor" style="width: 100%; height: 100%;"></div>
62
+ </div>
63
+ </div>
43
64
  </script>
44
65
 
45
66
  <!-- Help Text -->
@@ -1,4 +1,5 @@
1
1
  var {appendVerb, new_resolve} = require('./libs')
2
+ const assert = require('node:assert/strict');
2
3
 
3
4
  module.exports = function(RED) {
4
5
  function generic(config) {
@@ -6,12 +7,21 @@ module.exports = function(RED) {
6
7
  var node = this;
7
8
  node.verb = config.verb
8
9
  node.on('input', async function(msg) {
9
- let data = await new_resolve(RED, config.data, config.dataType, node, msg);
10
- appendVerb(msg, {
11
- ...{verb: node.verb},
12
- ...data
13
- });
14
- node.send(msg);
10
+ if (config.data.length==0) config.data='{}';
11
+ const _data = await new_resolve(RED, config.data, 'mustache', node, msg);
12
+ try {
13
+ const data = JSON.parse(_data)
14
+ assert.ok(typeof(data)=='object')
15
+ appendVerb(msg, {
16
+ ...{verb: node.verb},
17
+ ...data
18
+ });
19
+ node.send(msg);
20
+ } catch (error) {
21
+ console.error(error)
22
+ node.error(`Invalid Attributes object: ${_data}`)
23
+ }
24
+
15
25
  });
16
26
  }
17
27
  RED.nodes.registerType('generic', generic);
@@ -508,7 +508,7 @@
508
508
  <div class="form-row">
509
509
  <label for="node-input-dubSay">Say Text</label>
510
510
  <input type="text" id="node-input-dubSay" placeholder="Text">
511
- <input type="hidden" id="node-input-tagType">
511
+ <input type="hidden" id="node-input-dubSayType">
512
512
  </div>
513
513
  <div class="form-row">
514
514
  <label for="node-input-dubLoop">Loop</label>