Skip to content

Instantly share code, notes, and snippets.

View chatasweetie's full-sized avatar

Jessica Dene Earley-Cha chatasweetie

View GitHub Profile
/**
* 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]);
@chatasweetie
chatasweetie / recordsIntentFulfillment.js
Created July 22, 2019 20:28
recordsIntentFulfillment
/**
* 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,
//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;
}
// 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'},
// 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…',
},
...
// 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];
//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…',
//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