mirror of
https://github.com/node-red/node-red-nodes.git
synced 2025-03-01 10:37:43 +00:00
Attempt to clarify Info text for new Twilio features.
This commit is contained in:
parent
49e9edaf39
commit
139dcd67bc
@ -36,10 +36,10 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-number">
|
<label for="node-input-number">
|
||||||
<i class="fa fa-envelope-o" id="node-input-number-icon-sms"></i>
|
<i class="fa fa-envelope-o" id="node-input-number-icon-sms"></i>
|
||||||
<i class="fa fa-phone hidden" id="node-input-number-icon-call"></i>
|
<i class="fa fa-phone hidden" id="node-input-number-icon-call"></i>
|
||||||
To</label>
|
To</label>
|
||||||
<input type="text" id="node-input-number" placeholder="01234 5678901">
|
<input type="text" id="node-input-number" placeholder="01234 5678901">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row hidden" id="node-input-twiliourl-row">
|
<div class="form-row hidden" id="node-input-twiliourl-row">
|
||||||
@ -54,8 +54,11 @@
|
|||||||
|
|
||||||
<script type="text/x-red" data-help-name="twilio out">
|
<script type="text/x-red" data-help-name="twilio out">
|
||||||
<p>Sends an SMS message or makes a call using the Twilio service.</p>
|
<p>Sends an SMS message or makes a call using the Twilio service.</p>
|
||||||
<p><code>msg.payload</code> is used as either the body of the SMS message or the URL of the TWiML to create the call. The node can be configured with the number
|
<p><code>msg.payload</code> can either contain the text of the SMS message,
|
||||||
to send the message to. Alternatively, if the number is left blank, it can be set using <code>msg.topic</code>. If the node is configured to make a call then the URL can be entered into the node or if left blank then the <code>msg.payload</code> is used.</p>
|
<i>or</i> the URL of the <a href="https://www.twilio.com/docs/api/twiml" target = "_new">TWiML</a> used to create the call.
|
||||||
|
The node can be configured with the number to send the message to.
|
||||||
|
Alternatively, if the number is left blank, it can be set using <code>msg.topic</code>.
|
||||||
|
If the node is configured to make a call then the TWiML URL must be publically accessible.
|
||||||
<p>You must have an account with Twilio to use this node. You can register for one <a href="https://www.twilio.com/">here</a>.</p>
|
<p>You must have an account with Twilio to use this node. You can register for one <a href="https://www.twilio.com/">here</a>.</p>
|
||||||
<p>You can either set your account details within the node, or provide it globally using either the settings file or a file
|
<p>You can either set your account details within the node, or provide it globally using either the settings file or a file
|
||||||
called 'twiliokey.js' located in the directory above node-red.</p>
|
called 'twiliokey.js' located in the directory above node-red.</p>
|
||||||
@ -85,16 +88,12 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
var hasGlobal = false;
|
var hasGlobal = false;
|
||||||
$.getJSON('twilio-api/global',function(data) {
|
$.getJSON('twilio-api/global',function(data) {
|
||||||
hasGlobal = data.hasToken;
|
hasGlobal = data.hasToken;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
RED.nodes.registerType('twilio-api',{
|
RED.nodes.registerType('twilio-api',{
|
||||||
category: 'config',
|
category: 'config',
|
||||||
defaults: {
|
defaults: {
|
||||||
@ -144,8 +143,8 @@
|
|||||||
twilio:{type:"twilio-api",validate:function(v) {
|
twilio:{type:"twilio-api",validate:function(v) {
|
||||||
return hasGlobal || (v && v!="_ADD_");
|
return hasGlobal || (v && v!="_ADD_");
|
||||||
}},
|
}},
|
||||||
twilioType: {value:"sms"},
|
twilioType: {value:"sms"},
|
||||||
url: {value:""},
|
url: {value:""},
|
||||||
number: {value:""},
|
number: {value:""},
|
||||||
name: {value:""}
|
name: {value:""}
|
||||||
},
|
},
|
||||||
@ -193,18 +192,17 @@
|
|||||||
var twilioType = $("#node-input-twilioType option:selected").val();
|
var twilioType = $("#node-input-twilioType option:selected").val();
|
||||||
if (twilioType == "call") {
|
if (twilioType == "call") {
|
||||||
$("#node-input-twiliourl-row").show();
|
$("#node-input-twiliourl-row").show();
|
||||||
$("#node-input-number-icon-call").show();
|
$("#node-input-number-icon-call").show();
|
||||||
$("#node-input-number-icon-sms").hide();
|
$("#node-input-number-icon-sms").hide();
|
||||||
} else {
|
} else {
|
||||||
$("#node-input-twiliourl-row").hide();
|
$("#node-input-twiliourl-row").hide();
|
||||||
$("#node-input-number-icon-call").hide();
|
$("#node-input-number-icon-call").hide();
|
||||||
$("#node-input-number-icon-sms").show();
|
$("#node-input-number-icon-sms").show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$("#node-input-twilioType").val(this.twilioType);
|
$("#node-input-twilioType").val(this.twilioType);
|
||||||
$("#node-input-twilioType").change();
|
$("#node-input-twilioType").change();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -92,8 +92,8 @@ module.exports = function(RED) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.twilioType = n.twilioType;
|
this.twilioType = n.twilioType;
|
||||||
this.url = n.url;
|
this.url = n.url;
|
||||||
var node = this;
|
var node = this;
|
||||||
this.on("input",function(msg) {
|
this.on("input",function(msg) {
|
||||||
if (typeof(msg.payload) == 'object') {
|
if (typeof(msg.payload) == 'object') {
|
||||||
@ -102,24 +102,24 @@ module.exports = function(RED) {
|
|||||||
try {
|
try {
|
||||||
// decide if we are to Send SMS
|
// decide if we are to Send SMS
|
||||||
var tonum = node.number || msg.topic;
|
var tonum = node.number || msg.topic;
|
||||||
if( this.twilioType == "call" ) {
|
if( this.twilioType == "call" ) {
|
||||||
// Make a call
|
// Make a call
|
||||||
var twimlurl = node.url || msg.payload;
|
var twimlurl = node.url || msg.payload;
|
||||||
node.twilioClient.makeCall( {to: tonum, from: node.fromNumber, url: twimlurl}, function(err, response) {
|
node.twilioClient.makeCall( {to: tonum, from: node.fromNumber, url: twimlurl}, function(err, response) {
|
||||||
if (err) {
|
if (err) {
|
||||||
node.error(err);
|
node.error(err.message);
|
||||||
}
|
}
|
||||||
//console.log(response);
|
//console.log(response);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// Send SMS
|
// Send SMS
|
||||||
node.twilioClient.sendMessage( {to: tonum, from: node.fromNumber, body: msg.payload}, function(err, response) {
|
node.twilioClient.sendMessage( {to: tonum, from: node.fromNumber, body: msg.payload}, function(err, response) {
|
||||||
if (err) {
|
if (err) {
|
||||||
node.error(err);
|
node.error(err.message);
|
||||||
}
|
}
|
||||||
//console.log(response);
|
//console.log(response);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
node.error(err);
|
node.error(err);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user