How to use the actions-on-google.SimpleResponse 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 / actions-on-google-nodejs / samples / ts / app / facts-about-google / functions / src / index.ts View on Github external
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)
})
github actions-on-google / dialogflow-conversation-components-nodejs / actions-sdk / functions / index.js View on Github external
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.',
  }));
}
github actions-on-google / actionssdk-conversation-components-nodejs / functions / index.js View on Github external
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.',
  }));
}
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 actions-on-google / actions-on-google-nodejs / samples / js / app / facts-about-google / functions / index.js View on Github external
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)
})
github alvarowolfx / codelab-actions-on-google / 03-pizza-bot / functions / index.js View on Github external
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);
  }
}
github actions-on-google / dialogflow-conversation-components-nodejs / actions-sdk / functions / index.js View on Github external
function byeResponse(conv) {
  conv.close(new SimpleResponse({
    speech: 'Okay see you later',
    text: 'OK see you later!',
  }));
}
github AngularFirebase / 105-google-assistant-quick-start / functions / src / index.ts View on Github external
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',
        }),
    }));
});
github JargonInc / jargon-sdk-nodejs / packages / actions-on-google / lib / common / responseFactory.ts View on Github external
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)
  }
github actions-on-google / actionssdk-conversation-components-nodejs / functions / index.js View on Github external
function byeResponse(conv) {
  conv.close(new SimpleResponse({
    speech: 'Okay see you later',
    text: 'OK see you later!',
  }));
}