Obtaining last Alexa device called using

The On Device Activity node sadly, like others, is not working (at least not reliably) for me, so I've been trying to find a way to use the Alexa Palette (using node-red-contrib-alexa-remote2-applestrudel tho not sure it matters) to give me the last called Alexa device

I’ve found the "Alexa Other Node" set to Get Activities, when called will output an array which includes somewhere (seemingly random) within it the last command, but I see no clear way to obtain what is the last successful command

It seems to log all devices that may hear that command - I have no idea how to fish through that in order to know which device was the last one that actually was spoken to

Can anyone help me identify the way to find out what the device that was spoken to is?

[to give context on what I'm trying to do, I previously used another method and had a routine on Alexa called “Boost the Heating” - when it was called, it toggles a boolean, which triggers a call of “last alexa device” then boosts the relevant TRV depending on the room - maybe there is a better / different way to do this with the Node Red variant]

1 Like

Can you not search the array of responses for activity and output the object that contain description.summary that matches Boost the Heating, then that object will contain name property that contains the device name.

1 Like

I probably can, but do I know how... nope lol
Any direction would be appreciated! I know how to pull a specific value that I know where it's going to be, but not find something that could be in any place in an array

JSONata in a change node

$$.payload[$.description.summary = "Boost the Heating"]

or

$$.payload[$contains($.description.summary, "Boost the Heating")]

An example flow

[{"id":"0a18b02cc63066cf","type":"inject","z":"d1395164b4eec73e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"description\":{\"summary\":\"this is a test\"}}]","payloadType":"json","x":430,"y":7660,"wires":[["2527468f539263ad"]]},{"id":"2527468f539263ad","type":"change","z":"d1395164b4eec73e","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$$.payload[$contains($.description.summary, \"is a test\")]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":600,"y":7680,"wires":[["d6e46592f6e03c6e"]]},{"id":"d6e46592f6e03c6e","type":"debug","z":"d1395164b4eec73e","name":"debug 2575","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":610,"y":7740,"wires":[]}]

Your code is crashing my Node Red when I try and deploy with Error: Unrecognized Error: 3
:confused:

I tried recreating by just copying and same issue...

I'm also a little confused how I can use that tho - what I really need is to get the device name or unique identifier when the description is "Boost the Heating"

here is an example output I receive

{"data":{"recordKey":"A1A6CSBYZN6GSG#1728488546984#A1RABVCI4QCIKC#G090XG0894221VHG","recordType":"VOICE_HISTORY","timestamp":1728488546984,"customerId":"A1A6CSBYZN6GSG","device":{"deviceName":"Study","deviceEntityId":null},"isBinaryFeedbackProvided":false,"isFeedbackPositive":false,"utteranceType":"GENERAL","domain":"Routines","intent":"InvokeRoutineIntent","skillName":"","voiceHistoryRecordItems":[{"recordItemKey":"1728488546984#A1RABVCI4QCIKC#G090XG0894221VHG#1728488546970-0","recordItemType":"CUSTOMER_TRANSCRIPT","utteranceId":"A1RABVCI4QCIKC:1.0/2024/10/09/15/DEVICE_UNSPECIFIED/42:25::TNIH_2V.e574d79a-6c1b-406f-afc7-1078c2d7bbfcLPM/1","timestamp":1728488546970,"transcriptText":"boost the heating","agentVisualName":"","personsInfo":[{"personId":"amzn1.actor.person.oid.A3DVZJCMF7RKLW","personFirstName":"Name","personType":"ADULT"}]},{"recordItemKey":"1728488546984#A1RABVCI4QCIKC#G090XG0894221VHG#1728488546986-2","recordItemType":"ALEXA_RESPONSE","utteranceId":"A1RABVCI4QCIKC:1.0/2024/10/09/15/DEVICE_UNSPECIFIED/42:25::TNIH_2V.e574d79a-6c1b-406f-afc7-1078c2d7bbfcLPM/1","timestamp":1728488546986,"transcriptText":"","agentVisualName":"","personsInfo":[{"personId":"amzn1.actor.person.oid.A3DVZJCMF7RKLW","personFirstName":"Name","personType":"ADULT"}]},{"recordItemKey":null,"recordItemType":"PROFILE","utteranceId":null,"timestamp":0,"transcriptText":null,"agentVisualName":null,"personsInfo":[{"personId":"amzn1.actor.person.oid.A3DVZJCMF7RKLW","personFirstName":"Name","personType":"ADULT"}]}],"personsInfo":[{"personId":"amzn1.actor.person.oid.A3DVZJCMF7RKLW","personFirstName":"Name","personType":"ADULT"}],"cardResponse":null},"conversionDetails":{"CUSTOMER_TRANSCRIPT":[{"recordItemKey":"1728488546984#A1RABVCI4QCIKC#G090XG0894221VHG#1728488546970-0","recordItemType":"CUSTOMER_TRANSCRIPT","utteranceId":"A1RABVCI4QCIKC:1.0/2024/10/09/15/DEVICE_UNSPECIFIED/42:25::TNIH_2V.e574d79a-6c1b-406f-afc7-1078c2d7bbfcLPM/1","timestamp":1728488546970,"transcriptText":"boost the heating","agentVisualName":"","personsInfo":[{"personId":"amzn1.actor.person.oid.A3DVZJCMF7RKLW","personFirstName":"Name","personType":"ADULT"}]}],"ALEXA_RESPONSE":[{"recordItemKey":"1728488546984#A1RABVCI4QCIKC#G090XG0894221VHG#1728488546986-2","recordItemType":"ALEXA_RESPONSE","utteranceId":"A1RABVCI4QCIKC:1.0/2024/10/09/15/DEVICE_UNSPECIFIED/42:25::TNIH_2V.e574d79a-6c1b-406f-afc7-1078c2d7bbfcLPM/1","timestamp":1728488546986,"transcriptText":"","agentVisualName":"","personsInfo":[{"personId":"amzn1.actor.person.oid.A3DVZJCMF7RKLW","personFirstName":"Name","personType":"ADULT"}]}],"PROFILE":[{"recordItemKey":null,"recordItemType":"PROFILE","utteranceId":null,"timestamp":0,"transcriptText":null,"agentVisualName":null,"personsInfo":[{"personId":"amzn1.actor.person.oid.A3DVZJCMF7RKLW","personFirstName":"Name","personType":"ADULT"}]}]},"deviceType":"A1RABVCI4QCIKC","creationTimestamp":1728488546984,"deviceSerialNumber":"G090XG0894221VHG","name":"Study","description":{"summary":"boost the heating"},"alexaResponse":""}

What I really want in this use case is the output "Study"

But that was array item 1 of 9. Next time it might be 7 of 9

This is probably not a very fool proof method if multiple Alexa's can hear the message.
Get activities returns the last 10 events, regardless of any settings in the node.

The LAST activity will always be record [0] so in theory what you need is payload[0].name

Need to know how you used my code.

Another example and output

[{"id":"0a18b02cc63066cf","type":"inject","z":"d1395164b4eec73e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[{\"data\":{\"recordKey\":\"A1A6CSBYZN6GSG#1728488546984#A1RABVCI4QCIKC#G090XG0894221VHG\",\"recordType\":\"VOICE_HISTORY\",\"timestamp\":1728488546984,\"customerId\":\"A1A6CSBYZN6GSG\",\"device\":{\"deviceName\":\"Study\",\"deviceEntityId\":null},\"isBinaryFeedbackProvided\":false,\"isFeedbackPositive\":false,\"utteranceType\":\"GENERAL\",\"domain\":\"Routines\",\"intent\":\"InvokeRoutineIntent\",\"skillName\":\"\",\"voiceHistoryRecordItems\":[{\"recordItemKey\":\"1728488546984#A1RABVCI4QCIKC#G090XG0894221VHG#1728488546970-0\",\"recordItemType\":\"CUSTOMER_TRANSCRIPT\",\"utteranceId\":\"A1RABVCI4QCIKC:1.0/2024/10/09/15/DEVICE_UNSPECIFIED/42:25::TNIH_2V.e574d79a-6c1b-406f-afc7-1078c2d7bbfcLPM/1\",\"timestamp\":1728488546970,\"transcriptText\":\"boost the heating\",\"agentVisualName\":\"\",\"personsInfo\":[{\"personId\":\"amzn1.actor.person.oid.A3DVZJCMF7RKLW\",\"personFirstName\":\"Name\",\"personType\":\"ADULT\"}]},{\"recordItemKey\":\"1728488546984#A1RABVCI4QCIKC#G090XG0894221VHG#1728488546986-2\",\"recordItemType\":\"ALEXA_RESPONSE\",\"utteranceId\":\"A1RABVCI4QCIKC:1.0/2024/10/09/15/DEVICE_UNSPECIFIED/42:25::TNIH_2V.e574d79a-6c1b-406f-afc7-1078c2d7bbfcLPM/1\",\"timestamp\":1728488546986,\"transcriptText\":\"\",\"agentVisualName\":\"\",\"personsInfo\":[{\"personId\":\"amzn1.actor.person.oid.A3DVZJCMF7RKLW\",\"personFirstName\":\"Name\",\"personType\":\"ADULT\"}]},{\"recordItemKey\":null,\"recordItemType\":\"PROFILE\",\"utteranceId\":null,\"timestamp\":0,\"transcriptText\":null,\"agentVisualName\":null,\"personsInfo\":[{\"personId\":\"amzn1.actor.person.oid.A3DVZJCMF7RKLW\",\"personFirstName\":\"Name\",\"personType\":\"ADULT\"}]}],\"personsInfo\":[{\"personId\":\"amzn1.actor.person.oid.A3DVZJCMF7RKLW\",\"personFirstName\":\"Name\",\"personType\":\"ADULT\"}],\"cardResponse\":null},\"conversionDetails\":{\"CUSTOMER_TRANSCRIPT\":[{\"recordItemKey\":\"1728488546984#A1RABVCI4QCIKC#G090XG0894221VHG#1728488546970-0\",\"recordItemType\":\"CUSTOMER_TRANSCRIPT\",\"utteranceId\":\"A1RABVCI4QCIKC:1.0/2024/10/09/15/DEVICE_UNSPECIFIED/42:25::TNIH_2V.e574d79a-6c1b-406f-afc7-1078c2d7bbfcLPM/1\",\"timestamp\":1728488546970,\"transcriptText\":\"boost the heating\",\"agentVisualName\":\"\",\"personsInfo\":[{\"personId\":\"amzn1.actor.person.oid.A3DVZJCMF7RKLW\",\"personFirstName\":\"Name\",\"personType\":\"ADULT\"}]}],\"ALEXA_RESPONSE\":[{\"recordItemKey\":\"1728488546984#A1RABVCI4QCIKC#G090XG0894221VHG#1728488546986-2\",\"recordItemType\":\"ALEXA_RESPONSE\",\"utteranceId\":\"A1RABVCI4QCIKC:1.0/2024/10/09/15/DEVICE_UNSPECIFIED/42:25::TNIH_2V.e574d79a-6c1b-406f-afc7-1078c2d7bbfcLPM/1\",\"timestamp\":1728488546986,\"transcriptText\":\"\",\"agentVisualName\":\"\",\"personsInfo\":[{\"personId\":\"amzn1.actor.person.oid.A3DVZJCMF7RKLW\",\"personFirstName\":\"Name\",\"personType\":\"ADULT\"}]}],\"PROFILE\":[{\"recordItemKey\":null,\"recordItemType\":\"PROFILE\",\"utteranceId\":null,\"timestamp\":0,\"transcriptText\":null,\"agentVisualName\":null,\"personsInfo\":[{\"personId\":\"amzn1.actor.person.oid.A3DVZJCMF7RKLW\",\"personFirstName\":\"Name\",\"personType\":\"ADULT\"}]}]},\"deviceType\":\"A1RABVCI4QCIKC\",\"creationTimestamp\":1728488546984,\"deviceSerialNumber\":\"G090XG0894221VHG\",\"name\":\"Study\",\"description\":{\"summary\":\"boost the heating\"},\"alexaResponse\":\"\"}]","payloadType":"json","x":430,"y":7660,"wires":[["2527468f539263ad"]]},{"id":"2527468f539263ad","type":"change","z":"d1395164b4eec73e","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$$.payload[$contains($.description.summary, \"boost the heating\")]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":600,"y":7620,"wires":[["d6e46592f6e03c6e","904d55ec96fc2ae0"]]},{"id":"d6e46592f6e03c6e","type":"debug","z":"d1395164b4eec73e","name":"debug 2575","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":810,"y":7660,"wires":[]},{"id":"904d55ec96fc2ae0","type":"debug","z":"d1395164b4eec73e","name":"debug 2576","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.name","targetType":"msg","statusVal":"","statusType":"auto","x":810,"y":7720,"wires":[]}]

Just feed the output of the alexa other node into the change node.

Hmm, that doesn't seem to be happening in my case - it seems because I am in earshot of say 4 alexa devices, the ones further away that happen to pick up the message (even if it's determined by alexa to not be the primary one) end up in later payloads

