@jambonz/node-red-contrib-jambonz 2.3.0 → 2.3.2
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 +4 -4
- package/src/nodes/auth.html +9 -16
- package/src/nodes/auth.js +2 -9
- package/src/nodes/conference.html +12 -15
- package/src/nodes/conference.js +0 -4
- package/src/nodes/config.js +0 -4
- package/src/nodes/create_call.html +7 -16
- package/src/nodes/create_call.js +2 -6
- package/src/nodes/create_sms.html +3 -15
- package/src/nodes/create_sms.js +0 -5
- package/src/nodes/dequeue.html +6 -8
- package/src/nodes/dequeue.js +0 -4
- package/src/nodes/dial.html +20 -15
- package/src/nodes/dial.js +3 -5
- package/src/nodes/dialogflow.html +3 -13
- package/src/nodes/dialogflow.js +0 -5
- package/src/nodes/dtmf.html +5 -11
- package/src/nodes/dtmf.js +0 -5
- package/src/nodes/enqueue.html +7 -14
- package/src/nodes/enqueue.js +0 -6
- package/src/nodes/gather.html +7 -8
- package/src/nodes/gather.js +0 -5
- package/src/nodes/get_alerts.html +5 -27
- package/src/nodes/get_alerts.js +14 -16
- package/src/nodes/get_calls.html +6 -28
- package/src/nodes/get_calls.js +36 -36
- package/src/nodes/get_recent_calls.html +25 -27
- package/src/nodes/get_recent_calls.js +21 -21
- package/src/nodes/hangup.html +5 -11
- package/src/nodes/hangup.js +2 -7
- package/src/nodes/lcc.html +12 -19
- package/src/nodes/lcc.js +0 -4
- package/src/nodes/leave.html +4 -5
- package/src/nodes/leave.js +0 -6
- package/src/nodes/lex.html +5 -3
- package/src/nodes/lex.js +0 -5
- package/src/nodes/libs.js +2 -1
- package/src/nodes/listen.html +2 -3
- package/src/nodes/listen.js +0 -5
- package/src/nodes/message.html +5 -6
- package/src/nodes/message.js +30 -30
- package/src/nodes/pause.html +5 -8
- package/src/nodes/pause.js +0 -6
- package/src/nodes/play.html +7 -10
- package/src/nodes/play.js +0 -5
- package/src/nodes/rasa.html +5 -13
- package/src/nodes/rasa.js +1 -5
- package/src/nodes/redirect.html +4 -8
- package/src/nodes/redirect.js +0 -6
- package/src/nodes/s3-upload.html +0 -2
- package/src/nodes/s3-upload.js +1 -6
- package/src/nodes/say.html +9 -7
- package/src/nodes/say.js +0 -4
- package/src/nodes/sip-decline.html +5 -8
- package/src/nodes/sip-decline.js +0 -5
- package/src/nodes/sip-refer.html +4 -12
- package/src/nodes/sip-refer.js +1 -5
- package/src/nodes/sip-request.html +5 -11
- package/src/nodes/sip-request.js +1 -8
- package/src/nodes/tag.html +2 -4
- package/src/nodes/tag.js +0 -5
- package/src/nodes/template.html +7 -16
- package/src/nodes/userauth.html +47 -21
- package/src/nodes/userauth.js +18 -6
- package/src/nodes/webhooks.html +26 -29
- package/src/utils/http-helpers.js +5 -4
- package/src/utils/tts-utils.js +1 -0
package/src/nodes/dtmf.html
CHANGED
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
icon: "font-awesome/fa-cubes",
|
|
14
14
|
label: function() { return this.name || 'dtmf';},
|
|
15
15
|
oneditprepare: function() {
|
|
16
|
-
|
|
17
16
|
$('#node-input-dtmf').typedInput({
|
|
18
17
|
default: $('#node-input-dtmfType').val(),
|
|
19
18
|
types: ['str','msg', 'flow', 'global', 'jsonata', 'env'],
|
|
@@ -26,10 +25,8 @@
|
|
|
26
25
|
})
|
|
27
26
|
}
|
|
28
27
|
});
|
|
29
|
-
|
|
30
28
|
</script>
|
|
31
29
|
|
|
32
|
-
|
|
33
30
|
<!-- HTML -->
|
|
34
31
|
<script type="text/html" data-template-name="dtmf">
|
|
35
32
|
<div class="form-row">
|
|
@@ -49,26 +46,23 @@
|
|
|
49
46
|
</script>
|
|
50
47
|
|
|
51
48
|
<!-- Help Text -->
|
|
52
|
-
<script type="text/html" data-help-name="
|
|
49
|
+
<script type="text/html" data-help-name="dtmf">
|
|
53
50
|
<p>generates a string of dtmf digit signals</p>
|
|
54
51
|
<h3>Properties</h3>
|
|
55
52
|
<p><code>DTMF</code> - a string containing a sequence of dtmf digits (0-9,*,#)</p>
|
|
56
53
|
<p><code>Duration</code> - the length of each digit, in milliseconds, Defaults to 500</p>
|
|
57
|
-
|
|
58
54
|
|
|
59
55
|
<h3>Outputs</h3>
|
|
60
56
|
<dl class="message-properties">
|
|
61
|
-
|
|
62
|
-
|
|
57
|
+
<dt>jambonz<span class="property-type">object</span></dt>
|
|
58
|
+
<dd> <code>msg.jambonz</code> will contain any previous actions provided to the input with the new <code>play</code> action appended </dd>
|
|
63
59
|
</dl>
|
|
64
60
|
|
|
65
61
|
<h3>Details</h3>
|
|
66
62
|
The dtmf action generates a string of dtmf digit signals. These are sent as RTP payloads using RFC 2833.
|
|
67
63
|
|
|
68
|
-
|
|
69
|
-
|
|
70
64
|
<h3>References</h3>
|
|
71
65
|
<ul>
|
|
72
|
-
<li><a href="https://www.jambonz.org/docs/webhooks/dtmf/">Jambonz
|
|
66
|
+
<li><a href="https://www.jambonz.org/docs/webhooks/dtmf/">Jambonz dtmf reference</a></li>
|
|
73
67
|
</ul>
|
|
74
|
-
|
|
68
|
+
</script>
|
package/src/nodes/dtmf.js
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
var {createHash} = require('crypto');
|
|
2
|
-
const bent = require('bent');
|
|
3
|
-
var mustache = require('mustache');
|
|
4
|
-
mustache.escape = function(text) {return text;};
|
|
5
1
|
var {appendVerb} = require('./libs')
|
|
6
2
|
|
|
7
|
-
|
|
8
3
|
module.exports = function(RED) {
|
|
9
4
|
function dtmf(config) {
|
|
10
5
|
RED.nodes.createNode(this, config);
|
package/src/nodes/enqueue.html
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
<!-- Javascript -->
|
|
2
|
-
|
|
3
|
-
|
|
4
2
|
<script type="text/javascript">
|
|
5
3
|
RED.nodes.registerType('enqueue',{
|
|
6
4
|
category: 'jambonz',
|
|
@@ -35,12 +33,9 @@
|
|
|
35
33
|
});
|
|
36
34
|
}
|
|
37
35
|
});
|
|
38
|
-
|
|
39
36
|
</script>
|
|
40
37
|
|
|
41
|
-
|
|
42
38
|
<!-- HTML -->
|
|
43
|
-
|
|
44
39
|
<script type="text/html" data-template-name="enqueue">
|
|
45
40
|
<div class="form-row">
|
|
46
41
|
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
|
@@ -64,27 +59,25 @@
|
|
|
64
59
|
</script>
|
|
65
60
|
|
|
66
61
|
<!-- Help Text -->
|
|
67
|
-
|
|
68
62
|
<script type="text/html" data-help-name="enqueue">
|
|
69
63
|
<p>places a caller in a queue.</p>
|
|
70
64
|
<h3>Properties</h3>
|
|
71
65
|
<p><code>Queue name</code> -
|
|
72
|
-
|
|
66
|
+
The name of the queue</p>
|
|
73
67
|
<p><code>Action hook</code> -
|
|
74
|
-
|
|
68
|
+
A webhook invoke when operation completes.</p>
|
|
75
69
|
<p><code>Wait hook</code> -
|
|
76
|
-
|
|
77
|
-
|
|
70
|
+
A webhook to invoke while the caller is in queue. The only allowed verbs in the application returned from this webhook are say, play, pause, and leave,.</p>
|
|
78
71
|
<h3>Outputs</h3>
|
|
79
72
|
<dl class="message-properties">
|
|
80
|
-
|
|
81
|
-
|
|
73
|
+
<dt>jambonz<span class="property-type">object</span></dt>
|
|
74
|
+
<dd> <code>msg.jambonz</code> will contain any previous actions provided to the input with the new <code>enqueue</code> action appended </dd>
|
|
82
75
|
</dl>
|
|
83
76
|
|
|
84
77
|
<h3>Details</h3>
|
|
85
78
|
The enqueue command is used to place a caller in a queue.
|
|
86
79
|
<h3>References</h3>
|
|
87
80
|
<ul>
|
|
88
|
-
<li><a href="https://
|
|
81
|
+
<li><a href="https://www.jambonz.org/docs/webhooks/enqueue/">Jambonz enqueue reference</a></li>
|
|
89
82
|
</ul>
|
|
90
|
-
|
|
83
|
+
</script>
|
package/src/nodes/enqueue.js
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
var {createHash} = require('crypto');
|
|
2
|
-
const bent = require('bent');
|
|
3
|
-
var mustache = require('mustache');
|
|
4
|
-
mustache.escape = function(text) {return text;};
|
|
5
1
|
var {appendVerb, v_resolve} = require('./libs')
|
|
6
2
|
|
|
7
|
-
|
|
8
3
|
module.exports = function(RED) {
|
|
9
4
|
/** enqueue */
|
|
10
5
|
function enqueue(config) {
|
|
@@ -21,5 +16,4 @@ module.exports = function(RED) {
|
|
|
21
16
|
});
|
|
22
17
|
}
|
|
23
18
|
RED.nodes.registerType('enqueue', enqueue);
|
|
24
|
-
|
|
25
19
|
}
|
package/src/nodes/gather.html
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
<!-- Javascript -->
|
|
2
|
-
|
|
3
|
-
|
|
4
2
|
<script type="text/javascript">
|
|
5
3
|
RED.nodes.registerType('gather',{
|
|
6
4
|
category: 'jambonz',
|
|
@@ -113,12 +111,9 @@
|
|
|
113
111
|
$('#node-input-prompttype').change(onSayPlayChanged);
|
|
114
112
|
}
|
|
115
113
|
});
|
|
116
|
-
|
|
117
114
|
</script>
|
|
118
115
|
|
|
119
|
-
|
|
120
116
|
<!-- HTML -->
|
|
121
|
-
|
|
122
117
|
<script type="text/html" data-template-name="gather">
|
|
123
118
|
<div class="form-row">
|
|
124
119
|
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
|
@@ -276,7 +271,7 @@
|
|
|
276
271
|
</div>
|
|
277
272
|
</div>
|
|
278
273
|
</fieldset>
|
|
279
|
-
|
|
274
|
+
</script>
|
|
280
275
|
|
|
281
276
|
<!-- Help Text -->
|
|
282
277
|
<script type="text/html" data-help-name="gather">
|
|
@@ -315,8 +310,12 @@
|
|
|
315
310
|
|
|
316
311
|
<h3>Details</h3>
|
|
317
312
|
The gather command is used to collect dtmf or speech input.
|
|
313
|
+
|
|
314
|
+
Within the text field you can use mustache syntax to insert properties of the msg, flow or global objects.
|
|
315
|
+
For example if you wanted to insert the value of msg.payload into the text you could put
|
|
316
|
+
<code>The payload is {{msg.payload}}</code>
|
|
318
317
|
<h3>References</h3>
|
|
319
318
|
<ul>
|
|
320
|
-
<li><a href="https://
|
|
319
|
+
<li><a href="https://www.jambonz.org/docs/webhooks/gather/">Jambonz gather reference</a></li>
|
|
321
320
|
</ul>
|
|
322
|
-
|
|
321
|
+
</script>
|
package/src/nodes/gather.js
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
var {createHash} = require('crypto');
|
|
2
|
-
const bent = require('bent');
|
|
3
|
-
var mustache = require('mustache');
|
|
4
|
-
mustache.escape = function(text) {return text;};
|
|
5
1
|
var {appendVerb, v_resolve, v_text_resolve} = require('./libs')
|
|
6
2
|
|
|
7
|
-
|
|
8
3
|
module.exports = function(RED) {
|
|
9
4
|
/** gather */
|
|
10
5
|
function gather(config) {
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
<!-- Javascript -->
|
|
2
|
-
|
|
3
|
-
|
|
4
2
|
<script type="text/javascript">
|
|
5
|
-
|
|
3
|
+
RED.nodes.registerType('get_alerts',{
|
|
6
4
|
category: 'jambonz',
|
|
7
5
|
color: '#aebfb9',
|
|
8
6
|
defaults: {
|
|
@@ -13,7 +11,7 @@
|
|
|
13
11
|
count:{value: 25},
|
|
14
12
|
countType:{value: 'num'},
|
|
15
13
|
days:{value: 7},
|
|
16
|
-
|
|
14
|
+
daysType:{value: 'num'}
|
|
17
15
|
},
|
|
18
16
|
inputs:1,
|
|
19
17
|
outputs:1,
|
|
@@ -36,13 +34,9 @@
|
|
|
36
34
|
});
|
|
37
35
|
}
|
|
38
36
|
});
|
|
39
|
-
|
|
40
|
-
|
|
41
37
|
</script>
|
|
42
38
|
|
|
43
|
-
|
|
44
39
|
<!-- HTML -->
|
|
45
|
-
|
|
46
40
|
<script type="text/html" data-template-name="get_alerts">
|
|
47
41
|
<div class="form-row">
|
|
48
42
|
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
|
@@ -67,28 +61,12 @@
|
|
|
67
61
|
<input type="text" id="node-input-days" >
|
|
68
62
|
<input type="hidden" id="node-input-daysType">
|
|
69
63
|
</div>
|
|
70
|
-
|
|
71
|
-
|
|
72
64
|
</script>
|
|
73
65
|
|
|
74
66
|
<!-- Help Text -->
|
|
75
|
-
|
|
76
67
|
<script type="text/html" data-help-name="get_alerts">
|
|
77
|
-
|
|
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>
|
|
68
|
+
<p>Get alerts</p>
|
|
93
69
|
|
|
70
|
+
<h3>Details</h3>
|
|
71
|
+
Retrieve alerts for a specified account
|
|
94
72
|
</script>
|
package/src/nodes/get_alerts.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
var {createHash} = require('crypto');
|
|
2
1
|
const bent = require('bent');
|
|
3
|
-
var
|
|
4
|
-
mustache.escape = function(text) {return text;};
|
|
5
|
-
var {appendVerb, v_resolve, v_text_resolve, doLCC, doCreateCall, doCreateMessage} = require('./libs')
|
|
2
|
+
var {v_resolve} = require('./libs');
|
|
6
3
|
|
|
7
4
|
module.exports = function(RED) {
|
|
8
5
|
function get_alerts(config) {
|
|
@@ -12,10 +9,11 @@ module.exports = function(RED) {
|
|
|
12
9
|
const {accountSid, apiToken} = server.credentials;
|
|
13
10
|
node.on('input', async(msg, send, done) => {
|
|
14
11
|
const data = {
|
|
15
|
-
page: config.page,
|
|
16
|
-
count
|
|
17
|
-
days
|
|
12
|
+
page: v_resolve(config.page, config.pageType, this.context(), msg),
|
|
13
|
+
count: v_resolve(config.count, config.countType, this.context(), msg),
|
|
14
|
+
days: v_resolve(config.days, config.daysType, this.context(), msg),
|
|
18
15
|
}
|
|
16
|
+
Object.keys(data).forEach((k) => data[k] == null || data[k] == '' && delete data[k]);
|
|
19
17
|
const params = new URLSearchParams(data).toString()
|
|
20
18
|
const req = bent(`${server.url}/v1/Accounts/${accountSid}/Alerts?${params}`, 'GET', 'json', {
|
|
21
19
|
'Authorization': `Bearer ${apiToken}`
|
|
@@ -28,20 +26,20 @@ module.exports = function(RED) {
|
|
|
28
26
|
msg.page = res.page
|
|
29
27
|
} catch (err) {
|
|
30
28
|
if (err.statusCode) {
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
node.error(`GetAlerts failed with ${err.statusCode}`);
|
|
30
|
+
msg.statusCode = err.statusCode;
|
|
33
31
|
}
|
|
34
32
|
else {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
node.error(`Error getting alerts ${JSON.stringify(err)}`);
|
|
34
|
+
if (done) done(err);
|
|
35
|
+
else node.error(err, msg);
|
|
36
|
+
send(msg);
|
|
37
|
+
return;
|
|
40
38
|
}
|
|
41
39
|
}
|
|
42
40
|
send(msg);
|
|
43
41
|
if (done) done();
|
|
44
42
|
});
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
}
|
|
44
|
+
RED.nodes.registerType('get_alerts', get_alerts);
|
|
47
45
|
}
|
package/src/nodes/get_calls.html
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
<!-- Javascript -->
|
|
2
|
-
|
|
3
|
-
|
|
4
2
|
<script type="text/javascript">
|
|
5
|
-
|
|
3
|
+
RED.nodes.registerType('get_calls',{
|
|
6
4
|
category: 'jambonz',
|
|
7
5
|
color: '#aebfb9',
|
|
8
6
|
defaults: {
|
|
@@ -13,18 +11,11 @@
|
|
|
13
11
|
outputs:1,
|
|
14
12
|
icon: "font-awesome/fa-cubes",
|
|
15
13
|
paletteLabel: "Get - Calls",
|
|
16
|
-
label: function() { return this.name || 'Get Calls';}
|
|
17
|
-
oneditprepare: () => {
|
|
18
|
-
var node = this;
|
|
19
|
-
}
|
|
14
|
+
label: function() { return this.name || 'Get Calls';}
|
|
20
15
|
});
|
|
21
|
-
|
|
22
|
-
|
|
23
16
|
</script>
|
|
24
17
|
|
|
25
|
-
|
|
26
18
|
<!-- HTML -->
|
|
27
|
-
|
|
28
19
|
<script type="text/html" data-template-name="get_calls">
|
|
29
20
|
<div class="form-row">
|
|
30
21
|
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
|
@@ -37,23 +28,10 @@
|
|
|
37
28
|
</script>
|
|
38
29
|
|
|
39
30
|
<!-- Help Text -->
|
|
40
|
-
|
|
41
31
|
<script type="text/html" data-help-name="get_calls">
|
|
42
|
-
|
|
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>
|
|
32
|
+
<p>Get calls</p>
|
|
58
33
|
|
|
34
|
+
<h3>Details</h3>
|
|
35
|
+
Retrieve info for a group of calls under an account.
|
|
36
|
+
Call detail are only kept in the system for 10 minutes by default.
|
|
59
37
|
</script>
|
package/src/nodes/get_calls.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
|
|
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')
|
|
1
|
+
const bent = require("bent");
|
|
6
2
|
|
|
7
|
-
module.exports = function(RED) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
3
|
+
module.exports = function (RED) {
|
|
4
|
+
function get_calls(config) {
|
|
5
|
+
RED.nodes.createNode(this, config);
|
|
6
|
+
var node = this;
|
|
7
|
+
const server = RED.nodes.getNode(config.server);
|
|
8
|
+
const { accountSid, apiToken } = server.credentials;
|
|
9
|
+
node.on("input", async (msg, send, done) => {
|
|
10
|
+
const req = bent(
|
|
11
|
+
`${server.url}/v1/Accounts/${accountSid}/Calls`,
|
|
12
|
+
"GET",
|
|
13
|
+
"json",
|
|
14
|
+
{
|
|
15
|
+
Authorization: `Bearer ${apiToken}`,
|
|
16
|
+
}
|
|
17
|
+
);
|
|
18
|
+
try {
|
|
19
|
+
const res = await req();
|
|
20
|
+
msg.payload = res;
|
|
21
|
+
} catch (err) {
|
|
22
|
+
if (err.statusCode) {
|
|
23
|
+
node.error(`GetCalls failed with ${err.statusCode}`);
|
|
24
|
+
msg.statusCode = err.statusCode;
|
|
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
|
+
}
|
|
36
32
|
}
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
send(msg);
|
|
34
|
+
if (done) done();
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
RED.nodes.registerType("get_calls", get_calls);
|
|
38
|
+
};
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
<!-- Javascript -->
|
|
2
|
-
|
|
3
|
-
|
|
4
2
|
<script type="text/javascript">
|
|
5
|
-
|
|
3
|
+
RED.nodes.registerType('get_recent_calls',{
|
|
6
4
|
category: 'jambonz',
|
|
7
5
|
color: '#aebfb9',
|
|
8
6
|
defaults: {
|
|
9
7
|
name: {value: ''},
|
|
10
8
|
server: {value: '', required: true, type: 'jambonz_auth'},
|
|
9
|
+
direction: {value: ''},
|
|
10
|
+
directionType:{value: 'str'},
|
|
11
|
+
trunk: {value: ''},
|
|
12
|
+
trunkType:{value: 'str'},
|
|
11
13
|
page:{value: 1},
|
|
12
14
|
pageType:{value: 'num'},
|
|
13
15
|
count:{value: 25},
|
|
14
16
|
countType:{value: 'num'},
|
|
15
17
|
days:{value: 7},
|
|
16
|
-
|
|
18
|
+
daysType:{value: 'num'}
|
|
17
19
|
},
|
|
18
20
|
inputs:1,
|
|
19
21
|
outputs:1,
|
|
@@ -21,7 +23,6 @@
|
|
|
21
23
|
paletteLabel: "Get - Recent Calls",
|
|
22
24
|
label: function() { return this.name || 'Get Recent Calls';},
|
|
23
25
|
oneditprepare: () => {
|
|
24
|
-
var node = this;
|
|
25
26
|
$('#node-input-page').typedInput({
|
|
26
27
|
types: ['num', 'msg', 'flow', 'global', 'jsonata', 'env'],
|
|
27
28
|
typeField: $('#node-input-pageType')
|
|
@@ -34,15 +35,19 @@
|
|
|
34
35
|
types: ['num', 'msg', 'flow', 'global', 'jsonata', 'env'],
|
|
35
36
|
typeField: $('#node-input-daysType')
|
|
36
37
|
});
|
|
38
|
+
$('#node-input-direction').typedInput({
|
|
39
|
+
types: ['str', 'msg', 'flow', 'global'],
|
|
40
|
+
typeField: $('#node-input-directionType')
|
|
41
|
+
});
|
|
42
|
+
$('#node-input-trunk').typedInput({
|
|
43
|
+
types: ['str', 'msg', 'flow', 'global'],
|
|
44
|
+
typeField: $('#node-input-trunkType')
|
|
45
|
+
});
|
|
37
46
|
}
|
|
38
47
|
});
|
|
39
|
-
|
|
40
|
-
|
|
41
48
|
</script>
|
|
42
49
|
|
|
43
|
-
|
|
44
50
|
<!-- HTML -->
|
|
45
|
-
|
|
46
51
|
<script type="text/html" data-template-name="get_recent_calls">
|
|
47
52
|
<div class="form-row">
|
|
48
53
|
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
|
@@ -52,6 +57,16 @@
|
|
|
52
57
|
<label for="node-input-server">Server</label>
|
|
53
58
|
<input type="text" id="node-input-server">
|
|
54
59
|
</div>
|
|
60
|
+
<div class="form-row">
|
|
61
|
+
<label for="node-input-direction">Direction</label>
|
|
62
|
+
<input type="text" id="node-input-direction" placeholder="inbound">
|
|
63
|
+
<input type="hidden" id="node-input-directionType">
|
|
64
|
+
</div>
|
|
65
|
+
<div class="form-row">
|
|
66
|
+
<label for="node-input-trunk">Trunk</label>
|
|
67
|
+
<input type="text" id="node-input-trunk" placeholder="trunk name">
|
|
68
|
+
<input type="hidden" id="node-input-trunkType">
|
|
69
|
+
</div>
|
|
55
70
|
<div class="form-row">
|
|
56
71
|
<label for="node-input-page">Page</label>
|
|
57
72
|
<input type="text" id="node-input-page" >
|
|
@@ -67,29 +82,12 @@
|
|
|
67
82
|
<input type="text" id="node-input-days" >
|
|
68
83
|
<input type="hidden" id="node-input-daysType">
|
|
69
84
|
</div>
|
|
70
|
-
|
|
71
|
-
|
|
72
85
|
</script>
|
|
73
86
|
|
|
74
87
|
<!-- Help Text -->
|
|
75
|
-
|
|
76
88
|
<script type="text/html" data-help-name="get_recent_calls">
|
|
77
|
-
|
|
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>
|
|
89
|
+
<p>Get recent call records</p>
|
|
86
90
|
|
|
87
91
|
<h3>Details</h3>
|
|
88
92
|
Call detail records are only kept in the system for 30 days. As there could be a large number of CDRs, this node allows you to query pages of data at a time.
|
|
89
|
-
|
|
90
|
-
<ul>
|
|
91
|
-
<li><a href="https://api.jambonz.org/#4e82bdc2-327b-40a5-9b52-f86357647b45">Jambonz Get Recent Calls reference</a></li>
|
|
92
|
-
</ul>
|
|
93
|
-
</script>
|
|
94
|
-
|
|
95
93
|
</script>
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
var {createHash} = require('crypto');
|
|
2
1
|
const bent = require('bent');
|
|
3
|
-
var
|
|
4
|
-
mustache.escape = function(text) {return text;};
|
|
5
|
-
var {appendVerb, v_resolve, v_text_resolve, doLCC, doCreateCall, doCreateMessage} = require('./libs')
|
|
2
|
+
var {v_resolve} = require('./libs');
|
|
6
3
|
|
|
7
4
|
module.exports = function(RED) {
|
|
8
5
|
function get_recent_calls(config) {
|
|
@@ -12,36 +9,39 @@ module.exports = function(RED) {
|
|
|
12
9
|
const {accountSid, apiToken} = server.credentials;
|
|
13
10
|
node.on('input', async(msg, send, done) => {
|
|
14
11
|
const data = {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
direction: v_resolve(config.direction, config.directionType, this.context(), msg),
|
|
13
|
+
trunk: v_resolve(config.trunk, config.trunkType, this.context(), msg),
|
|
14
|
+
page: v_resolve(config.page, config.pageType, this.context(), msg),
|
|
15
|
+
count: v_resolve(config.count, config.countType, this.context(), msg),
|
|
16
|
+
days: v_resolve(config.days, config.daysType, this.context(), msg),
|
|
18
17
|
}
|
|
19
|
-
|
|
18
|
+
Object.keys(data).forEach((k) => data[k] == null || data[k] == '' && delete data[k]);
|
|
19
|
+
const params = new URLSearchParams(data).toString();
|
|
20
20
|
const req = bent(`${server.url}/v1/Accounts/${accountSid}/RecentCalls?${params}`, 'GET', 'json', {
|
|
21
21
|
'Authorization': `Bearer ${apiToken}`
|
|
22
22
|
});
|
|
23
23
|
try {
|
|
24
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
|
|
25
|
+
msg.payload = res.data;
|
|
26
|
+
msg.total = res.total;
|
|
27
|
+
msg.page_size = res.page_size;
|
|
28
|
+
msg.page = res.page;
|
|
29
29
|
} catch (err) {
|
|
30
30
|
if (err.statusCode) {
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
node.error(`GetRecentCalls failed with ${err.statusCode}`);
|
|
32
|
+
msg.statusCode = err.statusCode;
|
|
33
33
|
}
|
|
34
34
|
else {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
node.error(`Error getting recent calls ${JSON.stringify(err)}`);
|
|
36
|
+
if (done) done(err);
|
|
37
|
+
else node.error(err, msg);
|
|
38
|
+
send(msg);
|
|
39
|
+
return;
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
send(msg);
|
|
43
43
|
if (done) done();
|
|
44
44
|
});
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
}
|
|
46
|
+
RED.nodes.registerType('get_recent_calls', get_recent_calls);
|
|
47
47
|
}
|
package/src/nodes/hangup.html
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
<!-- Javascript -->
|
|
2
|
-
|
|
3
|
-
|
|
4
2
|
<script type="text/javascript">
|
|
5
|
-
|
|
6
|
-
RED.nodes.registerType('hangup',{
|
|
3
|
+
RED.nodes.registerType('hangup',{
|
|
7
4
|
category: 'jambonz',
|
|
8
5
|
color: '#bbabaa',
|
|
9
6
|
defaults: {
|
|
@@ -14,18 +11,15 @@ RED.nodes.registerType('hangup',{
|
|
|
14
11
|
icon: "font-awesome/fa-cubes",
|
|
15
12
|
label: function() { return this.name || 'hangup';},
|
|
16
13
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
14
|
</script>
|
|
20
15
|
|
|
21
|
-
|
|
22
16
|
<!-- HTML -->
|
|
23
17
|
<script type="text/html" data-template-name="hangup">
|
|
24
18
|
<div class="form-row">
|
|
25
19
|
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
|
26
20
|
<input type="text" id="node-input-name" placeholder="Name">
|
|
27
21
|
</div>
|
|
28
|
-
|
|
22
|
+
</script>
|
|
29
23
|
|
|
30
24
|
<!-- Help Text -->
|
|
31
25
|
<script type="text/html" data-help-name="hangup">
|
|
@@ -33,14 +27,14 @@ RED.nodes.registerType('hangup',{
|
|
|
33
27
|
|
|
34
28
|
<h3>Outputs</h3>
|
|
35
29
|
<dl class="message-properties">
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
<dt>jambonz<span class="property-type">object</span></dt>
|
|
31
|
+
<dd> <code>msg.jambonz</code> will contain any previous actions provided to the input with the new <code>hangup</code> action appended </dd>
|
|
38
32
|
</dl>
|
|
39
33
|
|
|
40
34
|
<h3>Details</h3>
|
|
41
35
|
The hangup verb hangs up the current call.
|
|
42
36
|
<h3>References</h3>
|
|
43
37
|
<ul>
|
|
44
|
-
<li><a href="https://
|
|
38
|
+
<li><a href="https://www.jambonz.org/docs/webhooks/hangup/">Jambonz hangup reference</a></li>
|
|
45
39
|
</ul>
|
|
46
40
|
</script>
|