-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcommunication.js
29 lines (27 loc) · 1.51 KB
/
communication.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
var accountSid = ''; // Fill this in when account is made.
var authToken = "{{ auth_token }}"; // Not sure what this is, do something here.
var client = require('twilio')(accountSid, authToken);
var app = require('express'); // Move this if necessary.
app.POST('/receive',function() {});
client.messages(message.sid).get(function(err, message) {
var number_regex = /\d{1,50}/g; // Change the number depending on the math constraints.
var numbers = message.body.match(number_regex); // match should return an array with the matches in them, if any.
if (numbers.length < 2) {
client.messages.create({
body: "You did not send enough numbers. Please try again.",
to: message.from, // Not sure if this is correct, and the documentation doesn't seem to help.
from: "" // Put number here.
}, function(err, message) {
process.stdout.write(message.sid); } // Change this if needed; it was in the Twilio documentation.
} else if (numbers.length > 2) {
client.messages.create({
/* Right now, I'm assuming that we only want two numbers.
Alternatively, we could just take the first two that they send in.
If we want to do that, just change it. */
body: "You sent too many numbers. Please try again.",
to: message.from, // Again, unsure if this is correct.
from: "" // Put number here.
}, function(err, message) {
process.stdout.write(message.sid); }
} else {} // Do something here.
});