@jambonz/node-red-contrib-jambonz 2.4.23 → 2.4.25

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.
@@ -0,0 +1,135 @@
1
+ <!-- Javascript -->
2
+ <script type="text/javascript">
3
+ var mustacheType = {
4
+ value: 'mustache',
5
+ label: 'mustache',
6
+ hasvalue: true,
7
+ icon: 'resources/@jambonz/node-red-contrib-jambonz/icons/mustache.svg'
8
+ }
9
+ RED.nodes.registerType("dub", {
10
+ category: "jambonz",
11
+ color: "#bbabaa",
12
+ defaults: {
13
+ name: { value: "" },
14
+ action: { value: "addTrack" },
15
+ track: { value: "" },
16
+ trackType: { value: "str" },
17
+ play: { value: "" },
18
+ playType: { value: "str" },
19
+ say: { value: "" },
20
+ sayType: { value: "str" },
21
+ loop: { value: false },
22
+ gain: {
23
+ value: "",
24
+ validate: function (v) {
25
+ if (v.length) {
26
+ return v.match(/([+-]?\d+(\.\d+)?)\s*db/i) !== null;
27
+ }
28
+ return true;
29
+ },
30
+ },
31
+ },
32
+ inputs: 1,
33
+ outputs: 1,
34
+ icon: "font-awesome/fa-cubes",
35
+ label: function () {
36
+ return this.name || "dub";
37
+ },
38
+ oneditprepare: function () {
39
+ var node = this;
40
+ $("#node-input-track").typedInput({
41
+ types: ["str", "msg", "flow", "global", "jsonata", "env", mustacheType],
42
+ typeField: $("#node-input-trackType"),
43
+ });
44
+ $("#node-input-play").typedInput({
45
+ types: ["str", "msg", "flow", "global", "jsonata", "env", mustacheType],
46
+ typeField: $("#node-input-playType"),
47
+ });
48
+ $("#node-input-say").typedInput({
49
+ types: ["str", "msg", "flow", "global", "jsonata", "env", mustacheType],
50
+ typeField: $("#node-input-sayType"),
51
+ });
52
+ },
53
+ });
54
+ </script>
55
+
56
+ <!-- HTML -->
57
+ <script type="text/html" data-template-name="dub">
58
+ <div class="form-row">
59
+ <label for="node-input-name"><i class="icon-tag"></i> Name</label>
60
+ <input type="text" id="node-input-name" placeholder="Name" />
61
+ </div>
62
+ <div class="form-row">
63
+ <label for="node-input-action">Action</label>
64
+ <select id="node-input-action">
65
+ <option value="addTrack">addTrack</option>
66
+ <option value="removeTrack">removeTrack</option>
67
+ <option value="silenceTrack">silenceTrack</option>
68
+ <option value="playOnTrack">playOnTrack</option>
69
+ <option value="sayOnTrack">sayOnTrack</option>
70
+ </select>
71
+ </div>
72
+ <div class="form-row">
73
+ <label for="node-input-track">Track</label>
74
+ <input type="text" id="node-input-track" placeholder="The label for the track">
75
+ <input type="hidden" id="node-input-trackType">
76
+ </div>
77
+ <div class="form-row">
78
+ <label for="node-input-play">Play</label>
79
+ <input type="text" id="node-input-play" placeholder="The http(s) url to an mp3 file">
80
+ <input type="hidden" id="node-input-playType">
81
+ </div>
82
+ <div class="form-row">
83
+ <label for="node-input-say">Say</label>
84
+ <input type="text" id="node-input-say" placeholder="The label for the play">
85
+ <input type="hidden" id="node-input-sayType">
86
+ </div>
87
+ <div class="form-row">
88
+ <label for="node-input-loop">Loop</label>
89
+ <input type="checkbox" id="node-input-loop" />
90
+ </div>
91
+ <div class="form-row">
92
+ <label for="node-input-gain">Gain</label>
93
+ <input
94
+ type="text"
95
+ id="node-input-gain"
96
+ placeholder="The value must be between +- 50 dB"
97
+ />
98
+ </div>
99
+ </script>
100
+
101
+ <!-- Help Text -->
102
+ <script type="text/html" data-help-name="dub">
103
+ <p>Adds one or more additional audio tracks</p>
104
+ <h3>Inputs</h3>
105
+ <h3>Properties</h3>
106
+ <p>
107
+ <code>Action</code> - One of 'addTrack', 'removeTrack', 'silenceTrack',
108
+ 'playOnTrack', or 'sayOnTrack'.
109
+ </p>
110
+ <p><code>Track</code> - Label for the track</p>
111
+ <p>
112
+ <code>Play</code> - An http(s) url to an mp3 file to play into the track
113
+ </p>
114
+ <p><code>Loop</code> - Loop the mp3</p>
115
+ <p>
116
+ <code>Gain</code> - Decibels to boost or reduce the strength of the audio
117
+ signal
118
+ </p>
119
+
120
+ <h3>Details</h3>
121
+ The dub verb adds one or more additional audio tracks into the conversation
122
+ (currently, a max of two additional audio tracks may be added). Audio can then
123
+ be inserted into these tracks and it will be blended with the play or say
124
+ content being sent to the caller/called party. The source of the audio content
125
+ can be either text to speech or mp3 audio accessible via http(s).
126
+
127
+ <h3>References</h3>
128
+ <ul>
129
+ <li>
130
+ <a href="https://www.jambonz.org/docs/webhooks/dub/"
131
+ >Jambonz dub reference</a
132
+ >
133
+ </li>
134
+ </ul>
135
+ </script>
@@ -0,0 +1,24 @@
1
+ var {appendVerb, new_resolve} = require('./libs')
2
+
3
+ module.exports = function(RED) {
4
+ /** dub */
5
+ function dub(config) {
6
+ RED.nodes.createNode(this, config);
7
+ var node = this;
8
+
9
+ node.on('input', async function(msg) {
10
+ var obj = {
11
+ verb: 'dub',
12
+ action: config.action,
13
+ track: await new_resolve(RED, config.track, config.trackType, node, msg),
14
+ play: await new_resolve(RED, config.play, config.playType, node, msg),
15
+ say: await new_resolve(RED, config.say, config.sayType, node, msg),
16
+ loop: config.loop,
17
+ gain: config.gain
18
+ };
19
+ appendVerb(msg, obj);
20
+ node.send(msg);
21
+ });
22
+ }
23
+ RED.nodes.registerType('dub', dub);
24
+ }
@@ -5,13 +5,13 @@ module.exports = function(RED) {
5
5
  function enqueue(config) {
6
6
  RED.nodes.createNode(this, config);
7
7
  var node = this;
8
- node.on('input', function(msg, send, done) {
8
+ node.on('input', async function(msg, send, done) {
9
9
  appendVerb(msg, {
10
10
  verb: 'enqueue',
11
- name: new_resolve(RED, config.queue, config.queueType, node, msg),
12
- priority: new_resolve(RED, config.priority, config.priorityType, node, msg),
13
- actionHook: new_resolve(RED, config.actionHook, config.actionHookType, node, msg),
14
- waitHook: new_resolve(RED, config.waitHook, config.waitHookType, node, msg)
11
+ name: await new_resolve(RED, config.queue, config.queueType, node, msg),
12
+ priority: await new_resolve(RED, config.priority, config.priorityType, node, msg),
13
+ actionHook: await new_resolve(RED, config.actionHook, config.actionHookType, node, msg),
14
+ waitHook: await new_resolve(RED, config.waitHook, config.waitHookType, node, msg)
15
15
  });
16
16
  node.send(msg);
17
17
  });
@@ -5,14 +5,14 @@ module.exports = function(RED) {
5
5
  function gather(config) {
6
6
  RED.nodes.createNode(this, config);
7
7
  var node = this;
8
- node.on('input', function(msg) {
8
+ node.on('input', async function(msg) {
9
9
 
10
10
  // simple properties
11
11
  node.log(`config: ${JSON.stringify(config)}`);
12
12
 
13
13
  var obj = {verb: 'gather', input: []};
14
- if (config.actionhook) obj.actionHook = new_resolve(RED, config.actionhook, config.actionhookType, node, msg)
15
- if (config.partialresulthook) obj.partialResultHook = new_resolve(RED, config.partialresulthook, config.partialresulthookType, node, msg)
14
+ if (config.actionhook) obj.actionHook = await new_resolve(RED, config.actionhook, config.actionhookType, node, msg)
15
+ if (config.partialresulthook) obj.partialResultHook = await new_resolve(RED, config.partialresulthook, config.partialresulthookType, node, msg)
16
16
 
17
17
  // input
18
18
  if (config.speechinput) {
@@ -22,9 +22,9 @@ module.exports = function(RED) {
22
22
  language: config.recognizerlang
23
23
  };
24
24
  if (recognizer.vendor === 'google') {
25
- var hints = new_resolve(RED, config.transcriptionhints, config.transcriptionhintsType, node, msg);
26
- var altlangs = new_resolve(RED, config.recognizeraltlang, config.recognizeraltlangType, node, msg);
27
- var naics = new_resolve(RED, config.naics, config.naicsType, node, msg);
25
+ var hints = await new_resolve(RED, config.transcriptionhints, config.transcriptionhintsType, node, msg);
26
+ var altlangs = await new_resolve(RED, config.recognizeraltlang, config.recognizeraltlangType, node, msg);
27
+ var naics = await new_resolve(RED, config.naics, config.naicsType, node, msg);
28
28
  Object.assign(recognizer, {
29
29
  profanityFilter: config.profanityfilter,
30
30
  hints: hints.length > 0 ?
@@ -37,8 +37,8 @@ module.exports = function(RED) {
37
37
  }
38
38
  }
39
39
  else if (recognizer.vendor === 'aws') {
40
- var vocab = new_resolve(RED, config.vocabularyname, config.vocabularynameType, node, msg);
41
- var vocabFilter = new_resolve(RED, config.vocabularyfiltername, config.vocabularyfilternameType, node, msg);
40
+ var vocab = await new_resolve(RED, config.vocabularyname, config.vocabularynameType, node, msg);
41
+ var vocabFilter = await new_resolve(RED, config.vocabularyfiltername, config.vocabularyfilternameType, node, msg);
42
42
  Object.assign(recognizer, {
43
43
  vocabularyName: vocab,
44
44
  vocabularyFilterName: vocabFilter,
@@ -74,7 +74,7 @@ module.exports = function(RED) {
74
74
  });
75
75
  }
76
76
  }
77
- else obj.play = {url: new_resolve(RED, config.playurl, config.playurlType, node, msg)};
77
+ else obj.play = {url: await new_resolve(RED, config.playurl, config.playurlType, node, msg)};
78
78
 
79
79
  node.log(`gather: ${JSON.stringify(obj)}`);
80
80
 
@@ -7,11 +7,11 @@ module.exports = function(RED) {
7
7
  var node = this;
8
8
  const server = RED.nodes.getNode(config.server);
9
9
  const {accountSid, apiToken} = server.credentials;
10
- node.on('input', async(msg, send, done) => {
10
+ node.on('input', async (msg, send, done) => {
11
11
  const data = {
12
- page: new_resolve(RED, config.page, config.pageType, node, msg),
13
- count: new_resolve(RED, config.count, config.countType, node, msg),
14
- days: new_resolve(RED, config.days, config.daysType, node, msg),
12
+ page: await new_resolve(RED, config.page, config.pageType, node, msg),
13
+ count: await new_resolve(RED, config.count, config.countType, node, msg),
14
+ days: await new_resolve(RED, config.days, config.daysType, node, msg),
15
15
  }
16
16
  Object.keys(data).forEach((k) => data[k] == null || data[k] == '' && delete data[k]);
17
17
  const params = new URLSearchParams(data).toString()
@@ -8,7 +8,7 @@ module.exports = function (RED) {
8
8
  const server = RED.nodes.getNode(config.server);
9
9
  const { accountSid, apiToken } = server.credentials;
10
10
  node.on("input", async (msg, send, done) => {
11
- const callSid = new_resolve(RED, config.callSid, config.callSidType, node, msg);
11
+ const callSid = await new_resolve(RED, config.callSid, config.callSidType, node, msg);
12
12
  if (!callSid) {
13
13
  if (done) done(new Error('CallSid empty'));
14
14
  else node.error(new Error('CallSid empty'), msg);
@@ -9,10 +9,10 @@ module.exports = function (RED) {
9
9
  const { accountSid, apiToken } = server.credentials;
10
10
  node.on("input", async (msg, send, done) => {
11
11
  const data = {
12
- direction: new_resolve(RED, config.direction, config.directionType, node, msg),
13
- from: new_resolve(RED, config.from, config.fromType, node, msg),
14
- to: new_resolve(RED, config.to, config.toType, node, msg),
15
- callStatus: new_resolve(RED, config.callStatus, config.callStatusType, node, msg),
12
+ direction: await new_resolve(RED, config.direction, config.directionType, node, msg),
13
+ from: await new_resolve(RED, config.from, config.fromType, node, msg),
14
+ to: await new_resolve(RED, config.to, config.toType, node, msg),
15
+ callStatus: await new_resolve(RED, config.callStatus, config.callStatusType, node, msg),
16
16
  };
17
17
  Object.keys(data).forEach(
18
18
  (k) => data[k] == null || (data[k] == '' && delete data[k])
@@ -7,13 +7,13 @@ module.exports = function(RED) {
7
7
  var node = this;
8
8
  const server = RED.nodes.getNode(config.server);
9
9
  const {accountSid, apiToken} = server.credentials;
10
- node.on('input', async(msg, send, done) => {
10
+ node.on('input', async (msg, send, done) => {
11
11
  const data = {
12
- direction: new_resolve(RED, config.direction, config.directionType, node, msg),
13
- trunk: new_resolve(RED, config.trunk, config.trunkType, node, msg),
14
- page: new_resolve(RED, config.page, config.pageType, node, msg),
15
- count: new_resolve(RED, config.count, config.countType, node, msg),
16
- days: new_resolve(RED, config.days, config.daysType, node, msg),
12
+ direction: await new_resolve(RED, config.direction, config.directionType, node, msg),
13
+ trunk: await new_resolve(RED, config.trunk, config.trunkType, node, msg),
14
+ page: await new_resolve(RED, config.page, config.pageType, node, msg),
15
+ count: await new_resolve(RED, config.count, config.countType, node, msg),
16
+ days: await new_resolve(RED, config.days, config.daysType, node, msg),
17
17
  }
18
18
  Object.keys(data).forEach((k) => data[k] == null || data[k] == '' && delete data[k]);
19
19
  const params = new URLSearchParams(data).toString();
@@ -4,7 +4,7 @@ module.exports = function(RED) {
4
4
  function hangup(config) {
5
5
  RED.nodes.createNode(this, config);
6
6
  var node = this;
7
- node.on('input', function(msg) {
7
+ node.on('input', async function(msg) {
8
8
  var data = {
9
9
  verb: 'hangup'
10
10
  };
package/src/nodes/lcc.js CHANGED
@@ -8,12 +8,12 @@ function lcc(config) {
8
8
  var node = this;
9
9
  const server = RED.nodes.getNode(config.server);
10
10
 
11
- node.on('input', async(msg, send, done) => {
11
+ node.on('input', async (msg, send, done) => {
12
12
  send = send || function() { node.send.apply(node, arguments);};
13
13
 
14
14
  const {accountSid, apiToken} = server.credentials;
15
15
  const url = server.url;
16
- const callSid = new_resolve(RED, config.callSid, config.callSidType, node, msg);
16
+ const callSid = await new_resolve(RED, config.callSid, config.callSidType, node, msg);
17
17
  if (!url || !accountSid || !apiToken || !callSid) {
18
18
  node.log(`invalid / missing credentials or callSid, skipping LCC node: ${JSON.stringify(server.credentials)}`);
19
19
  send(msg);
@@ -51,14 +51,14 @@ function lcc(config) {
51
51
  opts.transcribe_status = 'resume';
52
52
  break;
53
53
  case 'redirect':
54
- opts.call_hook = {url: new_resolve(RED, config.callHook, config.callHookType, node, msg)};
54
+ opts.call_hook = {url: await new_resolve(RED, config.callHook, config.callHookType, node, msg)};
55
55
  if (config.childCallHook) {
56
- opts.child_call_hook = {url: new_resolve(RED, config.childCallHook, config.childCallHookType, node, msg)};
56
+ opts.child_call_hook = {url: await new_resolve(RED, config.childCallHook, config.childCallHookType, node, msg)};
57
57
  }
58
58
  break;
59
59
  case 'hold_conf':
60
60
  opts.conf_hold_status = 'hold';
61
- opts.wait_hook = {url: new_resolve(RED, config.waitHook, config.waitHookType, node, msg)};
61
+ opts.wait_hook = {url: await new_resolve(RED, config.waitHook, config.waitHookType, node, msg)};
62
62
  break;
63
63
  case 'unhold_conf':
64
64
  opts.conf_hold_status = 'unhold';
@@ -82,16 +82,16 @@ function lcc(config) {
82
82
  case 'sip_request':
83
83
  opts.sip_request = {
84
84
  method: config.sipRequestMethod,
85
- content_type: new_resolve(RED, config.sipRequestContentType, config.sipRequestContentTypeType, node, msg),
86
- content: new_resolve(RED, config.sipRequestBody, config.sipRequestBodyType, node, msg),
87
- headers: new_resolve(RED, config.sipRequestHeaders, config.sipRequestHeadersType, node, msg) || {}
85
+ content_type: await new_resolve(RED, config.sipRequestContentType, config.sipRequestContentTypeType, node, msg),
86
+ content: await new_resolve(RED, config.sipRequestBody, config.sipRequestBodyType, node, msg),
87
+ headers: await new_resolve(RED, config.sipRequestHeaders, config.sipRequestHeadersType, node, msg) || {}
88
88
  };
89
89
  break;
90
90
  case 'start_call_recording':
91
91
  opts.record = {
92
92
  action: 'startCallRecording',
93
- siprecServerURL: new_resolve(RED, config.siprecServerURL, config.siprecServerURLType, node, msg),
94
- recordingID: new_resolve(RED, config.recordingID, config.recordingIDType, node, msg) || crypto.randomUUID()
93
+ siprecServerURL: await new_resolve(RED, config.siprecServerURL, config.siprecServerURLType, node, msg),
94
+ recordingID: await new_resolve(RED, config.recordingID, config.recordingIDType, node, msg) || crypto.randomUUID()
95
95
  };
96
96
  // SIPREC headers
97
97
  if (config.siprecHeaders) {
@@ -115,12 +115,12 @@ function lcc(config) {
115
115
  break;
116
116
  case 'send_dtmf':
117
117
  opts.dtmf = {
118
- digit: new_resolve(RED, config.dtmfDigit, config.dtmfDigitType, node, msg),
119
- duration: new_resolve(RED, config.dtmfDuration, config.dtmfDurationType, node, msg) || '250'
118
+ digit: await new_resolve(RED, config.dtmfDigit, config.dtmfDigitType, node, msg),
119
+ duration: await new_resolve(RED, config.dtmfDuration, config.dtmfDurationType, node, msg) || '250'
120
120
  };
121
121
  break;
122
122
  case 'tag':
123
- opts.tag = new_resolve(RED, config.tag, config.tagType, node, msg);
123
+ opts.tag = await new_resolve(RED, config.tag, config.tagType, node, msg);
124
124
  break;
125
125
  default:
126
126
  node.log(`invalid action: ${config.action}`);
package/src/nodes/lex.js CHANGED
@@ -6,27 +6,27 @@ module.exports = function(RED) {
6
6
  RED.nodes.createNode(this, config);
7
7
  var node = this;
8
8
  const awsCreds = RED.nodes.getNode(config.aws);
9
- node.on('input', function(msg) {
9
+ node.on('input', async function(msg) {
10
10
  let accessKey, secretAccessKey;
11
11
  if (awsCreds && awsCreds.credentials) {
12
12
  accessKey = awsCreds.credentials.accessKey;
13
13
  secretAccessKey = awsCreds.credentials.secretAccessKey;
14
14
  }
15
- var eventHook = new_resolve(RED, config.eventHook, config.eventHookType, node, msg);
16
- var actionHook = new_resolve(RED, config.actionHook, config.actionHookType, node, msg);
17
- var botId = new_resolve(RED, config.bot, config.botType, node, msg);
18
- var botAlias = new_resolve(RED, config.alias, config.aliasType, node, msg);
19
- var locale = new_resolve(RED, config.locale, config.localeType, node, msg) || 'en_US';
20
- var val = new_resolve(RED, config.inputTimeout, config.inputTimeoutType, node, msg);
15
+ var eventHook = await new_resolve(RED, config.eventHook, config.eventHookType, node, msg);
16
+ var actionHook = await new_resolve(RED, config.actionHook, config.actionHookType, node, msg);
17
+ var botId = await new_resolve(RED, config.bot, config.botType, node, msg);
18
+ var botAlias = await new_resolve(RED, config.alias, config.aliasType, node, msg);
19
+ var locale = await new_resolve(RED, config.locale, config.localeType, node, msg) || 'en_US';
20
+ var val = await new_resolve(RED, config.inputTimeout, config.inputTimeoutType, node, msg);
21
21
  var timeout = /^\d+$/.test(val) ? parseInt(val) : 0;
22
22
  var slots, intentName;
23
23
  if (config.specifyIntent) {
24
- intentName = new_resolve(RED, config.intent, config.intentType, node, msg);
24
+ intentName = await new_resolve(RED, config.intent, config.intentType, node, msg);
25
25
  if (intentName) {
26
- slots = new_resolve(RED, config.slots, config.slotsType, node, msg);
26
+ slots = await new_resolve(RED, config.slots, config.slotsType, node, msg);
27
27
  }
28
28
  }
29
- var metadata = new_resolve(RED, config.metadata, config.metadataType, node, msg);
29
+ var metadata = await new_resolve(RED, config.metadata, config.metadataType, node, msg);
30
30
 
31
31
  const obj = {
32
32
  verb: 'lex',
package/src/nodes/libs.js CHANGED
@@ -45,7 +45,7 @@ exports.appendVerb = (msg, obj) => {
45
45
  return mustache.render('{{' + val + '}}', data);
46
46
  }
47
47
 
48
- exports.new_resolve = (RED, val, valtype, node, msg) => {
48
+ exports.new_resolve = async (RED, val, valtype, node, msg) => {
49
49
  if (!val || !valtype) return val;
50
50
  switch (valtype) {
51
51
  case 'str':
@@ -56,7 +56,12 @@ exports.appendVerb = (msg, obj) => {
56
56
  case 'flow':
57
57
  case 'global':
58
58
  case 'jsonata':
59
- return RED.util.evaluateNodeProperty(val, valtype, node, msg);
59
+ try {
60
+ return await asyncEvaluateNodeProperty(RED, val, valtype, node, msg);
61
+ } catch (e) {
62
+ node.error(`Error evaluating ${valtype} property: ${e.message}`);
63
+ return null;
64
+ }
60
65
  case 'mustache':
61
66
  let data = dataobject(node.context(), msg);
62
67
  return mustache.render(val, data);
@@ -64,6 +69,19 @@ exports.appendVerb = (msg, obj) => {
64
69
  return JSON.parse(val);
65
70
  }
66
71
  }
72
+
73
+ function asyncEvaluateNodeProperty(RED, value, type, node, msg) {
74
+ return new Promise(function (resolve, reject) {
75
+ RED.util.evaluateNodeProperty(value, type, node, msg, function (e, r) {
76
+ if (e) {
77
+ reject(e);
78
+ } else {
79
+ resolve(r);
80
+ }
81
+ });
82
+ });
83
+ }
84
+
67
85
  function dataobject(context, msg){
68
86
  let data = Object.assign({}, msg);
69
87
  data.global = {};
@@ -4,11 +4,11 @@ module.exports = function(RED) {
4
4
  function listen(config) {
5
5
  RED.nodes.createNode(this, config);
6
6
  var node = this;
7
- node.on('input', function(msg) {
7
+ node.on('input', async function(msg) {
8
8
  const obj = {
9
9
  verb: 'listen',
10
- url: new_resolve(RED, config.url, config.urlType, node, msg),
11
- actionHook: new_resolve(RED, config.actionhook, config.actionhookType, node, msg),
10
+ url: await new_resolve(RED, config.url, config.urlType, node, msg),
11
+ actionHook: await new_resolve(RED, config.actionhook, config.actionhookType, node, msg),
12
12
  finishOnKey: config.finishonkey,
13
13
  mixType: config.mixtype,
14
14
  playBeep: config.beep,
@@ -17,8 +17,8 @@ module.exports = function(RED) {
17
17
  sampleRate: config.sampleRate,
18
18
  };
19
19
 
20
- const authUser = new_resolve(RED, config.authuser, config.authuserType, node, msg);
21
- const authPass = new_resolve(RED, config.authpass, config.authpassType, node, msg);
20
+ const authUser = await new_resolve(RED, config.authuser, config.authuserType, node, msg);
21
+ const authPass = await new_resolve(RED, config.authpass, config.authpassType, node, msg);
22
22
  if (authUser && authPass) {
23
23
  obj.wsAuth = {
24
24
  username: authUser,
@@ -35,11 +35,11 @@ module.exports = function(RED) {
35
35
  diarization: config.diarization
36
36
  };
37
37
  if (recognizer.vendor === 'google') {
38
- var diarizationMin = new_resolve(RED, config.diarizationmin, config.diarizationminType, node, msg);
39
- var diarizationMax = new_resolve(RED, config.diarizationmax, config.diarizationmaxType, node, msg);
40
- var hints = new_resolve(RED, config.transcriptionhints, config.transcriptionhintsType, node, msg);
41
- var altlangs = new_resolve(RED, config.recognizeraltlang, config.recognizeraltlangType, node, msg);
42
- var naics = new_resolve(RED, config.naics, config.naicsType, node, msg);
38
+ var diarizationMin = await new_resolve(RED, config.diarizationmin, config.diarizationminType, node, msg);
39
+ var diarizationMax = await new_resolve(RED, config.diarizationmax, config.diarizationmaxType, node, msg);
40
+ var hints = await new_resolve(RED, config.transcriptionhints, config.transcriptionhintsType, node, msg);
41
+ var altlangs = await new_resolve(RED, config.recognizeraltlang, config.recognizeraltlangType, node, msg);
42
+ var naics = await new_resolve(RED, config.naics, config.naicsType, node, msg);
43
43
  Object.assign(recognizer, {
44
44
  profanityFilter: config.profanityfilter,
45
45
  hints: hints.length > 0 ?
@@ -60,8 +60,8 @@ module.exports = function(RED) {
60
60
  }
61
61
  }
62
62
  else if (recognizer.vendor === 'aws') {
63
- var vocab = new_resolve(RED, config.vocabularyname, config.vocabularynameType, node, msg);
64
- var vocabFilter = new_resolve(RED, config.vocabularyfiltername, config.vocabularyfilternameType, node, msg);
63
+ var vocab = await new_resolve(RED, config.vocabularyname, config.vocabularynameType, node, msg);
64
+ var vocabFilter = await new_resolve(RED, config.vocabularyfiltername, config.vocabularyfilternameType, node, msg);
65
65
  Object.assign(recognizer, {
66
66
  vocabularyName: vocab,
67
67
  vocabularyFilterName: vocabFilter,
@@ -69,7 +69,7 @@ module.exports = function(RED) {
69
69
  });
70
70
  }
71
71
  obj.transcribe = {
72
- transcriptionHook: new_resolve(RED, config.transcriptionhook, config.transcriptionhookType, node, msg),
72
+ transcriptionHook: await new_resolve(RED, config.transcriptionhook, config.transcriptionhookType, node, msg),
73
73
  recognizer
74
74
  };
75
75
  }
@@ -77,7 +77,7 @@ module.exports = function(RED) {
77
77
  if (/^\d+$/.test(config.maxlength)) obj.maxLength = parseInt(config.maxLength);
78
78
  if (config.finishonkey.length) obj.finishOnKey = config.finishonkey;
79
79
 
80
- var data = new_resolve(RED, config.metadata, config.metadataType, node, msg);
80
+ var data = await new_resolve(RED, config.metadata, config.metadataType, node, msg);
81
81
  if (data) obj.metadata = data;
82
82
 
83
83
  appendVerb(msg, obj);
@@ -4,11 +4,11 @@ module.exports = function (RED) {
4
4
  function message(config) {
5
5
  RED.nodes.createNode(this, config);
6
6
  var node = this;
7
- node.on("input", function (msg, send, done) {
8
- var from = new_resolve(RED, config.from, config.fromType, node, msg);
9
- var to =new_resolve(RED, config.to, config.toType, node, msg);
10
- var text = new_resolve(RED, config.text, config.textType, node, msg);
11
- var provider = new_resolve(RED, config.provider, config.providerType, node, msg);
7
+ node.on("input", async function(msg, send, done) {
8
+ var from = await new_resolve(RED, config.from, config.fromType, node, msg);
9
+ var to = await new_resolve(RED, config.to, config.toType, node, msg);
10
+ var text = await new_resolve(RED, config.text, config.textType, node, msg);
11
+ var provider = await new_resolve(RED, config.provider, config.providerType, node, msg);
12
12
  if ((!provider || 0 === provider.length) && msg.sms.provider) {
13
13
  provider = msg.sms.provider;
14
14
  }
@@ -5,8 +5,8 @@ module.exports = function(RED) {
5
5
  function pause(config) {
6
6
  RED.nodes.createNode(this, config);
7
7
  var node = this;
8
- node.on('input', function(msg) {
9
- var length = new_resolve(RED, config.len, config.lenType, node, msg);
8
+ node.on('input', async function(msg) {
9
+ var length = await new_resolve(RED, config.len, config.lenType, node, msg);
10
10
  appendVerb(msg, {
11
11
  verb: 'pause',
12
12
  length
package/src/nodes/play.js CHANGED
@@ -4,15 +4,15 @@ module.exports = function(RED) {
4
4
  function play(config) {
5
5
  RED.nodes.createNode(this, config);
6
6
  var node = this;
7
- node.on('input', function(msg) {
7
+ node.on('input', async function(msg) {
8
8
  appendVerb(msg, {
9
9
  verb: 'play',
10
- url: new_resolve(RED, config.url, config.urlType, node, msg),
10
+ url: await new_resolve(RED, config.url, config.urlType, node, msg),
11
11
  earlyMedia: config.early,
12
12
  loop: config.loop,
13
- timeoutSecs: config.timeout ? new_resolve(RED, config.timeout, config.timeoutType, node, msg) : null,
14
- seekOffset: config.offset ? new_resolve(RED, config.offset, config.offsetType, node, msg) : null,
15
- actionHook: config.hook ? new_resolve(RED, config.hook, config.hookType, node, msg) : null
13
+ timeoutSecs: config.timeout ? await new_resolve(RED, config.timeout, config.timeoutType, node, msg) : null,
14
+ seekOffset: config.offset ? await new_resolve(RED, config.offset, config.offsetType, node, msg) : null,
15
+ actionHook: config.hook ? await new_resolve(RED, config.hook, config.hookType, node, msg) : null
16
16
  });
17
17
  node.send(msg);
18
18
  });
package/src/nodes/rasa.js CHANGED
@@ -4,12 +4,12 @@ module.exports = function(RED) {
4
4
  function rasa(config) {
5
5
  RED.nodes.createNode(this, config);
6
6
  var node = this;
7
- node.on('input', function(msg) {
7
+ node.on('input', async function(msg) {
8
8
  obj = {verb: 'rasa'}
9
- obj.url = new_resolve(RED, config.url, config.urlType, node, msg);
10
- obj.prompt = new_resolve(RED, config.prompt, config.promptType, node, msg);
11
- obj.eventHook = new_resolve(RED, config.eventHook, config.eventHookType, node, msg);
12
- obj.actionHook = new_resolve(RED, config.actionHook, config.actionHookType, node, msg);
9
+ obj.url = await new_resolve(RED, config.url, config.urlType, node, msg);
10
+ obj.prompt = await new_resolve(RED, config.prompt, config.promptType, node, msg);
11
+ obj.eventHook = await new_resolve(RED, config.eventHook, config.eventHookType, node, msg);
12
+ obj.actionHook = await new_resolve(RED, config.actionHook, config.actionHookType, node, msg);
13
13
  appendVerb(msg, obj);
14
14
  node.send(msg);
15
15
  });
@@ -5,8 +5,8 @@ module.exports = function(RED) {
5
5
  function redirect(config) {
6
6
  RED.nodes.createNode(this, config);
7
7
  var node = this;
8
- node.on('input', function(msg, send, done) {
9
- var actionHook = new_resolve(RED, config.hook, config.hookType, node, msg);
8
+ node.on('input', async function(msg, send, done) {
9
+ var actionHook = await new_resolve(RED, config.hook, config.hookType, node, msg);
10
10
  appendVerb(msg, {
11
11
  verb: 'redirect',
12
12
  actionHook
package/src/nodes/say.js CHANGED
@@ -9,8 +9,8 @@ module.exports = function(RED) {
9
9
  this.loop = config.loop;
10
10
  var node = this;
11
11
 
12
- node.on('input', function(msg) {
13
- const text = new_resolve(RED, config.text, 'mustache', node, msg);
12
+ node.on('input', async function(msg) {
13
+ const text = await new_resolve(RED, config.text, 'mustache', node, msg);
14
14
  var obj = {
15
15
  verb: 'say',
16
16
  text,
@@ -5,15 +5,15 @@ module.exports = function(RED) {
5
5
  function sip_decline(config) {
6
6
  RED.nodes.createNode(this, config);
7
7
  var node = this;
8
- node.on('input', function(msg) {
9
- var status = new_resolve(RED, config.status, config.statusType, node, msg);
10
- var reason = new_resolve(RED, config.reason, config.reasonType, node, msg);
8
+ node.on('input', async function(msg) {
9
+ var status = await new_resolve(RED, config.status, config.statusType, node, msg);
10
+ var reason = await new_resolve(RED, config.reason, config.reasonType, node, msg);
11
11
  var obj = {
12
12
  verb: 'sip:decline',
13
13
  status: parseInt(status),
14
14
  reason
15
15
  }
16
- config.headers ? obj.headers = new_resolve(RED, config.headers, config.headersType, node, msg) : null
16
+ config.headers ? obj.headers = await new_resolve(RED, config.headers, config.headersType, node, msg) : null
17
17
  if (typeof obj.headers == 'string'){
18
18
  obj.headers = JSON.parse(obj.headers)
19
19
  }