How to use the actions-on-google.BasicCard function in actions-on-google

To help you get started, we’ve selected a few actions-on-google 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 actions-on-google / actionssdk-conversation-components-nodejs / functions / index.js View on Github external
function basicCard(conv) {
  conv.ask('This is the first simple response for a basic card.');
  conv.ask(new Suggestions(intentSuggestions));
  conv.ask(new BasicCard({
    text: `This is a basic card.  Text in a basic card can include "quotes" and
    most other unicode characters including emoji 📱.  Basic cards also support
    some markdown formatting like *emphasis* or _italics_, **strong** or
    __bold__, and ***bold itallic*** or ___strong emphasis___ as well as other
    things like line  \nbreaks`, // Note the two spaces before '\n' required for
                                // a line break to be rendered in the card.
    subtitle: 'This is a subtitle',
    title: 'Title: this is a title',
    buttons: new Button({
      title: 'This is a button',
      url: 'https://assistant.google.com/',
    }),
    image: new Image({
      url: IMG_URL_AOG,
      alt: 'Image alternate text',
    }),
github actions-on-google / actions-on-google-nodejs / samples / js / app / facts-about-google / functions / index.js View on Github external
conv.ask(new Suggestions(otherCategory.suggestion))
    if (cats.length) {
      conv.ask(new Suggestions(responses.cats.suggestion))
    }
    return
  }
  const { factPrefix } = categoryResponse
  // conv.ask can be called multiple times to have the library construct a single response itself
  // the response will get sent at the end of the function
  // or if the function returns a promise, after the promise is resolved
  conv.ask(new SimpleResponse({
    speech: concat(factPrefix, fact),
    text: factPrefix,
  }))
  conv.ask(responses.general.nextFact)
  conv.ask(new BasicCard({
    title: fact,
    image: random(responses.content.images),
    buttons: new Button({
      title: responses.general.linkOut,
      url: responses.content.link,
    }),
  }))
  conv.ask(responses.general.suggestions.confirmation)
})
github actions-on-google / dialogflow-facts-about-google-nodejs / functions / index.js View on Github external
return conv.ask(responses.general.suggestions.newFact);
  }
  const {factPrefix, audio} = responses.cats;
  // conv.ask can be called multiple times to have the library construct
  // a single response itself. The response will get sent at the end of
  // the function or if the function returns a promise, after the promise
  // is resolved.
  const sound = util.format(audio, random(responses.cats.sounds));
  conv.ask(new SimpleResponse({
    //  is needed here since factPrefix is a SSML string
    // and contains audio.
    speech: `${concat(factPrefix, sound, fact)}`,
    text: factPrefix,
  }));
  conv.ask(responses.general.nextFact);
  conv.ask(new BasicCard({
    title: fact,
    image: random(responses.cats.images),
    buttons: new Button({
      title: responses.general.linkOut,
      url: responses.cats.link,
    }),
  }));
  conv.ask(responses.general.suggestions.confirmation);
});
github actions-on-google / actions-on-google-nodejs / samples / ts / app / facts-about-google / functions / src / index.ts View on Github external
conv.ask(new Suggestions(otherCategory.suggestion))
    if (cats.length) {
      conv.ask(new Suggestions(responses.cats.suggestion))
    }
    return
  }
  const { factPrefix } = categoryResponse
  // conv.ask can be called multiple times to have the library construct a single response itself
  // the response will get sent at the end of the function
  // or if the function returns a promise, after the promise is resolved
  conv.ask(new SimpleResponse({
    speech: concat(factPrefix, fact),
    text: factPrefix,
  }))
  conv.ask(responses.general.nextFact)
  conv.ask(new BasicCard({
    title: fact,
    image: random(responses.content.images),
    buttons: new Button({
      title: responses.general.linkOut,
      url: responses.content.link,
    }),
  }))
  conv.ask(responses.general.suggestions.confirmation)
})
github actions-on-google / dialogflow-quotes-nodejs / functions / index.js View on Github external
.then((json) => {
      // Grab random quote data from JSON.
      const data = json.data[Math.floor(Math.random() * json.data.length)];
      const randomQuote =
        data.quotes[Math.floor(Math.random() * data.quotes.length)];
      conv.close(new SimpleResponse({
        text: json.info,
        speech: `${data.author}, from Google ` +
          `Developer Relations once said... ${randomQuote}`,
      }));
      if (conv.screen) {
        conv.close(new BasicCard({
          text: randomQuote,
          title: `${data.author} once said...`,
          image: new Image({
            url: BACKGROUND_IMAGE,
            alt: 'DevRel Quote',
          }),
        }));
      }
    });
});
github PinkyJie / google-actions-github-bot / functions / src / actions.ts View on Github external
function goToNextRepo(conv: CONV_TYPE) {
    const data = conv.data as UserData;
    const { repositories, period } = data;
    data.currentIndex += 1;
    const nextRepo = repositories[data.currentIndex];

    const greetingMsg =
        data.currentIndex === 0
            ? getRepoStartMessage(data.language, data.period)
            : getRandomMessage(PROMPTS.REPOSITORY_NEXT_ONE);

    const cardItem = new BasicCard({
        title: `${nextRepo.author} / ${nextRepo.name}`,
        subtitle: `Stars: ${nextRepo.stars}`,
        text: nextRepo.description,
        buttons: new Button({
            title: 'Read more on Github',
            url: nextRepo.href,
        }),
    });
    conv.ask(greetingMsg);

    // if next one is the last one
    if (data.currentIndex === repositories.length - 1) {
        conv.ask(
            wrapWithSpeak([
                getRepoParagraph(nextRepo, period),
                getRandomMessage(PROMPTS.REPOSITORY_LAST_ONE),
github actions-on-google / dialogflow-updates-nodejs / functions / index.js View on Github external
.then((querySnapshot) => {
      const tip = querySnapshot.docs[0];

      conv.ask(tip.get(FirestoreNames.TIP));
      conv.ask(new BasicCard({
        text: tip.get(FirestoreNames.TIP),
        buttons: new Button({
          title: 'Learn More!',
          url: tip.get(FirestoreNames.URL),
        }),
      }));

      if (!conv.user.storage[PUSH_NOTIFICATION_ASKED]) {
        conv.ask(new Suggestions('Alert me of new tips'));
        conv.user.storage[PUSH_NOTIFICATION_ASKED] = true;
      }
    });
});
github actions-on-google / actionssdk-updates-nodejs / functions / aog-webhook.js View on Github external
function renderTip(conv, tip) {
  if (!tip) {
    return conv.ask(MSG_NO_TIP);
  }
  conv.ask(
    tip.tip,
    new BasicCard({
      text: tip.tip,
      buttons: new Button({
        title: 'Learn More!',
        url: tip.url,
      }),
    }));
}
github JargonInc / jargon-sdk-nodejs / packages / actions-on-google / lib / common / responseFactory.ts View on Github external
async basicCard (options: JBasicCardOptions): Promise {
    const card: BasicCardOptions = await this._render(options, jBasicCardFields)
    return new BasicCard(card)
  }