jratliff681 / EchoTasker

Amazon Echo skill that sends an AutoRemote message to tasker with your speech. You can also use it to send SMS messages from the Echo with Tasker.
21 stars 4 forks source link

Join compatibility #1

Closed SCrid2000 closed 8 years ago

SCrid2000 commented 8 years ago

Will this work with Join? I tried using the Join api rather than the autoremote one, but the echo speaks an error message after asking me to speak my message or say text and the contact name/message:

"There was a problem with the requested skills response"

The app gives the error message "The target Lambda application returned a failure response." Lambda gives the following error in the logs:

 `    "errorMessage": "Protocol \"https:\" not supported. Expected \"http:\".",
     "errorType": "Error",
     "stackTrace": [
         "new ClientRequest (_http_client.js:52:11)",
         "Object.exports.request (http.js:31:10)",
         "httpreq (/var/task/index.js:47:25)",
         "EchoTasker.intentHandlers.TaskerIntent (/var/task/index.js:29:9)",
         "AlexaSkill.eventHandlers.onIntent (/var/task/AlexaSkill.js:65:27)",
         "AlexaSkill.requestHandlers.IntentRequest (/var/task/AlexaSkill.js:28:37)",
         "AlexaSkill.execute (/var/task/AlexaSkill.js:105:24)",
         "exports.handler (/var/task/index.js:85:16)"
     ]
 }`

So maybe the problem is the join requires https and autoremote uses http?

The join api I replaced the autoremote one with is https://joinjoaomgcd.appspot.com/_ah/api/messaging/v1/sendPush?deviceId=' + options.ARkey + '&text=echo=:=' + intent.slots.Message.value

jratliff681 commented 8 years ago

Yeah it will work with a different api. I'm not familiar with join but I see what happened. You have to specify to use http or https. I had it setup for http so it had an error trying to call that https address with the http protocol.

When I made this I didn't understand what this second line of code was doing: function httpreq(options, responseCallback) { var transport = options.useHttps ? https : http; var req = transport.request(options, function(httpResponse) {

So I changed it to http : http instead. In the options.js file there is a variable called useHttps that you can set to true or false. That line above says if true use the first one (https) and if false use the second one (http).

So there are many different ways to do it but just change that back to https : http down around the bottom of the index.js file and zip the 3 files back together and reupload to aws. Unless you changed it the options.js file already had useHttps = true so it will work once you change that. That assumes you aren't mixing any other urls that use http.

You can also just use this one line in your intent block of code to call a url: http.get('url_here'); or https.get('url_here');

The benefit of the function used in the skill is that it will send back an error response if it was unable to call the address. But I wasn't even taking advantage of that when I made this skill because I didn't understand that at the time.

Let me know if that didn't make sense or you need more help.

SCrid2000 commented 8 years ago

Thanks, that did it. Don't know why I didn't catch that. Had to change it to

var transport = options.useHttps ? http : https;

so https was second, not first.

Thanks!