If multiple devices are hearing the command it will be more difficult to isolate the one you are nearest to.
you may be able to order by the timestamp and select the oldest. can we see the full array output of the other node?

Here is the full output

[{"data":{"recordKey":"A1A6CSBYZN6GSG#1728491001183#A4ZXE0RM7LQ7A#G6G225053152035L","recordType":"VOICE_HISTORY","timestamp":1728491001183,"customerId":"A1A6CSBYZN6GSG","device":{"deviceName":"Alana's Owl","deviceEntityId":null},"isBinaryFeedbackProvided":false,"isFeedbackPositive":false,"utteranceType":"ASR_TIMEOUT","domain":"","intent":"Unknown","skillName":"","voiceHistoryRecordItems":[{"recordItemKey":"1728491001183#A4ZXE0RM7LQ7A#G6G225053152035L#0-0","recordItemType":"ASR_REPLACEMENT_TEXT","utteranceId":"A4ZXE0RM7LQ7A:1.0/2024/10/09/16/DEVICE_UNSPECIFIED/23:15::TNIH_2V.916cd5ff-619d-467d-9da5-f34c414eacb3LPM","timestamp":0,"transcriptText":"","agentVisualName":"","personsInfo":[]}],"personsInfo":[],"cardResponse":null},"conversionDetails":{"ASR_REPLACEMENT_TEXT":[{"recordItemKey":"1728491001183#A4ZXE0RM7LQ7A#G6G225053152035L#0-0","recordItemType":"ASR_REPLACEMENT_TEXT","utteranceId":"A4ZXE0RM7LQ7A:1.0/2024/10/09/16/DEVICE_UNSPECIFIED/23:15::TNIH_2V.916cd5ff-619d-467d-9da5-f34c414eacb3LPM","timestamp":0,"transcriptText":"","agentVisualName":"","personsInfo":[]}]},"deviceType":"A4ZXE0RM7LQ7A","creationTimestamp":1728491001183,"deviceSerialNumber":"G6G225053152035L","name":"Alana's Owl","description":{"summary":""},"alexaResponse":""},{"data":{"recordKey":"A1A6CSBYZN6GSG#1728490997574#A1RABVCI4QCIKC#G090XG0894221VHG","recordType":"VOICE_HISTORY","timestamp":1728490997574,"customerId":"A1A6CSBYZN6GSG","device":{"deviceName":"Study","deviceEntityId":null},"isBinaryFeedbackProvided":false,"isFeedbackPositive":false,"utteranceType":"GENERAL","domain":"Routines","intent":"InvokeRoutineIntent","skillName":"","voiceHistoryRecordItems":[{"recordItemKey":"1728490997574#A1RABVCI4QCIKC#G090XG0894221VHG#1728490997567-0","recordItemType":"CUSTOMER_TRANSCRIPT","utteranceId":"A1RABVCI4QCIKC:1.0/2024/10/09/16/DEVICE_UNSPECIFIED/23:15::TNIH_2V.ae4810eb-0fbe-48ea-9ae4-b32f9518d108LPM/1","timestamp":1728490997567,"transcriptText":"boost the heating","agentVisualName":"","personsInfo":[]},{"recordItemKey":"1728490997574#A1RABVCI4QCIKC#G090XG0894221VHG#1728490997576-2","recordItemType":"ALEXA_RESPONSE","utteranceId":"A1RABVCI4QCIKC:1.0/2024/10/09/16/DEVICE_UNSPECIFIED/23:15::TNIH_2V.ae4810eb-0fbe-48ea-9ae4-b32f9518d108LPM/1","timestamp":1728490997576,"transcriptText":"","agentVisualName":"","personsInfo":[]}],"personsInfo":[],"cardResponse":null},"conversionDetails":{"CUSTOMER_TRANSCRIPT":[{"recordItemKey":"1728490997574#A1RABVCI4QCIKC#G090XG0894221VHG#1728490997567-0","recordItemType":"CUSTOMER_TRANSCRIPT","utteranceId":"A1RABVCI4QCIKC:1.0/2024/10/09/16/DEVICE_UNSPECIFIED/23:15::TNIH_2V.ae4810eb-0fbe-48ea-9ae4-b32f9518d108LPM/1","timestamp":1728490997567,"transcriptText":"boost the heating","agentVisualName":"","personsInfo":[]}],"ALEXA_RESPONSE":[{"recordItemKey":"1728490997574#A1RABVCI4QCIKC#G090XG0894221VHG#1728490997576-2","recordItemType":"ALEXA_RESPONSE","utteranceId":"A1RABVCI4QCIKC:1.0/2024/10/09/16/DEVICE_UNSPECIFIED/23:15::TNIH_2V.ae4810eb-0fbe-48ea-9ae4-b32f9518d108LPM/1","timestamp":1728490997576,"transcriptText":"","agentVisualName":"","personsInfo":[]}]},"deviceType":"A1RABVCI4QCIKC","creationTimestamp":1728490997574,"deviceSerialNumber":"G090XG0894221VHG","name":"Study","description":{"summary":"boost the heating"},"alexaResponse":""},{"data":{"recordKey":"A1A6CSBYZN6GSG#1728490997381#A4ZXE0RM7LQ7A#G0922G0524831SU3","recordType":"VOICE_HISTORY","timestamp":1728490997381,"customerId":"A1A6CSBYZN6GSG","device":{"deviceName":"Ethan's Dragon","deviceEntityId":null},"isBinaryFeedbackProvided":false,"isFeedbackPositive":false,"utteranceType":"DEVICE_ARBITRATION","domain":"","intent":"Unknown","skillName":"","voiceHistoryRecordItems":[{"recordItemKey":"1728490997381#A4ZXE0RM7LQ7A#G0922G0524831SU3#1728490997371-0","recordItemType":"ASR_REPLACEMENT_TEXT","utteranceId":"A4ZXE0RM7LQ7A:1.0/2024/10/09/16/DEVICE_UNSPECIFIED/23:15::TNIH_2V.e116f0ac-6ec5-445a-9039-45b57526a478LPM/1","timestamp":1728490997371,"transcriptText":"boost the heating","agentVisualName":"","personsInfo":[]}],"personsInfo":[],"cardResponse":null},"conversionDetails":{"ASR_REPLACEMENT_TEXT":[{"recordItemKey":"1728490997381#A4ZXE0RM7LQ7A#G0922G0524831SU3#1728490997371-0","recordItemType":"ASR_REPLACEMENT_TEXT","utteranceId":"A4ZXE0RM7LQ7A:1.0/2024/10/09/16/DEVICE_UNSPECIFIED/23:15::TNIH_2V.e116f0ac-6ec5-445a-9039-45b57526a478LPM/1","timestamp":1728490997371,"transcriptText":"boost the heating","agentVisualName":"","personsInfo":[]}]},"deviceType":"A4ZXE0RM7LQ7A","creationTimestamp":1728490997381,"deviceSerialNumber":"G0922G0524831SU3","name":"Ethan's Dragon","description":{"summary":"boost the heating"},"alexaResponse":""},{"data":{"recordKey":"A1A6CSBYZN6GSG#1728490996196#A4ZXE0RM7LQ7A#G6G225053152035L","recordType":"VOICE_HISTORY","timestamp":1728490996196,"customerId":"A1A6CSBYZN6GSG","device":{"deviceName":"Alana's Owl","deviceEntityId":null},"isBinaryFeedbackProvided":false,"isFeedbackPositive":false,"utteranceType":"WAKE_WORD_ONLY","domain":"","intent":"Unknown","skillName":"","voiceHistoryRecordItems":[{"recordItemKey":"1728490996196#A4ZXE0RM7LQ7A#G6G225053152035L#1728490996189-0","recordItemType":"ASR_REPLACEMENT_TEXT","utteranceId":"A4ZXE0RM7LQ7A:1.0/2024/10/09/16/DEVICE_UNSPECIFIED/23:15::TNIH_2V.916cd5ff-619d-467d-9da5-f34c414eacb3LPM/0","timestamp":1728490996189,"transcriptText":"alexa","agentVisualName":"","personsInfo":[]}],"personsInfo":[],"cardResponse":null},"conversionDetails":{"ASR_REPLACEMENT_TEXT":[{"recordItemKey":"1728490996196#A4ZXE0RM7LQ7A#G6G225053152035L#1728490996189-0","recordItemType":"ASR_REPLACEMENT_TEXT","utteranceId":"A4ZXE0RM7LQ7A:1.0/2024/10/09/16/DEVICE_UNSPECIFIED/23:15::TNIH_2V.916cd5ff-619d-467d-9da5-f34c414eacb3LPM/0","timestamp":1728490996189,"transcriptText":"alexa","agentVisualName":"","personsInfo":[]}]},"deviceType":"A4ZXE0RM7LQ7A","creationTimestamp":1728490996196,"deviceSerialNumber":"G6G225053152035L","name":"Alana's Owl","description":{"summary":""},"alexaResponse":""},{"data":{"recordKey":"A1A6CSBYZN6GSG#1728490996088#A4ZXE0RM7LQ7A#G0922G0524831SU3","recordType":"VOICE_HISTORY","timestamp":1728490996088,"customerId":"A1A6CSBYZN6GSG","device":{"deviceName":"Ethan's Dragon","deviceEntityId":null},"isBinaryFeedbackProvided":false,"isFeedbackPositive":false,"utteranceType":"WAKE_WORD_ONLY","domain":"","intent":"Unknown","skillName":"","voiceHistoryRecordItems":[{"recordItemKey":"1728490996088#A4ZXE0RM7LQ7A#G0922G0524831SU3#1728490996075-0","recordItemType":"ASR_REPLACEMENT_TEXT","utteranceId":"A4ZXE0RM7LQ7A:1.0/2024/10/09/16/DEVICE_UNSPECIFIED/23:15::TNIH_2V.e116f0ac-6ec5-445a-9039-45b57526a478LPM/0","timestamp":1728490996075,"transcriptText":"alexa","agentVisualName":"","personsInfo":[]}],"personsInfo":[],"cardResponse":null},"conversionDetails":{"ASR_REPLACEMENT_TEXT":[{"recordItemKey":"1728490996088#A4ZXE0RM7LQ7A#G0922G0524831SU3#1728490996075-0","recordItemType":"ASR_REPLACEMENT_TEXT","utteranceId":"A4ZXE0RM7LQ7A:1.0/2024/10/09/16/DEVICE_UNSPECIFIED/23:15::TNIH_2V.e116f0ac-6ec5-445a-9039-45b57526a478LPM/0","timestamp":1728490996075,"transcriptText":"alexa","agentVisualName":"","personsInfo":[]}]},"deviceType":"A4ZXE0RM7LQ7A","creationTimestamp":1728490996088,"deviceSerialNumber":"G0922G0524831SU3","name":"Ethan's Dragon","description":{"summary":""},"alexaResponse":""},{"data":{"recordKey":"A1A6CSBYZN6GSG#1728490996013#A1RABVCI4QCIKC#G090XG0894221VHG","recordType":"VOICE_HISTORY","timestamp":1728490996013,"customerId":"A1A6CSBYZN6GSG","device":{"deviceName":"Study","deviceEntityId":null},"isBinaryFeedbackProvided":false,"isFeedbackPositive":false,"utteranceType":"WAKE_WORD_ONLY","domain":"","intent":"Unknown","skillName":"","voiceHistoryRecordItems":[{"recordItemKey":"1728490996013#A1RABVCI4QCIKC#G090XG0894221VHG#1728490996011-0","recordItemType":"ASR_REPLACEMENT_TEXT","utteranceId":"A1RABVCI4QCIKC:1.0/2024/10/09/16/DEVICE_UNSPECIFIED/23:15::TNIH_2V.ae4810eb-0fbe-48ea-9ae4-b32f9518d108LPM/0","timestamp":1728490996011,"transcriptText":"alexa","agentVisualName":"","personsInfo":[]}],"personsInfo":[],"cardResponse":null},"conversionDetails":{"ASR_REPLACEMENT_TEXT":[{"recordItemKey":"1728490996013#A1RABVCI4QCIKC#G090XG0894221VHG#1728490996011-0","recordItemType":"ASR_REPLACEMENT_TEXT","utteranceId":"A1RABVCI4QCIKC:1.0/2024/10/09/16/DEVICE_UNSPECIFIED/23:15::TNIH_2V.ae4810eb-0fbe-48ea-9ae4-b32f9518d108LPM/0","timestamp":1728490996011,"transcriptText":"alexa","agentVisualName":"","personsInfo":[]}]},"deviceType":"A1RABVCI4QCIKC","creationTimestamp":1728490996013,"deviceSerialNumber":"G090XG0894221VHG","name":"Study","description":{"summary":""},"alexaResponse":""},{"data":{"recordKey":"A1A6CSBYZN6GSG#1728490268798#A15996VY63BQ2D#G091GG1022650114","recordType":"VOICE_HISTORY","timestamp":1728490268798,"customerId":"A1A6CSBYZN6GSG","device":{"deviceName":"Dining Room Echo Show","deviceEntityId":null},"isBinaryFeedbackProvided":false,"isFeedbackPositive":false,"utteranceType":"GENERAL","domain":"Global","intent":"VolumeDownIntent","skillName":"","voiceHistoryRecordItems":[{"recordItemKey":"1728490268798#A15996VY63BQ2D#G091GG1022650114#1728490268776-0","recordItemType":"CUSTOMER_TRANSCRIPT","utteranceId":"A15996VY63BQ2D:1.0/2024/10/09/16/DEVICE_UNSPECIFIED/11:05::TNIH_2V.7d2dc6af-076c-4148-a897-376768305eaaLPM/1","timestamp":1728490268776,"transcriptText":"volume down","agentVisualName":"","personsInfo":[]}],"personsInfo":[],"cardResponse":null},"conversionDetails":{"CUSTOMER_TRANSCRIPT":[{"recordItemKey":"1728490268798#A15996VY63BQ2D#G091GG1022650114#1728490268776-0","recordItemType":"CUSTOMER_TRANSCRIPT","utteranceId":"A15996VY63BQ2D:1.0/2024/10/09/16/DEVICE_UNSPECIFIED/11:05::TNIH_2V.7d2dc6af-076c-4148-a897-376768305eaaLPM/1","timestamp":1728490268776,"transcriptText":"volume down","agentVisualName":"","personsInfo":[]}]},"deviceType":"A15996VY63BQ2D","creationTimestamp":1728490268798,"deviceSerialNumber":"G091GG1022650114","name":"Dining Room Echo Show","description":{"summary":"volume down"},"alexaResponse":""},{"data":{"recordKey":"A1A6CSBYZN6GSG#1728490266098#A15996VY63BQ2D#G091GG1022650114","recordType":"VOICE_HISTORY","timestamp":1728490266098,"customerId":"A1A6CSBYZN6GSG","device":{"deviceName":"Dining Room Echo Show","deviceEntityId":null},"isBinaryFeedbackProvided":false,"isFeedbackPositive":false,"utteranceType":"WAKE_WORD_ONLY","domain":"","intent":"Unknown","skillName":"","voiceHistoryRecordItems":[{"recordItemKey":"1728490266098#A15996VY63BQ2D#G091GG1022650114#1728490266087-0","recordItemType":"ASR_REPLACEMENT_TEXT","utteranceId":"A15996VY63BQ2D:1.0/2024/10/09/16/DEVICE_UNSPECIFIED/11:05::TNIH_2V.7d2dc6af-076c-4148-a897-376768305eaaLPM/0","timestamp":1728490266087,"transcriptText":"alexa","agentVisualName":"","personsInfo":[]}],"personsInfo":[],"cardResponse":null},"conversionDetails":{"ASR_REPLACEMENT_TEXT":[{"recordItemKey":"1728490266098#A15996VY63BQ2D#G091GG1022650114#1728490266087-0","recordItemType":"ASR_REPLACEMENT_TEXT","utteranceId":"A15996VY63BQ2D:1.0/2024/10/09/16/DEVICE_UNSPECIFIED/11:05::TNIH_2V.7d2dc6af-076c-4148-a897-376768305eaaLPM/0","timestamp":1728490266087,"transcriptText":"alexa","agentVisualName":"","personsInfo":[]}]},"deviceType":"A15996VY63BQ2D","creationTimestamp":1728490266098,"deviceSerialNumber":"G091GG1022650114","name":"Dining Room Echo Show","description":{"summary":""},"alexaResponse":""},{"data":{"recordKey":"A1A6CSBYZN6GSG#1728490260583#A15996VY63BQ2D#G091GG1022650114","recordType":"VOICE_HISTORY","timestamp":1728490260583,"customerId":"A1A6CSBYZN6GSG","device":{"deviceName":"Dining Room Echo Show","deviceEntityId":null},"isBinaryFeedbackProvided":false,"isFeedbackPositive":false,"utteranceType":"GENERAL","domain":"Global","intent":"VolumeDownIntent","skillName":"","voiceHistoryRecordItems":[{"recordItemKey":"1728490260583#A15996VY63BQ2D#G091GG1022650114#1728490260574-0","recordItemType":"CUSTOMER_TRANSCRIPT","utteranceId":"A15996VY63BQ2D:1.0/2024/10/09/16/DEVICE_UNSPECIFIED/10:58::TNIH_2V.288cadd5-7e18-428c-94a8-cf746bf86a8cLPM/1","timestamp":1728490260574,"transcriptText":"volume down","agentVisualName":"","personsInfo":[]}],"personsInfo":[],"cardResponse":null},"conversionDetails":{"CUSTOMER_TRANSCRIPT":[{"recordItemKey":"1728490260583#A15996VY63BQ2D#G091GG1022650114#1728490260574-0","recordItemType":"CUSTOMER_TRANSCRIPT","utteranceId":"A15996VY63BQ2D:1.0/2024/10/09/16/DEVICE_UNSPECIFIED/10:58::TNIH_2V.288cadd5-7e18-428c-94a8-cf746bf86a8cLPM/1","timestamp":1728490260574,"transcriptText":"volume down","agentVisualName":"","personsInfo":[]}]},"deviceType":"A15996VY63BQ2D","creationTimestamp":1728490260583,"deviceSerialNumber":"G091GG1022650114","name":"Dining Room Echo Show","description":{"summary":"volume down"},"alexaResponse":""},{"data":{"recordKey":"A1A6CSBYZN6GSG#1728490260476#A4ZXE0RM7LQ7A#G0922H0725170DUK","recordType":"VOICE_HISTORY","timestamp":1728490260476,"customerId":"A1A6CSBYZN6GSG","device":{"deviceName":"TV Echo Dot","deviceEntityId":null},"isBinaryFeedbackProvided":false,"isFeedbackPositive":false,"utteranceType":"DEVICE_ARBITRATION","domain":"","intent":"Unknown","skillName":"","voiceHistoryRecordItems":[{"recordItemKey":"1728490260476#A4ZXE0RM7LQ7A#G0922H0725170DUK#1728490260469-0","recordItemType":"ASR_REPLACEMENT_TEXT","utteranceId":"A4ZXE0RM7LQ7A:1.0/2024/10/09/16/DEVICE_UNSPECIFIED/10:58::TNIH_2V.56e0101f-21df-4f1a-b3b6-a278f7521857LPM/1","timestamp":1728490260469,"transcriptText":"volume down","agentVisualName":"","personsInfo":[]}],"personsInfo":[],"cardResponse":null},"conversionDetails":{"ASR_REPLACEMENT_TEXT":[{"recordItemKey":"1728490260476#A4ZXE0RM7LQ7A#G0922H0725170DUK#1728490260469-0","recordItemType":"ASR_REPLACEMENT_TEXT","utteranceId":"A4ZXE0RM7LQ7A:1.0/2024/10/09/16/DEVICE_UNSPECIFIED/10:58::TNIH_2V.56e0101f-21df-4f1a-b3b6-a278f7521857LPM/1","timestamp":1728490260469,"transcriptText":"volume down","agentVisualName":"","personsInfo":[]}]},"deviceType":"A4ZXE0RM7LQ7A","creationTimestamp":1728490260476,"deviceSerialNumber":"G0922H0725170DUK","name":"TV Echo Dot","description":{"summary":"volume down"},"alexaResponse":""}]

