Code

file_5911.txtJavaScript
    var client = require('twilio')('{{ sid token }}', '{{ auth token }}');

var pinoccio = require('pinoccio');

var api = pinoccio("{{ pinoccio api token }}");

var s = api.sync();

s.on('data', function(data) {
    data = data.data;
    if (data.type === 'digital' && data.troop === '1' && data.scout === '1') {
        if (data.value.state[0] == 0) {
            console.log("Someone rang the doorbell");
            command = "led.green delay(5000) led.off";
            // initialize the command that we will set below.
            client.sendMessage({

                to: '+{{ your phone number }}', 
                // Any number Twilio can deliver to
                from: '+{{ twilio phone number }}', 
                // A number you bought from Twilio and can use f
                // or outbound communication
                body: '\nword to your mother.\nsomeone rang the doorbell.'
                // body of the SMS message
            }, 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
                  // "responseData" is a JavaScript object containing 
                  // data received from Twilio.
                  // A sample response from sending an SMS message is 
                  // here (click "JSON" to see how the data appears in
                  // JavaScript):
              // http://www.twilio.com/docs/api/rest/sending-sms#example-1
                    console.log(responseData.from); 
                    // outputs your twilio number
                    console.log(responseData.body);
                    // outputs the body of the text from above
                }
            });
            api.rest({
                url: "/v1/1/1/command",
                data: {
                    command: command
                }
            }, function(err, data) {});
        }
    }
});

Credits

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

Occupied
  • 6,532
  • 55

Full instructions

A toilet queueing app for serious poopers. Uses resin.io, firebase and twilio to notify people when the toilet is open - runs on the RPI.

Spark Core and Twilio
  • 3,497
  • 21

Full instructions

Calling a Twilio number to control Spark Core

DHT22 Sensor and Pinoccio
  • 1,615
  • 5

Full instructions

Using DHT22 Temperature and Humidity sensor with Pinoccio

Mesh Your Brain
  • 3,469
  • 22

Full instructions

Build your own Internet of Brains with this wireless EEG hack!

Human Presence Detection & Visualization
  • 1,064
  • 9

Full instructions

Team Cogitate's social radar displays people nearby as a set of glowing orbs

A Sleep Tracker for Your Dog Using Tessel and Twilio
  • 2,192
  • 5

Full instructions

A Sleep Tracker for Your Dog Using Tessel and Twilio

ProjectsCommunitiesTopicsContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login