How to use the actions-on-google.ApiAiApp 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 rusinikita / voice-assistant-apps-start / events / DevFest2017 / webhook / index.js View on Github external
exports.devfest = functions.https.onRequest((request, response) => {
    console.log('Request headers: ' + JSON.stringify(request.headers))
    console.log('Request body: ' + JSON.stringify(request.body))

    // Construct actions app object, processing request
    const app = new App({ request, response })
    const actionMap = new Map()
    actionMap.set(ACTION_BOOKS_SHOW_INFO, bookSelected)
    actionMap.set(ACTION_BOOKS_SHOW_INFO_BY_NAME, bookSelectedByName)    
    actionMap.set(ACTION_AUTHOR_SHOW_INFO, authorInfoRequested)
    app.handleRequest(actionMap)

    function bookSelected(app) {
        const optionKey = app.getContextArgument('actions_intent_option', 'OPTION').value;
        
        app.setContext('books-last3-followup', 2, {
            book: BOOKS_DUMMY[optionKey].name,
            author: BOOKS_DUMMY[optionKey].author
        })
        console.log('Selected book' + JSON.stringify(optionKey) + ", " + JSON.stringify(app.getContexts()))
        // Compare the user's selections to each of the item's keys
        if (!optionKey) {
github fossasia / susi_gassistantbot / app.js View on Github external
app.post('/', function(request, response) {
    //console.log('headers: ' + JSON.stringify(request.headers));
    //console.log('body: ' + JSON.stringify(request.body));

    const assistant = new Assistant({
        request: request,
        response: response
    });

    function responseHandler(app) {
        // intent contains the name of the intent you defined in the Actions area of API.AI
        let intent = assistant.getIntent();
        switch (intent) {
            case SUSI_INTENT:
                var query = assistant.getRawInput(SUSI_INTENT);
                console.log(query);

                var options = {
                    method: 'GET',
                    url: 'http://api.susi.ai/susi/chat.json',
                    qs: {
github ImAdamTM / actions-ai-app / bin / lib / App.js View on Github external
constructor({ request, response }) {
    const app = new ApiAiApp({ request, response });

    // Shorthand link the `sessionId`
    app.sessionId = request.body.sessionId;
    // Shorthand link the `resolvedQuery`
    app.userInput = request.body.result.resolvedQuery;
    // Shorthand link the screen surface capability boolean
    app.hasScreen = app.hasSurfaceCapability(
      app.SurfaceCapabilities.SCREEN_OUTPUT);
    // Shorthand link the audio surface capability boolean
    app.hasAudio = app.hasSurfaceCapability(
      app.SurfaceCapabilities.AUDIO_OUTPUT);

    /**
     * Get an argument as string. This simply ensures the response is expressed
     * as a string instead of an array. It is only to be used when expecting
     * a string response instead of an array (or we only care about the first
github Ramkishorevit / GitInfo-Git-for-Google-Assistant / routes / index.js View on Github external
router.post('/assistant', function(req, res, next) {
  
   const app = new ApiAiApp({request: req, response: res});
   app.handleRequest(responseHandler);

});
github manekinekko / angular-bot / functions / index.js View on Github external
exports.assistant = functions.https.onRequest((request, response) => {
    const app = new App({ request, response });
    let actionMap = new Map();
    actionMap.set('_angular.upcoming_events', upcomingEvents);
    actionMap.set('_angular.upcoming_events:next', upcomingEventsNext);
    actionMap.set('_angular.search', search);
    actionMap.set('_angular.check_version', checkVersion);
    actionMap.set('_angular.core_team', contributors('Angular', 'The Angular Core Team'));
    actionMap.set('_angular.gde_team', contributors('GDE', 'The Angular GDE Team'));
    actionMap.set('actions.intent.OPTION', contributorsOption);
    actionMap.set('_angular.eg', eg);
    app.handleRequest(actionMap);
});
github hitherejoe / Fret / functions / index.js View on Github external
const fret = functions.https.onRequest((request, response) => {
  const app = new ApiAiApp({ request, response });
  i18n.setLocale(app.getUserLocale());
  app.handleRequest(actionMap);
});