Skip to content

Instantly share code, notes, and snippets.

@chatasweetie
Created July 2, 2018 22:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chatasweetie/f9811054d9156910031cf9ea7b2ea1fa to your computer and use it in GitHub Desktop.
Save chatasweetie/f9811054d9156910031cf9ea7b2ea1fa to your computer and use it in GitHub Desktop.
//index.js
const responses = require('./responses');
app.intent('Default Welcome Intent', (conv) => {
// the user has used this Action prior, let's give them the
// returning greeting
if (conv.user.last.seen) {
// the choose function is something that I wrote to return
// a list of random elements
let message = choose(responses.greeting['returning'])[0];
// creates an instance of a Simple Response and passes our
// message information
conv.ask(new SimpleResponse({
speech: message['speech'],
text: message['text'],
}));
// provides suggestion chips for visual displays
conv.ask(new Suggestions(
choose(responses.commmonSuggestions, 2)
));
// a new user, woot! Let's give them the new user greeting
} else {
let message = responses.greeting['new'][0];
// creates an instance of a Simple Response and passes our
// message information
conv.ask(new SimpleResponse({
speech: message['speech'],
text: message['text'],
}));
// provides suggestion chips for visual displays
conv.ask(new Suggestions(
choose(responses.commmonSuggestions, 2)
));
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment