How to use the actions-on-google.actionssdk 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.

github actions-on-google / dialogflow-conversation-components-nodejs / actions-sdk / functions / index.js View on Github external
[SELECTION_KEY_GOOGLE_HOME]: 'You selected the Google Home!',
  [SELECTION_KEY_GOOGLE_PIXEL]: 'You selected the Google Home!',
  [SELECTION_KEY_GOOGLE_PIXEL]: 'You selected the Google Pixel!',
  [SELECTION_KEY_GOOGLE_ALLO]: 'You selected Google Allo!',
};

const intentSuggestions = [
  'Basic Card',
  'Browse Carousel',
  'Carousel',
  'List',
  'Media',
  'Suggestions',
];

const app = actionssdk({debug: true});

app.middleware((conv) => {
  conv.hasScreen =
    conv.surface.capabilities.has('actions.capability.SCREEN_OUTPUT');
  conv.hasAudioPlayback =
    conv.surface.capabilities.has('actions.capability.AUDIO_OUTPUT');
});

// Welcome
app.intent('actions.intent.MAIN', (conv) => {
  conv.ask(new SimpleResponse({
    speech: 'Hi there!',
    text: 'Hello there!',
  }));
  conv.ask(new SimpleResponse({
    speech: 'I can show you basic cards, lists and carousels ' +
github actions-on-google / actionssdk-say-number-nodejs / functions / index.js View on Github external
// You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

const functions = require('firebase-functions');
const {actionssdk} = require('actions-on-google');

const app = actionssdk({debug: true});

app.intent('actions.intent.MAIN', (conv) => {
  conv.ask('<speak>Hi! <break time="1"/> I can read out an ordinal like ' +
    '<say-as interpret-as="ordinal">123</say-as>. Say a number.</speak>');
});

app.intent('raw.input', (conv, input) => {
  const number = conv.arguments.get('ordinal');
  conv.ask(`<speak>You said, <say-as interpret-as="ordinal">${number}</say-as></speak>`);
});

//Handles in-dialog conversation
app.intent('actions.intent.TEXT', (conv, input) => {
  if (input === 'bye') {
    return conv.close('Goodbye!');
  }
github googlearchive / actionssdk-eliza-nodejs / functions / index.js View on Github external
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

const {actionssdk} = require('actions-on-google');
const Eliza = require('elizabot');
const functions = require('firebase-functions');

const app = actionssdk({debug: true});

/**
 * Handles the MAIN intent coming from Assistant, when the user first engages
 * with the app, expecting for an initial greeting from Eliza.
 */
app.intent('actions.intent.MAIN', (conv) => {
  const eliza = new Eliza();
  conv.data.elizaInstance = eliza;
  conv.ask(eliza.getInitial());
});

/**
 * Handles the intent where the user invokes with a query to be
 * handled by Eliza.
 *
 * This intent is triggered when the user invokes the Raw Input
github samtecspg / articulate / api / lib / channels / google-home / reply.js View on Github external
module.exports = async function ({ event, response }) {

  const app = actionssdk();

  app.intent('actions.intent.MAIN', conv => {
    conv.ask(response.textResponse);
  });

  app.intent('actions.intent.TEXT', (conv, input) => {
    if (response.closeGoogleActions){
      conv.close(response.textResponse);
    }
    else {
      conv.ask(response.textResponse);
    }
  });

  return await app.handler(event, {});
}
github actions-on-google / actionssdk-conversation-components-nodejs / functions / index.js View on Github external
[SELECTION_KEY_GOOGLE_PAY]: 'You selected Google Pay!',
  [SELECTION_KEY_GOOGLE_PIXEL]: 'You selected Google Pixel!',
  [SELECTION_KEY_GOOGLE_HOME]: 'You selected Google Home!',
};

const intentSuggestions = [
  'Basic Card',
  'Browse Carousel',
  'Carousel',
  'List',
  'Media',
  'Suggestions',
  'Table',
];

const app = actionssdk({debug: true});

app.middleware((conv) => {
  conv.hasScreen =
    conv.surface.capabilities.has('actions.capability.SCREEN_OUTPUT');
  conv.hasAudioPlayback =
    conv.surface.capabilities.has('actions.capability.AUDIO_OUTPUT');
  conv.hasWebBrowser =
    conv.surface.capabilities.has('actions.capability.WEB_BROWSER');

  if (!conv.hasScreen && (conv.rawInput !== 'media response' || 'media status')) {
    conv.ask(`Hi there! Sorry, I'm afraid you'll have to switch to a ` +
      `screen device or select the phone surface in the simulator.`);
    return;
  }
});
github actions-on-google / actionssdk-updates-nodejs / functions / aog-webhook.js View on Github external
actionssdk,
  BasicCard,
  Button,
  RegisterUpdate,
  Suggestions,
  UpdatePermission,
} = require('actions-on-google');

const {
  getRandomTip,
  getLatestTip,
  getCategories,
  registerUserForUpdate,
} = require('./tip-service');

const app = actionssdk({debug: true});

/** Query pattern parameters */
const Parameters = {
  CATEGORY: 'category',
  UPDATE_INTENT: 'UPDATE_INTENT',
};

/** App strings */
const RANDOM_CATEGORY = 'random';
const RECENT_TIP = 'most recent';
const CATEGORIES = 'categories';
const DAILY_NOTIFICATION_SUGGESTION = 'Send daily updates';
const ASK_CATEGORY_FLAG = 'ask_category';
const PUSH_NOTIFICATION_SUGGESTION = 'Alert me of new tips';
const DAILY_NOTIFICATION_ASKED = 'daily_notification_asked';
const PUSH_NOTIFICATION_ASKED = 'push_notification_asked';
github yoichiro / generator-action / templates / actions-sdk.javascript.index.js View on Github external
const functions = require('firebase-functions');
const { actionssdk } = require('actions-on-google');

const app = actionssdk({
  debug: true
});

app.intent('actions.intent.MAIN', conv => {
  conv.close('Hello, world!');
});

exports.fulfillment = functions.https.onRequest(app);
github yoichiro / generator-action / templates / actions-sdk.typescript.index.ts View on Github external
import * as functions from 'firebase-functions';
import { actionssdk } from 'actions-on-google';

const app = actionssdk({
  debug: true
});

app.intent('actions.intent.MAIN', (conv): void => {
  conv.close('Hello, world!');
});

exports.fulfillment = functions.https.onRequest(app);
github AlexLakatos / computer-puns / google-action / netlify-functions / dev-pun.js View on Github external
exports.handler = function(event, context, callback) {

const {actionssdk} = require('actions-on-google');
const app = actionssdk({debug: true});

app.intent('actions.intent.MAIN', (conv) => {
  conv.ask('Hi!');
});



  callback(null, {
    statusCode: 200,
    body: app
  });
}