Quick And Dirty - Send TTS Notifications *TO* Amazon Alexa Units

requires_server
project_alerts

(Boris Tsipenyuk) #1

Hello, I wanted to share a quick and dirty setup to send TTS notifications to my alexa units (and other functions) , I am obviously glossing over the technical aspects but hopefully this is helpful, as most information online refeered to older workarounds that no longer function - this is something that I have long wanted to do and finally decided to focus on this as for some reason - the DLNA TTS media render smart app / device handler completly stopped working for me (and others)

now my gut would tell me that the cookie used in this workaround would eventually expire and this would stop working, so far it’s been humming along fine for two weeks

Requirements: web server that your ST hub can access (I have a linux server on my LAN) - no reason it can’t be done with an amazon lambda function but I didn’t get around to that.

Virtual HTTP Button Device Handler: [Released] Virtual HTTP Switch/Button Creator

Software to capture HTTPS sessions I am big fan of charles proxy: https://www.charlesproxy.com

login to https://alexa.amazon.com - you will find an interface comperable to what’s in the alexa app, create a reminder on one of your alexa devices. in charles, this will show up under https://alexa.amazon.com/api/notifications/createreminder
there is an option to convert to a CURL request:

the request will look something like this:

curl -H ‘Host: alexa.amazon.com’ -H ‘Accept: application/json, text/javascript, /; q=0.01’ -H ‘X-Requested-With: XMLHttpRequest’ -H ‘Accept-Language: en-us’ -H ‘Content-Type: application/json’ -H ‘Origin: https://alexa.amazon.com’ -H ‘User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.1.1 Safari/605.1.15’ -H ‘Referer: https://alexa.amazon.com/spa/index.html’ -H ‘DNT: 1’ -H 'Cookie: SUPER LONG COOKIE ‘Pragma: no-cache’ -H ‘Cache-Control: no-cache’ --data-binary ‘{“type”:“Reminder”,“status”:“ON”,“alarmTime”:1531697940000,“originalTime”:“19:39:00.000”,“originalDate”:“2018-07-15”,“timeZoneId”:null,“reminderIndex”:null,“sound”:null,“deviceSerialNumber”:“XXXXXXX”,“deviceType”:“XXXXXXXXX”,“recurringPattern”:null,“reminderLabel”:“test”,“isSaveInFlight”:true,“id”:“createReminder”,“isRecurring”:false,“createdDate”:1531604386442}’ -X PUT --compressed ‘https://alexa.amazon.com/api/notifications/createReminder

I have created two scripts:

Here is the one you point to with the http button via get, which I use for motion notification via SMH - for this to work I find that the reminder has to be at least a few seconds in the future for the API to accept.

#!/bin/bash
echo “Content-Type: text/html; charset=UTF-8”
echo ‘’
echo ‘’
echo ‘’
now=$(date -d ‘+5 seconds’ +%H:%M:%S).000
nowday=$(date +%F)
/usr/lib/cgi-bin/set-alexa-reminder.sh “$now” “$nowday” “MotionHasBeenDetected”

here is set-alexa-reminder.sh - you will want to replace reminderlabel, originaltime and originaldate as below

curl -H ‘Host: alexa.amazon.com’ -H ‘Accept: application/json, text/javascript, /; q=0.01’ -H ‘X-Requested-With: XMLHttpRequest’ -H ‘Accept-Language: en-us’ -H ‘Content-Type: application/json’ -H ‘Origin: https://alexa.amazon.com’ -H ‘User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.1.1 Safari/605.1.15’ -H ‘Referer: https://alexa.amazon.com/spa/index.html’ -H ‘DNT: 1’ -H ‘Cookie: SUPER LONG COOKIE’ -H ‘csrf: -XXXXXX’ -H ‘Pragma: no-cache’ -H ‘Cache-Control: no-cache’ --data-binary ‘{“type”:“Reminder”,“status”:“ON”,“alarmTime”:1531069800000,“originalTime”:"’$1’",“originalDate”:"’$2’",“timeZoneId”:null,“reminderIndex”:null,“sound”:null,“deviceSerialNumber”:“XXXXXX”,“deviceType”:“XXXXXXX”,“recurringPattern”:null,“reminderLabel”:"’$3’",“isSaveInFlight”:true,“id”:“createReminder”,“isRecurring”:false,“createdDate”:1530983424221}’ -X PUT --compressed ‘https://alexa.amazon.com/api/notifications/createReminder


(Ron Talley) #2

I like the Title as it says, “Quick and Dirty”!


(Boris Tsipenyuk) #4

Two quick addendum - this seems to work fine via aws lambda if you are so inclined and I should mention something that may not be obvious but the “reverse” of setting up an echo “routine” to trigger the http Button via smart home works fine as well. For example I have an 8 minute timer for coffee so one can do “alexa coffee” to remind you in 8 minutes