Created
July 2, 2018 22:53
-
-
Save chatasweetie/f9811054d9156910031cf9ea7b2ea1fa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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