Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
//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
You can’t perform that action at this time.