configured twilio voice, fixed bug with added slash on numbers
This commit is contained in:
4
app/public/sayings/alarm.twiml.xml
Normal file
4
app/public/sayings/alarm.twiml.xml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Response>
|
||||||
|
<Say voice="woman" language="english">Zoblak Farm ALARM! ALARM! ALARM!</Say>
|
||||||
|
</Response>
|
||||||
@@ -254,7 +254,9 @@ function soundTheAlarm(controller_id, tooCold, tooHot, boxSilent, phoneSilent) {
|
|||||||
var smsSent = !!state.state.alarmSmsSent;
|
var smsSent = !!state.state.alarmSmsSent;
|
||||||
var needsToSendSms = !smsSent // && phoneSilent;
|
var needsToSendSms = !smsSent // && phoneSilent;
|
||||||
|
|
||||||
var sendSmsPart = needsToSendSms ? { 'state.alarmSmsSent': true } : {};
|
var sendSmsPart = needsToSendSms ? {
|
||||||
|
'state.alarmSmsSent': true
|
||||||
|
} : {};
|
||||||
|
|
||||||
ControllerState.update(state._id, {
|
ControllerState.update(state._id, {
|
||||||
'$set': Object.assign({
|
'$set': Object.assign({
|
||||||
@@ -265,7 +267,8 @@ function soundTheAlarm(controller_id, tooCold, tooHot, boxSilent, phoneSilent) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (needsToSendSms) {
|
if (needsToSendSms) {
|
||||||
sendAlarmingSms(controller_id,reason, state.config.smsNumbers)
|
sendAlarmingSms(controller_id, reason, state.config.smsNumbers);
|
||||||
|
callTheUser(controller_id, reason, state.config.smsNumbers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,7 +278,7 @@ function sendAlarmingSms(controller_id,reason, numbers) {
|
|||||||
twilio = Twilio('AC10d7ed0bf54c1be4b1cd7133130e63f4', 'e133d3f02a69b79e93ad9ca1d73517d1');
|
twilio = Twilio('AC10d7ed0bf54c1be4b1cd7133130e63f4', 'e133d3f02a69b79e93ad9ca1d73517d1');
|
||||||
twilio.sendSms({
|
twilio.sendSms({
|
||||||
to: number, // Any number Twilio can deliver to
|
to: number, // Any number Twilio can deliver to
|
||||||
from: '+447481345235', // A number you bought from Twilio and can use for outbound communication
|
from: '+19282124174', // A number you bought from Twilio and can use for outbound communication
|
||||||
body: 'Zoblak alarm! Pokrenite aplikaciju! HITNO! http://agrar.zoblak.com/alarm?controller_id=' + controller_id // body of the SMS message
|
body: 'Zoblak alarm! Pokrenite aplikaciju! HITNO! http://agrar.zoblak.com/alarm?controller_id=' + controller_id // body of the SMS message
|
||||||
}, function(err, responseData) { //this function is executed when a response is received from Twilio
|
}, function(err, responseData) { //this function is executed when a response is received from Twilio
|
||||||
if (!err) { // "err" is an error received during the request, if any
|
if (!err) { // "err" is an error received during the request, if any
|
||||||
@@ -289,6 +292,21 @@ function sendAlarmingSms(controller_id,reason, numbers) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function callTheUser(controller_id, reason, numbers) {
|
||||||
|
for (var i in numbers) {
|
||||||
|
var number = numbers[i];
|
||||||
|
twilio = Twilio('AC10d7ed0bf54c1be4b1cd7133130e63f4', 'e133d3f02a69b79e93ad9ca1d73517d1');
|
||||||
|
twilio.makeCall({
|
||||||
|
to: number, // Any number Twilio can call
|
||||||
|
from: '+441143031932', // A number you bought from Twilio and can use for outbound communication
|
||||||
|
url: 'https://handler.twilio.com/twiml/EH9491c24474db07ec52b598baa5724f1e' // A URL that produces an XML document (TwiML) which contains instructions for the call
|
||||||
|
}, function(err, responseData) {
|
||||||
|
//executed when the call has been initiated.
|
||||||
|
console.log(err); // outputs "+14506667788"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function stopTheAlarm(controller_id, everythingIsBackToNormal = false) {
|
function stopTheAlarm(controller_id, everythingIsBackToNormal = false) {
|
||||||
// time of alarm stopped is reset so that scheduled job can raise the alarm
|
// time of alarm stopped is reset so that scheduled job can raise the alarm
|
||||||
// again
|
// again
|
||||||
|
|||||||
Reference in New Issue
Block a user