diff --git a/src/apps/callflows/i18n/en-US.json b/src/apps/callflows/i18n/en-US.json index 29edeb1..9ee7419 100644 --- a/src/apps/callflows/i18n/en-US.json +++ b/src/apps/callflows/i18n/en-US.json @@ -1138,6 +1138,7 @@ "advanced_cat": "Advanced", "call_recording_cat": "Call Recording", "caller_id_cat": "Caller-ID", + "integrations_cat": "Integrations", "delete_callflow": "Delete callflow", "save_changes": "Save changes", "invalid_number": "Invalid number!", @@ -1292,7 +1293,13 @@ "check_cid_match": "Match", "check_cid_nomatch": "No match", "check_cid_matchnomatch": "Match or no match?", - "regex": "Regex" + "regex": "Regex", + "webhook": "Send webhook", + "webhook_tip": "Send a webhook to an external webservice when this callflow node is hit", + "webhook_title": "Send a HTTP webhook", + "webhook_uri": "URI", + "webhook_method": "HTTP method", + "webhook_retry": "# retries" }, "__comment": "UI-1260: created common control for carrier selection", "__version": "v3.20_s2", diff --git a/src/apps/callflows/submodules/misc/misc.js b/src/apps/callflows/submodules/misc/misc.js index 3d0fb6c..bc0b022 100644 --- a/src/apps/callflows/submodules/misc/misc.js +++ b/src/apps/callflows/submodules/misc/misc.js @@ -397,7 +397,7 @@ define(function(require){ }, 'check_cid[]': { name: self.i18n.active().oldCallflows.check_cid, - icon: 'lightbulb-o', + icon: 'list-ol', category: self.i18n.active().oldCallflows.caller_id_cat, module: 'check_cid', tip: self.i18n.active().oldCallflows.check_cid_tip, @@ -477,6 +477,53 @@ define(function(require){ } + }, + 'webhook[]': { + name: self.i18n.active().oldCallflows.webhook, + icon: 'upload', + category: self.i18n.active().oldCallflows.integrations_cat, + module: 'webhook', + tip: self.i18n.active().oldCallflows.webhook_tip, + data: { + }, + rules: [ + { + type: 'quantity', + maxSize: '1' + } + ], + isUsable: 'true', + weight: 40, + caption: function(node, caption_map) { + return node.getMetadata('webhook') || ''; + }, + edit: function(node, callback) { + var popup_html = $(monster.template(self, 'webhook-callflowEdit', { + data_webhook: { + 'http_verb': node.getMetadata('http_verb') || 'get', + 'retries': node.getMetadata('retries') || '3', + 'uri': node.getMetadata('uri') || '' + } + })), + popup; + $('#add', popup_html).click(function() { + node.setMetadata('http_verb', $('#http_verb option:selected', popup_html).val()); + node.setMetadata('retries', $('#retries_input', popup_html).val()); + node.setMetadata('uri', $('#uri_input', popup_html).val()); + + popup.dialog('close'); + }); + + popup = monster.ui.dialog(popup_html, { + title: self.i18n.active().oldCallflows.webhook_title, + beforeClose: function() { + if(typeof callback == 'function') { + callback(); + } + } + }); + } + }, 'manual_presence[]': { name: self.i18n.active().oldCallflows.manual_presence, diff --git a/src/apps/callflows/views/webhook-callflowEdit.html b/src/apps/callflows/views/webhook-callflowEdit.html new file mode 100644 index 0000000..cfec44a --- /dev/null +++ b/src/apps/callflows/views/webhook-callflowEdit.html @@ -0,0 +1,28 @@ +