Custom greeting Google Assistant app with Dialogflow and Actions on Google

Let's have a look into how you can create custom Welcome messages for your Google Assistant with Dialogflow and Actions on Google.

First open your Dialogflow Console. Create a new Intent with the following settings:

Intent name: [bot-first-greeting]
Events: Choose Google Assistant Welcome
Training Phrases: Empty
Fulfillment: Enable Webhook call for intent

Click Save.

For the code I am using Google Cloud functions. Please see also my previous post.

Your Google Cloud Function could like this:

'use strict';

const {
  dialogflow
} = require('actions-on-google'); //npm actions-on-google 2.1.1

const welcomeHandler = (conv) => {

  var today = new Date(); 
  var curHr = today.getHours(); 
  var greet = ""; 

  if( curHr < 12 ) {
    greet = "Good morning!"; 
  } else if (curHr < 18) {
    greet = "Good afternoon!";
  } else {
    greet = "Good evening!";
  }

  conv.ask(greet);
};

const app = dialogflow();

app.intent('[bot-first-greeting]', welcomeHandler);

exports.index = app;

Click the Fulfillment menu item, and make sure the URL points to your Google Cloud function.

Assuming that you linked the Actions on Google already in the Integrations tab; move back to your Actions on Google simulator, and refresh your app.

When you start your Google Assistant app, it will greet you, based on the time of the day.

Obviously, this is a simple example, but this can become more interesting, when loading profile information or previous contexts before starting your app.

Is there a way to add a timeout to the listeners so that it only executes after a time period as passed?

Posted on in Ext JS Ext JS 5 & 6 Questions

Yes, what you are looking for is Ext.defer(), you can create a time out before certain logics gets executed.
http://docs.sencha.com/extjs/5.0/5.0.1-apidocs/#!/api/Ext-method-defer

If you also want to block certain events from executing directly after each other, you could possibly use a callback, a boolean check or just a check with time stamps. I made an example of that:
https://fiddle.sencha.com/#fiddle/f2h