This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
misty.Debug("Starting my skill"); | |
_yesnoURL = "https://yesno.wtf/api" | |
// Parse the response data to get the current condition in _params.city | |
// and print this in a string to the dev console in the Skill Runner | |
// web page. | |
function _SendExternalRequest(data) { | |
_data = JSON.parse(data.Result.ResponseObject.Data) | |
_answer = _data.answer.toLowerCase(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ----------------------- Finger Print Sensor ----------------- | |
// Updates the fingerPrintActivated key to set the state of the skill | |
// so that Misty is ready to receive data from the fingerprint scanner | |
_enableFingerPrint() | |
function _enableFingerPrint() { | |
misty.Set("fingerPrintActivated", false, false); | |
} | |
// Starts Misty listening for data from UART serial. Data that comes in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sendPicture() { | |
misty.Debug("Sending Image to User"); | |
// Sets up thee JSON body for the Twilio SMS API. | |
// Includes the phone number of the recipient and | |
// the URL for their photograph on Imgur | |
var jsonBody = { | |
'Body': '[••] Greetings from Misty!', | |
'From': '<number-to-send-from>', | |
'To': misty.Get("contact"), | |
'MediaUrl': misty.Get("imageLink") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function uploadImage(imageData) { | |
// Sets up the JSON body for uploading the picture | |
var jsonBody = { | |
'image': imageData, | |
'type' : 'base64', | |
'album': '<album-name> | |
}; | |
// Uploads the picture to a private album; then, passes Imgur | |
// response data into the _imageUploadResponse() callback | |
misty.SendExternalRequest("POST", "https://api.imgur.com/3/image", "Bearer", "<bearer-token>", JSON.stringify(jsonBody), false, false, "", "application/json", "_imageUploadResponse"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function _TakePicture(data) { | |
var base64String = data.Result.Base64; | |
uploadImage(base64String); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (data != [] && data.type == 'photo') | |
{ | |
// Saves the user's contact info | |
misty.Set("contact", (data.phNumber).toString(), false); | |
// Changes display image, sets head position, and plays | |
// sounds to show she's taking a picture | |
misty.DisplayImage("DefaultEyes_SystemCamera.jpg"); | |
misty.Pause(100); | |
misty.PlayAudio("DefaultSounds_Awe3.wav", 100); | |
misty.Set("pictureMode", true, false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Calls the keepActive() function every 15 seconds | |
misty.RegisterTimerEvent("keepActive", 15000, true); | |
// Sends a publish request to work around timeouts | |
function _keepActive() { | |
misty.SendExternalRequest("POST", "https://ps.pndsn.com/publish/<publish-key>/<subscribe-key/0/<channel-name>/myCallback", null, null, "{}", false, false, "", "application/json"); | |
} | |
// Gets the message Twilio sends to PubNub and passes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
'phNumber': contact, | |
'type': 'photo' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://ps.pndsn.com/publish/<publish-key>/<subscribe-key>/0/<channel-name>/0?store=0&uuid=<client-name> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.handler = function(context, event, callback) { | |
// Saves phone number to contact variable | |
var contact = event.UserIdentifier || "19294421336"; | |
// Sends SMS to user | |
const replySms = {"actions": [{"say": "[••] Time to Pose"}]}; | |
const replyErrorSms = {"actions": [{"say": "[••] Oops an error occured, Could you please try again.."}]}; | |
const axios = require('axios') | |
// The PubNub URL includes publish/subscribe keys, a |
NewerOlder