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
/** | |
* Selects suggestion chips | |
* @param {obj} conv, the conversation object. | |
* @return [] array of suggestion chips. | |
*/ | |
function selectSuggestionChips(conv) { | |
let suggestions = []; | |
for (let i=0; i < conv.data.intentFulfilled.length; i++) { | |
if (conv.data.intentFulfilled[i] === 0) { | |
suggestions.push(responses.SUGGESTIONS['MENU')[i]); |
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
/** | |
* Records which options the user has complete | |
* @param {obj} conv, the conversation object. | |
* @param num conv, the conversation object. | |
* @return {null} none. | |
*/ | |
function recordsIntentFulfillment(conv, intentName) { | |
const convertIntentValue = { | |
'gdg': 0, | |
'next event': 1, |
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 | |
app.intent('solution', (conv) => { | |
let message = choose(responses.solutions)[0]; | |
// if the user doesn't have a screen, give them only the | |
// message plus info about getting url via a screen | |
if (!conv.screen){ | |
conv.ask(message['text'] + ' To see the url switch ' + | |
'over to a screen'); | |
return; | |
} |
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 | |
app.intent('challengeHint', (conv) => { | |
// get the data that is saved on the user | |
let challengesName = conv.user.storage.currentChallenge; | |
let level = conv.user.storage.currentLevel; | |
// if they don't have a challengeName, then we tell them a | |
// message | |
if (!challengeName){ | |
conv.ask(new SimpleResponse({ | |
speech: noChallengeresponse['speech'}, |
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
// responses.js | |
beginnerChallenges = [ | |
{ | |
'problemName': 'matching_parens', | |
'text': 'Write the function …', | |
'speech': '<speak> Write the function…', | |
'hintText': 'If you remove all the letters…', | |
'hintSpeech': '<speak> If you remove all the letters…', | |
}, | |
... |
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 | |
app.intent('askProblem', (conv, params) => { | |
let level = params.level; | |
// if level is random or not defined, I choose a random level | |
if (level === 'random' || !level) { | |
let keys = Object.keys(response.challenges); | |
level = choose(keys); | |
} | |
let questions = responses.challenge[level]; | |
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
//responses.js | |
export.greeting = { | |
'new': [ | |
{'text': 'Hello, my name is Jessica…', | |
'speech': '<speak> Hello, <break time=".35 /> my name…', | |
}, | |
], | |
'returning': [ | |
{'text': 'Hi again! I'm excited to help…', | |
'speech': '<speak> Hi again! I'm excited to help…', |
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 |