Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
app.intent('Azure Facts Intent', async (conv, {facts}) => {
let factToQuery = facts.toString();
let fact = await buildFactResponse(factToQuery);
const AZURE_TEXT_SHORT = `Sure, here's a fact about ${fact.title}`;
conv.ask(new SimpleResponse({
speech: fact.response,
if (conv.hasScreen) {
conv.ask(new BasicCard({
text: fact.response,
title: fact.title,
image: new Image({
url: `${IMAGE_BUCKET}/${fact.image}`,
alt: fact.title,
display: 'WHITE',
conv.ask(new Suggestions([SUGGESTION_1, SUGGESTION_2, SUGGESTION_3]));
function buildFactResponse(factToQuery) {
return new Promise((resolve, reject) => {
if (factToQuery.toString().trim() === 'random') {
factToQuery = selectRandomFact();
const query = datastore
.filter('__key__', '=', datastore.key(['AzureFact', factToQuery]));
.then(results => {
.catch(err => {
console.log(`Error: ${err}`);
reject(`Sorry, I don't know the fact, ${factToQuery}.`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.