THis should pick the oldest command out of the 10 array items

$$.payload[$contains($.description.summary, "boost the heating")]^(>$.data.timestamp)[0]

If the command is repeated and in the 10 items you could possibly limit the age of the timestamp to 5 -10 seconds, this would rule out older commands that may still be in array responds from other node.

Thanks, sadly after running a few tests on that, seems that the oldest isn't sufficient.
First few attempts worked well, but then different devices seemed to come up later :frowning:

Edit. I've had an idea - if I give the routine an Alexa response (e.g. "Okay - boosting the heating") - the alexaResponse: "" value would be set only on the device that was spoken to and could search based on that?

Edit2: nope - that field obviously isn't what i thought it was

try

$$.payload[$contains($.alexaResponse, "boosting the heating")

But i still think you would get all the responses to any device that heard the command.

As said above you could only return the timestamp of a limited age. This may rule out older commands.

Sorry - alexaResponse doesn't seem to do what I thought it did after testing (edited the post)

However- looking at the events

Array->Object->conversionDetails seems to contain ASR_REPLACEMENT_TEXT when it is NOT the device being spoken to and CUSTOMER_TRANSCRIPT when it is the device being spoken to

Can we use that?

Edit - square is indicating an array, not sure why it's converted two square brackets to a square!

A combination of the two

$$.payload["CUSTOMER_TRANSCRIPT" in $keys($.conversionDetails) and $contains($.description.summary, "boost the heating")]

this maybe more robust

[$$.payload["CUSTOMER_TRANSCRIPT" in $keys($.conversionDetails) and $contains($.description.summary, "boost the heating")]][0]

[0] returns first and [-1] will return last

As the forum uses markdown and [ ]is a check box. use `[ ]`, use bacticks to surround any code.

1 Like

That seems to do the trick!
I've not tested extensively, but tested 4 devices around the house and seemed to work!!

I shall give it a play over the next few days and see if it continues to play ball :slight_smile:
Thank you!

Further testing and this seems to be working really well!

One further question - I've realised the routine has a few different options "heating boost" and "it's cold"
My wife likes to use one of those (of course!) so is there a way to build an or into the detection in the initial node?

I presume I could have three different nodes looking for the different phrases, but seems inefficient!

if you add it's cold and heating boost to the alexa routine , then you should be able to do something like

[$$.payload["CUSTOMER_TRANSCRIPT" in $keys($.conversionDetails) and
	    $.description.summary in ["boost the heating","heating boost", "it's cold"]]][0]

That works great, but after testing this I'm now finding that the room is picking up incorrectly :cry:

I have two rooms close to each other, the one is responding but the other is being detected... I suspect it's because I'm creating slightly artificial scenarios in testing

Edit - I'm not allowed to post again for a bit as a new user :frowning: - will respond in a bit, but typically it's now working in my tests

Show us the debug of the change node.
[edit] also show us the output if you remove the [0] of the expression

You should be able to automate the whole sequence and collect the utterances from the routine you require.
e.g.

[{"id":"5f36f9963b89697a","type":"inject","z":"d1395164b4eec73e","name":"","props":[{"p":"routine","v":"open router","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":250,"y":7640,"wires":[["fa60a0b5b7522ddd"]]},{"id":"fa60a0b5b7522ddd","type":"alexa-remote-other","z":"d1395164b4eec73e","name":"","account":"c8738129.d902c","config":{"option":"get","value":{"what":"automationRoutines"}},"x":470,"y":7640,"wires":[["4dd3de929cb75875"]]},{"id":"4dd3de929cb75875","type":"change","z":"d1395164b4eec73e","name":"","rules":[{"t":"set","p":"utterances","pt":"msg","to":"[payload[name = $$.routine].triggers.payload.utterances]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":750,"y":7640,"wires":[["d6e46592f6e03c6e","e71c2f9c2f2ebbe8"]]},{"id":"d6e46592f6e03c6e","type":"debug","z":"d1395164b4eec73e","name":"debug 2575","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"utterances","targetType":"msg","statusVal":"","statusType":"auto","x":870,"y":7580,"wires":[]},{"id":"e71c2f9c2f2ebbe8","type":"alexa-remote-other","z":"d1395164b4eec73e","name":"","account":"c8738129.d902c","config":{"option":"get","value":{"what":"activities","count":{"type":"num","value":"1"},"offset":{"type":"num","value":"1"}}},"x":310,"y":7740,"wires":[["2527468f539263ad"]]},{"id":"2527468f539263ad","type":"change","z":"d1395164b4eec73e","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"[$$.payload[\"CUSTOMER_TRANSCRIPT\" in $keys($.conversionDetails) and \t    $.description.summary in $$.utterances]][0]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":7740,"wires":[["904d55ec96fc2ae0"]]},{"id":"904d55ec96fc2ae0","type":"debug","z":"d1395164b4eec73e","name":"debug 2576","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.name","targetType":"msg","statusVal":"","statusType":"auto","x":750,"y":7740,"wires":[]},{"id":"c8738129.d902c","type":"alexa-remote-account","name":"alexa remote 2","authMethod":"proxy","proxyOwnIp":"localhost","proxyPort":"3456","cookieFile":"/data/data/com.termux/files/home/.node-red/.alexa.cookie","refreshInterval":"14","alexaServiceHost":"layla.amazon.co.uk","pushDispatchHost":"","amazonPage":"amazon.co.uk","acceptLanguage":"en-GB","onKeywordInLanguage":"","userAgent":"","usePushConnection":"on","autoInit":"off","autoQueryActivityOnTrigger":"off"}]

just add the name of the routine in the inject node..
This way when ever you update the routines trigger words the flow will auto update.