question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question: How to use Display.RenderTemplates as directives and get it working

See original GitHub issue

Hi guys,

I’m currently trying to integrate some display responses and wanted to use the Display.RenderTemplates from the Alexa Skills Kit. My problem is, I can’t get it working. Unfortunately, the documentation isn’t really detailed in this point, it just says

The response.directive(Object directive) method allows you to set custom directive objects to devices to perform a specific device-level actions. The full specification for the directive object passed to this method can be found here.

So, here’s the code of the latest of my tries:

                  response
                        .card({
                            type: 'Simple',
                            title: 'Test Title',
                            content: 'short text'
                        })
                        .directive({
                            type: "Display.RenderTemplate",
                            template: {
                                type: "BodyTemplate1",
                                token: "token1",
                                backButton: "VISIBLE",
                                title: "rendertemplate title",
                                textContent: {
                                    primaryText: {
                                        text: `<b>Name:</b> John`,
                                        type: "RichText"
                                    },
                                    secondaryText: {
                                        text: `<b>Phone:</b> 08163/2534`,
                                        type: "RichText"
                                    },
                                    tertiaryText: {
                                        text: "<i>Powered by my awesome skill</i>",
                                        type: "RichText"
                                    }
                                },
                            }
                        })
                        .directive({
                            type: 'Hint',
                            hint: {
                                type: 'PlainText',
                                text: 'test hint'
                            }
                        })
                        .say('this is the answer you want to hear')
                        .shouldEndSession(false)
                        .send();

Well, this code doesn’t work, my Echo Show says there was a problem with the answer of the skill.

So, could anyone show me a working example of such a DisplayTemplate directive please?

Best regards, Benjamin

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:12

github_iconTop GitHub Comments

1reaction
matt-krusecommented, May 14, 2018

The directive method just passes thru whatever json you provide, so you need to validate that your json is correct. You can do this manually in the simulator or thru the SMAPI. Are you testing on a device with display capability? Have you enabled that in your skill configuration? You can’t return display directives unless your skill declares that it requires that API. Here’s a working call to directive for one of my skills:

  if (has_display(request)) {
      response.directive({
          "type" : "Display.RenderTemplate",
          "template" : {
              "type" : "BodyTemplate6",
              "backButton" : "HIDDEN",
              "backgroundImage" : {
                  "contentDescription" : "",
                  "sources" : [{
                          "url" : "https://matt-kruse.github.io/alexa-color-tap/game.jpg",
                          "size" : "MEDIUM"
                      }
                  ]
              },
              "textContent" : {
                  "primaryText" : {
                      "text" : "Color Tap!",
                      "type" : "PlainText"
                  }
              }
          }
      });
  }

0reactions
pschildcommented, Nov 8, 2018

Is there any option for changing text color in List template1. It would be helpful if you share the json sample.

You can easily use RichText and use color. https://developer.amazon.com/de/docs/custom-skills/display-interface-reference.html#supported-markup

@patrickbussmann Did you manage to make it work? AFAIK the supported markup does not include setting the text’s color. Hopefully we get this functionality in the future…

Read more comments on GitHub >

github_iconTop Results From Across the Web

AudioPlayer.Play + Display.RenderTemplate directive, template ...
I passed AudioPlayer.Play and Display.RenderTemplate directives,. when launching skill via echo show, it displays my template for like ~2 seconds and when ...
Read more >
Display Interface Reference | Alexa Skills Kit
This reference describes how to use display templates in the skill service code to achieve the look and ... RenderTemplate and other directives...
Read more >
Echo Show python skill not generating display template
Show activity on this post. This worked for me in python. But not able to render the list template. def build_response(session_attributes ...
Read more >
Screens | litexa
If they are, the APL directive(s) will take precedence and the Display.RenderTemplate directive will be removed! # Installation. The module can be installed ......
Read more >
Alexa Skills Kit SDK for Node.js - npm
Start using alexa-sdk in your project by running `npm i alexa-sdk`. There are 22 other projects in ... RenderTemplate directive in response.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found