alexa / alexa-skills-kit-sdk-for-python

The Alexa Skills Kit SDK for Python helps you get a skill up and running quickly, letting you focus on skill logic instead of boilerplate code.
https://developer.amazon.com/en-US/docs/alexa/alexa-skills-kit-sdk-for-python/overview.html
Apache License 2.0
809 stars 204 forks source link

Access to the event's context.System.device.supportedInterfaces.Display attribute #18

Closed bobpskier closed 6 years ago

bobpskier commented 6 years ago

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[X] Bug report  
[ ] Performance issue
[X] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:

While writing a request handler such as:

@sb.request_handler(can_handle_func=is_intent_name("HelloWorldIntent")) def hello_world_intent_handler(handler_input):

I've noticed the handler_input object does not provide access to the supported interfaces for the device. In many use cases the function needs access to the supported interfaces for the device. IE: It wants to return a display template for an Echo Show if a display is available.

A javascript implementation would simply check for:

this.event.context.System.device.supportedInterfaces.Display

The handler_input object in the python SDK does not appear to provide access to the System object via the context object. IE: handler_input.context.System.

Is there a correct way using the alexa-skills-kit-sdk-for-python to determine the supportedInterfaces while handling the request?

I've also noticed that the handler_input object provides :

handler_input.request_envelope.context.system.device.supported_interfaces

Perhaps this is the correct location to detect this setting.

nikhilym commented 6 years ago

Hey @bobpskier , the code you provided is correct. handler_input.request_envelope.context.system.device.supported_interfaces is the object which will provide you content regarding supported interfaces for the skill. Can you try using it and let us know if that is what you were trying to check?

bobpskier commented 6 years ago

Using the request_envelope.context worked correctly for me. Thanks.