@jambonz/node-red-contrib-jambonz 2.3.2 → 2.3.4

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.3.2",
3
+ "version": "2.3.4",
4
4
  "description": "Node-RED nodes for jambonz platform",
5
5
  "keywords": [
6
6
  "node-red"
@@ -258,18 +258,21 @@
258
258
  <script type="text/html" data-help-name="create-call">
259
259
  <p>Create an outbound call</p>
260
260
  <h3>Properties</h3>
261
- <p><code>Server</code> -jambonz server to connect to</p>
261
+ <p><code>Server</code> - Jambonz server to connect to</p>
262
262
  <p><code>From</code> - Calling party phone number</p>
263
263
  <p><code>To</code> - Called party phone number, or other identifier</p>
264
264
  <p><code>Call type</code> - Type of destination: phone number, registered user, sip endpoint, or microsoft teams</p>
265
265
  <p><code>Application</code> - Application to execute when call is answered</p>
266
-
266
+ <p><code>Webhooks</code> - Webhooks to execute when call is answered</p>
267
+
267
268
  <h3>Outputs</h3>
268
269
  <dl class="message-properties">
269
270
  <dt>statusCode<span class="property-type">int</span></dt>
270
- <dd> <code>msg.statusCode</code> will contain the response code from Jambomnz to the createCall request</dd>
271
+ <dd> <code>msg.statusCode</code> will contain the response code from Jambonz to the createCall request</dd>
271
272
  <dt>callSid<span class="property-type">string</span></dt>
272
273
  <dd> <code>msg.callSid</code> will contain the SID of the call that was created</dd>
274
+ <dt>callId<span class="property-type">string</span></dt>
275
+ <dd> <code>msg.callId</code> will contain the call id of the call that was created</dd>
273
276
  </dl>
274
277
 
275
278
  <h3>Details</h3>
@@ -31,23 +31,23 @@ module.exports = function(RED) {
31
31
 
32
32
  switch (config.mode) {
33
33
  case 'app':
34
- opts.application_sid = config.application
34
+ opts.application_sid = config.application;
35
35
  break
36
36
  case 'url':
37
37
  opts.call_hook = {
38
- url: config.call_hook_url,
38
+ url: v_resolve(config.call_hook_url, config.call_hook_urlType, this.context(), msg),
39
39
  method: config.call_hook_method
40
- }
40
+ };
41
41
  opts.call_status_hook = {
42
- url: config.call_status_url,
42
+ url: v_resolve(config.call_status_url, config.call_status_urlType, this.context(), msg),
43
43
  method: config.call_status_method
44
- }
45
- opts.speech_synthesis_vendor = config.vendor
46
- opts.speech_synthesis_language = config.lang
47
- opts.speech_synthesis_voice = config.voice
48
- opts.speech_recognizer_vendor = config.transcriptionvendor
49
- opts.speech_recognizer_language = config.recognizerlang
50
- break
44
+ };
45
+ opts.speech_synthesis_vendor = config.vendor;
46
+ opts.speech_synthesis_language = config.lang;
47
+ opts.speech_synthesis_voice = config.voice;
48
+ opts.speech_recognizer_vendor = config.transcriptionvendor;
49
+ opts.speech_recognizer_language = config.recognizerlang;
50
+ break;
51
51
  }
52
52
 
53
53
  if (config.timeout) {
@@ -73,19 +73,25 @@ module.exports = function(RED) {
73
73
  send(msg);
74
74
  return;
75
75
  }
76
- node.log(JSON.stringify(opts))
77
76
  try {
77
+ node.log(`sending create call ${JSON.stringify(opts)}`);
78
78
  const res = await doCreateCall(url, accountSid, apiToken, opts);
79
- msg.statusCode = 202;
79
+ msg.statusCode = 201;
80
80
  msg.callSid = res.sid;
81
+ msg.callId = res.callId;
81
82
  } catch (err) {
82
83
  if (err.statusCode) {
83
- console.log(JSON.stringify(err))
84
- node.error(`create-call failed with ${err.statusCode}`);
84
+ node.log(JSON.stringify(err));
85
+ try {
86
+ const responseBody = await err.json();
87
+ node.error(`create-call failed with ${err.statusCode}. Response ${JSON.stringify(responseBody)}`);
88
+ } catch (e) {
89
+ node.error(`create-call failed with ${err.statusCode}`);
90
+ }
85
91
  msg.statusCode = err.statusCode;
86
92
  }
87
93
  else {
88
- node.error(`Error sending create all ${JSON.stringify(err)}`);
94
+ node.error(`Error sending create call ${JSON.stringify(err)}`);
89
95
  if (done) done(err);
90
96
  else node.error(err, msg);
91
97
  send(msg);
@@ -82,13 +82,22 @@
82
82
 
83
83
  <!-- Help Text -->
84
84
  <script type="text/html" data-help-name="create-sms">
85
- <p>Send an SMS</p>
86
- <h3>Properties</h3>
87
- <p><code>Server</code> - jambonz server to connect to</p>
88
- <p><code>From</code> - Sending party phone number</p>
89
- <p><code>To</code> - Destination phone number</p>
85
+ <p>Create an outbound SMS message</p>
86
+ <h3>Properties</h3>
87
+ <p><code>Server</code> - Jambonz server to connect to</p>
88
+ <p><code>From</code> - Sending party phone number</p>
89
+ <p><code>To</code> - Destination phone number</p>
90
90
  <p><code>Text</code> - Text message</p>
91
91
 
92
+ <h3>Outputs</h3>
93
+ <dl class="message-properties">
94
+ <dt>statusCode<span class="property-type">int</span></dt>
95
+ <dd> <code>msg.statusCode</code> will contain the response code from Jambonz to the createMessage request</dd>
96
+ <dt>messageSid<span class="property-type">string</span></dt>
97
+ <dd> <code>msg.messageSid</code> will contain the SID of the message that was created</dd>
98
+ <dt>providerResponse<span class="property-type">string</span></dt>
99
+ <dd> <code>msg.providerResponse</code> will contain the provider response of the call that was created</dd>
100
+ </dl>
92
101
  <h3>Details</h3>
93
- The create message command is used to send an SMS message.
102
+ The create message command is used to send an outbound SMS message.
94
103
  </script>
@@ -30,17 +30,21 @@ function create_sms(config) {
30
30
  text,
31
31
  provider
32
32
  };
33
-
34
33
  try {
35
34
  node.log(`sending create message ${JSON.stringify(opts)}`);
36
35
  const res = await doCreateMessage(url, accountSid, apiToken, opts);
37
- msg.statusCode = 202;
36
+ msg.statusCode = 201;
38
37
  msg.messageSid = res.sid;
39
38
  msg.providerResponse = res.providerResponse;
40
- node.log(`successfully launched call with messageSid ${msg.messageSid}`);
41
39
  } catch (err) {
42
40
  if (err.statusCode) {
43
- node.log(`create_message failed with ${err.statusCode}`);
41
+ node.log(JSON.stringify(err));
42
+ try {
43
+ const responseBody = await err.json();
44
+ node.error(`create_sms failed with ${err.statusCode}. Response ${JSON.stringify(responseBody)}`);
45
+ } catch (e) {
46
+ node.error(`create_sms failed with ${err.statusCode}`);
47
+ }
44
48
  msg.statusCode = err.statusCode;
45
49
  }
46
50
  else {
@@ -56,5 +60,4 @@ function create_sms(config) {
56
60
  });
57
61
  }
58
62
  RED.nodes.registerType('create-sms', create_sms);
59
-
60
63
  }