richtier / alexa-voice-service-client

Python Client for Alexa Voice Service (AVS)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support for template runtime interface.

mushfiq opened this issue · comments

Currently the project does not support TemplateRuntime interface.

For devices where users want to display text and images the supports are needed.

@mushfiq what changes are needed to inform AVS that the device supports templates? I suspect it needs to be alerted to the fact the device has a screen.

@richtier As of my understanding thats actually independent of the client.
AVS checks whether the display card option is enabled or not (in product settings) and when thats enabled, AVS sends TemplateRuntime as part of response directives.

Great. If it's that simple then we should be able to simply check `directive.name == 'RenderTemplate'. Can you test that and let me know.

for directive in alexa_client.send_audio_file(f):
    if directive.name in ['Speak', 'Play']:
        ...
    elif directive.name == 'RenderTemplate':
        print(directive.directive)  # do something with directive template data

@richtier I will check it and let you know soon.

Hi @richtier below is my findings:

elif directive.name == 'RenderTemplate':
        print(directive.directive)  # do something with directive template data

Does not work out of the box.
As the avs_client implementation looks only for octet-stream and it filters out other content type. To overcome that, the current (tested on 1.0.1) implementation needs to be adjusted.

BTW, sorry for late feedback :)

@mushfiq thanks I will add this feature soon.

How did you test it? I will aim to use your method for testing the new feature

@richtier as prerequisite the display card options should be enabled from the product settings.

AVS does not provide RenderTemplate out of the box, for some queries it has template data for some it does not. For testing, I had to try out different queries (generally for asking for a place would return a template).
I am also planning to implement it (but not sure when exactly I will be done with that). If I can finish soon, I will submit a PR.

Hi @richtier I tried the latest version of the client and now RenderTemplate directive is being returned via the client. I am closing this issue. The RenderTemplate payload can be accessed like below:

directive.directive.get("payload")