How to use the ask-sdk-core.ImageHelper function in ask-sdk-core

To help you get started, we’ve selected a few ask-sdk-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github internetarchive / internet-archive-voice-apps / functions / src / platform / alexa / response / index.js View on Github external
media.forEach(m => {
        const previousToken = m.previousTrack ? m.previousTrack.contentURL : null;
        debug('previous token', previousToken);
        if (mediaResponseOnly) {
          // https://developer.amazon.com/docs/custom-skills/audioplayer-interface-reference.html#playbacknearlyfinished
          debug('card is not allowed');
        } else {
          debug('render card', m.name, m.description);
          if (m.imageURL) {
            handlerInput.responseBuilder.withStandardCard(m.name, m.description, m.imageURL);
          } else {
            handlerInput.responseBuilder.withSimpleCard(m.name, m.description);
          }
        }

        const art = new Alexa.ImageHelper()
          .withDescription(m.name)
          .addImageInstance(m.imageURL)
          .getImage();

        // TODO: we could find better image for background
        const backgroundImage = art;

        debug('playback audio', m.contentURL);
        handlerInput.responseBuilder.addAudioPlayerPlayDirective(
          // behavior,
          previousToken ? 'ENQUEUE' : 'REPLACE_ALL',
          m.contentURL,
          // token (This token cannot exceed 1024 characters)
          m.contentURL,
          // offsetInMilliseconds
          m.offset,
github alexa / alexa-cookbook / feature-demos / skill-demo-display-directive / lambda / custom / index.js View on Github external
}

    responseBuilder.withStandardCard(
      getCardTitle(selectedState),
      getTextDescription(selectedState),
      getSmallImage(selectedState.Abbreviation),
      getLargeImage(selectedState.Abbreviation),
    );

    speechOutput = getSpeechDescription(selectedState);

    if (supportsDisplay(handlerInput)) {
      const image = new Alexa.ImageHelper()
        .addImageInstance(getLargeImage(selectedState.Abbreviation))
        .getImage();
      const bgImage = new Alexa.ImageHelper()
        .addImageInstance(getBackgroundImage(800, 1200, selectedState.Abbreviation))
        .getImage();
      const title = getCardTitle(selectedState);
      const bodyTemplate = bodyTemplateChoice(getCardTitle(selectedState));
      const primaryText = new Alexa.RichTextContentHelper()
        .withPrimaryText(getTextDescription(selectedState, '<br>'))
        .getTextContent();
      responseBuilder.addRenderTemplateDirective({
        type: bodyTemplate,
        backButton: 'visible',
        backgroundImage: bgImage,
        image,
        title,
        textContent: primaryText,
      });
      speechOutput = `This is the ${getBodyTemplateName(bodyTemplate)} template, also known as body template number ${getBodyTemplateNumber(bodyTemplate)}. `;
github alexa / alexa-cookbook / feature-demos / skill-demo-display-directive / lambda / custom / index.js View on Github external
data.forEach((x) =&gt; {
        const stateImage = new Alexa.ImageHelper().withDescription(`${x.StateName} state flag`);
        for (let y = 0; y &lt; imgHeight.length; y += 1) {
          stateImage.addImageInstance(getImageUrl(imgHeight[y], imgWidth[y], x.Abbreviation));
        }
        statesList.push({
          token: x.Abbreviation,
          textContent: new Alexa.PlainTextContentHelper()
            .withPrimaryText(x.StateName)
            .withSecondaryText(`Abbreviation: ${x.Abbreviation}`)
            .withTertiaryText(`Capital: ${x.Capital}`)
            .getTextContent(),
          image: stateImage.getImage(),
        });
      });
      responseBuilder.addRenderTemplateDirective({