Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (cats.length) {
response.push(responses.transitions.content.alsoCats)
}
response.push(responses.general.wantWhat)
conv.ask(concat(...response))
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)
})
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.',
}));
}
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.',
}));
}
.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',
}),
}));
}
});
});
app.intent('tell_cat_fact', conv => {
const { cats } = conv.data
const fact = randomPop(cats)
if (!fact) {
conv.contexts.delete(AppContexts.FACT)
conv.contexts.delete(AppContexts.CATS)
conv.ask(responses.transitions.cats.heardItAll)
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 welcomeHandler(assistant) {
console.log(assistant.user);
let welcoming = 'Welcome to Mamma Mia Pizza!';
if (assistant.user.name.display) {
welcoming = `Welcome to Mamma Mia Pizza, is awesome to have you back ${assistant.user.name.display}!`;
}
welcoming += ' What pizza do you want today ?';
const msg = new SimpleResponse({
speech: welcoming + 'Peperoni and Marguerita are pretty popular!',
text: welcoming
});
if (isScreenAvailable(assistant)) {
assistant.ask(msg);
assistant.ask(new Suggestions(['margherita', 'peperoni', 'marinara']));
} else {
assistant.ask(msg);
}
}
function byeResponse(conv) {
conv.close(new SimpleResponse({
speech: 'Okay see you later',
text: 'OK see you later!',
}));
}
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',
}),
}));
});
async simple (options: JSimpleResponseOptions | RenderItem): Promise {
if (isRI(options)) {
return new SimpleResponse(await this._rm.render(options))
}
const sro: SimpleResponseOptions = await this._render(options, jSimpleResponseFields)
return new SimpleResponse(sro)
}
function byeResponse(conv) {
conv.close(new SimpleResponse({
speech: 'Okay see you later',
text: 'OK see you later!',
}));
}