AlexaAndroid icon indicating copy to clipboard operation
AlexaAndroid copied to clipboard

How to get the response in text format besides Audio response?

Open chowdary60 opened this issue 6 years ago • 7 comments

hello @willblaschko , @wantitmore ,@prasannakumark

I am trying to display the weather information on device UI. for that when we ask question to Alexa, it supposed to give response of type "Speak " and "RenderTemplate". The RenderTemplate directive will have the weather information in text format.

when i check the AvsResponse i am getting only AvsSpeakItem only .How to get the "Render " object which the actual information about the weather to show it in User interface. any Ideas please?

chowdary60 avatar Apr 10 '18 20:04 chowdary60

You must check your alexa products first, when you create a new product. there have a section "capability" need select "Display Cards With Media" then you will get "RenderTemplate" data. https://drive.google.com/file/d/1qJJm_FR5T3qBdSpYk9w-4UJHdKosjG5e/view

RayHuangDev avatar Apr 12 '18 07:04 RayHuangDev

@RayHuangDev I've done that. In which class can we then get the RenderTemplate? By the way your link does not work!

tatasadi avatar Apr 12 '18 07:04 tatasadi

@Ehsanta83 you can copy link and paste on browser, it's a pic about alexa product setting page BTW, this sample has no AvsRenderTemplate class, need create by your own

RayHuangDev avatar Apr 12 '18 08:04 RayHuangDev

@RayHuangDev Do you have an example of creating it on your own which you can share with us? It would be much appreciated.

tatasadi avatar Apr 12 '18 08:04 tatasadi

@Ehsanta83 here is code below, you can change parameters by your own

public class AvsRenderTemplateItem extends AvsItem { private String mHeaderName; private Payload mPayload;

public AvsRenderTemplateItem(String token, String headerName, Payload payload) {
    super(token);

    mHeaderName = headerName;
    mPayload = payload;
}

public String getmHeaderName() {
    return mHeaderName;
}

public Payload getPayload() {
    return mPayload;
}

}

RayHuangDev avatar Apr 12 '18 09:04 RayHuangDev

@RayHuangDev Thank you for sharing the code. How do you use it? I mean in this project.

tatasadi avatar Apr 12 '18 09:04 tatasadi

add this class in "interfaces" folder such as link below: https://github.com/willblaschko/AlexaAndroid/tree/master/libs/AlexaAndroid/src/main/java/com/willblaschko/android/alexa/interfaces

you can use in BaseActivity->checkQueue()-> else if (current instanceof AvsRenderTemplateItem ){ ... }

https://github.com/willblaschko/AlexaAndroid/blob/master/app/src/main/java/com/willblaschko/android/alexavoicelibrary/BaseActivity.java

RayHuangDev avatar Apr 12 '18 10:04 RayHuangDev