Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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',
}),
}));
conv.ask(new SimpleResponse({
speech: 'This is the second simple response.',
text: 'This is the 2nd simple response.',
}));
}
}
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)
})
'phone surface in the simulator.');
return;
}
conv.ask('This is the first simple response for a basic card.');
conv.ask(new Suggestions(intentSuggestions));
// Create a basic card
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',
}),
}));
conv.ask(new SimpleResponse({
speech: 'This is the second simple response.',
text: 'This is the 2nd simple response.',
}));
}
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),
getRandomMessage(PROMPTS.GOODBYE),
])
);
} else {
return conv.ask(responses.general.suggestions.confirmation)
}
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({
ssml: `${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)
})
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,
}),
}));
}
app.intent('Get Latest Episode', async (conv) => {
const data = await scrapePage();
conv.close(new SimpleResponse({
text: `Last episode was ${data.title}`,
speech: `The last video was episode ${data.episode}. ${data.title}. It's description goes like this: ${data.description}`,
}));
conv.close(new BasicCard({
title: 'Watch the latest Episode',
image: new Image({
url: 'https://goo.gl/Fz9nrQ',
alt: 'AngularFirebase Logo'
}),
buttons: new Button({
title: 'Watch',
url: 'https://angularfirebase.com/lessons',
}),
}));
});
const buttons = [];
if (getMoment(session.startTimestamp).isAfter(Date.now())) {
buttons.push(new Button({
title: buttonText || 'Add to my schedule',
url: `https://events.google.com/io/schedule/?sid=${session.id}`,
}));
} else if (getMoment(session.startTimestamp).isBefore(Date.now()) &&
getMoment(session.endTimestamp).isAfter(Date.now()) &&
session.livestream) {
buttons.push(new Button({
title: 'Watch live',
url: session.youtubeUrl,
}));
} else if (session.livestream) {
buttons.push(new Button({
title: 'Watch the recording',
url: session.youtubeUrl,
}));
}
return {
'presentSession': {
'firstTime/repeat': {
'screen': [
{
'elements': [
prefixes,
[
new BasicCard({
title: session.title,
subtitle: `${getMoment(session.startTimestamp).format('ddd MMM D h:mmA')} / ${session.roomName}`,
const restaurantInfo = conv => {
conv.ask(
"We are located on 944 Market st, San Francisco. You can reach us at (123) 456 6524. \n We are open from Monday to Saturday, from 9 am to 5 pm. \n"
);
conv.ask(
new BasicCard({
text: `We are locate at 📍__944 Market st__, San Francisco. \nOur phone number is: 📱 (123) 345 6789`,
subtitle: "A little bit about our restaurant",
title: "Restaurant information",
buttons: new Button({
title: "Visit our website!",
url: "https://www.google.com/"
}),
image: new Image({
url:
"https://cdn-images-1.medium.com/max/1600/1*CmLh1VWDcPyzAmQLA8pLJg.png",
alt: "Image alternate text"
}),
display: "CROPPED"
})
);
conv.ask(new Suggestions(listOfOptions));
};