-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcrushping.js
More file actions
19 lines (18 loc) · 853 Bytes
/
Copy pathcrushping.js
File metadata and controls
19 lines (18 loc) · 853 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// This was originally sourced from Alex Swan's lovenotes project at https://particle.hackster.io/boldbigflank/love-notes-37be49
const request = require('request')
exports.handler = function(context, event, callback) {
// Send the message to the Particle Electron's 'message' function
request
.post('https://api.particle.io/v1/devices/' + context.PARTICLE_DEVICE_ID + '/message')
.form({
access_token: context.PARTICLE_ACCESS_TOKEN,
args: event.Body
})
.on('response', function(response) {
// Tell the sender if it worked
let responseText = response.statusCode == 200 ? "Success!" : "Failure!"
let twiml = new Twilio.twiml.MessagingResponse();
twiml.message(responseText);
callback(null, twiml);
})
};