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
addGreeting(function(user, response){ | |
console.log('greeting run'); | |
response | |
.sendText('Welcome to spacebot') | |
.sendText('I love space!'); | |
response.startScript('profile'); | |
}); |
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
newScript('profile') | |
.dialog('nickname', (session, response) => { | |
return Promise.delay(500) | |
.then(() => response.sendText('What should I call you?')); | |
}) | |
.expect | |
.text((session, response) => { | |
session.user.state.name = session.message.text; | |
}) | |
.catch((session, response) => { |
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
newScript() | |
.dialog('start', function(session, response) { | |
response | |
.createButtons() | |
.text(`Hi ${session.user.state.name}, what do you want to do?`) | |
.addButton('postback', 'Photo of the day', 'POTD') | |
.addButton('postback', 'Space trivia', 'TRIVIA') | |
.send(); | |
}) | |
.expect |
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
newScript('POTD') | |
.dialog((session, response) => { | |
return request({ | |
uri: 'https://api.nasa.gov/planetary/apod', | |
method: 'GET', | |
qs: { | |
api_key: 'DEMO_KEY' | |
}, | |
json: true, | |
}) |
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
const questions = [{ | |
question: 'What type of galaxy is the most common in the universe?', | |
correct: 'Elliptical', | |
wrong: ['Spiral','Irregular'] | |
}, | |
{ | |
question: 'What is the coldest place in the universe?', | |
correct: 'Boomerang Nebula', | |
wrong: ['Center of the Milky Way','Moon\'s surface', 'Pluto\'s surface'], | |
}, |
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
addGreeting(function(user, response){ | |
console.log('greeting run'); | |
response | |
.sendText('Welcome to spacebot') | |
.sendText('I love space!'); | |
// notice how you can chain responses | |
}); |
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
newScript('profile') | |
.dialog((session, response) => { | |
response.sendText('What should I call you?')); | |
}) | |
.expect | |
.text((session, response) => { | |
session.user.state.name = session.message.text; | |
response.sendText('Hi ' + session.message.text); | |
}) |
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
newScript() | |
.dialog(function(session, response) { | |
response | |
.createButtons() | |
.text(`Hi ${session.user.state.name}, what do you want to do?`) | |
.addButton('postback', 'Photo of the day', 'POTD') | |
.addButton('postback', 'Space trivia', 'TRIVIA') | |
.send(); | |
}) | |
.expect |
OlderNewer