3

I have a need to differentiate between an explicit request and a request from a routine.

Here is an example. Let's say I am controlling a smart light. The light is able to detect occupancy.

If a user comes in the room and says turn on the light, it will check occupancy and turn off. However, if the user creates a scheduled routine to turn the light on, we should disable the occupancy check.

I don't see anything in the documentation for the TurnOn Directive that would indicate the source of the request.

Is there an indicator that I missed? Can I add some indicator? Or has anyone used a different approach to accomplish similar functionality?

Bill Kidwell
  • 280
  • 2
  • 9

1 Answers1

3

The official response from Amazon is that you can't tell the difference. Here is a recent response from Amazon's Alexa developer forum: https://forums.developer.amazon.com/questions/218340/skills-invoking-routines.html

That said, you will generally see additional fields in the launch request if it is launched from a Routine:

"request": {
    "type": "LaunchRequest",
    "requestId": "amzn1.echo-api.request.abunchofnumbers",
    "timestamp": "2020-01-18T22:27:01Z",
    "locale": "en-US",
    "target": {
        "path": "AMAZON.Launch",
        "address": "amzn1.ask.skill.abunchofnumbers"
    },
    "metadata": {
        "referrer": "amzn1.alexa-speechlet-client.SequencedSimpleIntentHandler"
    },
    "body": {},
    "payload": {},
    "targetURI": "alexa://amzn1.ask.skill.abunchofnumbers/AMAZON.Launch",
    "launchRequestType": "FOLLOW_LINK_WITH_RESULT",
    "shouldLinkResultBeReturned": true
}

The target, metadata, body, payload, targetURI, and launchRequestType fields are generally not found when a user launches a skill with their voice. HOWEVER, I do not believe the existence of these fields are unique to being launched by an Alexa Routine. I suspect you'll find them if the skill was launched when, for example, Alexa asks, "Hey, since you like the Blind Monkey skill would you like to try Blind Pig?" and you say "yes."

randyth
  • 95
  • 6