Shivanshu Garg
Shivanshu Garg

Reputation: 67

Display a Hyperlink in alexa skill

Is there any method possible to display a hyperlink like "read more" in Alexa skill? I am trying to display a hyperlink in my custom Alexa skill but could not find any method to implement it

Upvotes: 3

Views: 2562

Answers (2)

ilkeraktuna
ilkeraktuna

Reputation: 31

I tried this in my skill but all I get is a blank (black) page. Normally the Silk browser on Echo Show device can properly display the page I tried.

I used the following APL document to test:

{
  "type": "APL",
  "version": "1.9",
  "description": "A hello world APL document.",
  "theme": "dark",
  "mainTemplate": {
    "parameters": [
      "payload"
    ],
    "items": [
      {
          "type": "OpenURL",
          "source": "http://192.168.254.240/",
          "onFail": {
            "type": "SetValue",
            "componentId": "errorText",
            "property": "text",
            "value": "Unable to open (${event.source.value})"
          }
      }
    ]
  }
}

so what is wrong ?

I found the correct usage (or a workaround):

{
    "type": "APL",
    "version": "1.8",
    "theme": "dark",
    "import": [
        {
            "name": "alexa-layouts",
            "version": "1.5.0"
        }
    ],
"mainTemplate": {
    "parameters": [
        "payload"
    ],
    "items": [
        {
            "type": "Pager",
            "id": "fisrtpager",
            "width": "100%",
            "height": "100%",
            "items": [
            ],
            "navigation": "none",
            "onMount": [{
  "type": "OpenURL",
  "source": "http://192.168.254.240/",
  "onFail": {
    "type": "SetValue",
    "componentId": "errorText",
    "property": "text",
    "value": "Unable to open Amazon.com (${event.source.value})"
  }
            }]
        }
    ]
}
}

Upvotes: 0

Josh Broadhurst
Josh Broadhurst

Reputation: 439

Hyperlinks are now available as part of an APL directive for devices that support it. You can read the documentation here:

OpenURL Command

The OpenURL command, if successful, opens the specified URL in a web browser or other application on the device. You must provide a suitable URL that works on the current device.

They give an example:

{
  "type": "OpenURL",
  "source": "https://www.amazon.com/",
  "onFail": {
    "type": "SetValue",
    "componentId": "errorText",
    "property": "text",
    "value": "Unable to open Amazon.com (${event.source.value})"
  }
}

Description about supported devices:

Not all devices support opening a URL. If the device does not support opening URLs, the command is ignored and it does not run onFail commands. Check the value of the allowOpenURL in the data-binding context to determine if OpenURL is supported on the device.

Upvotes: 4

Related Questions