Skip to content

Instantly share code, notes, and snippets.

@adamjuhasz
Last active March 31, 2017 18:58
Show Gist options
  • Save adamjuhasz/30912f6f1a457d1dc758bb4d2297c844 to your computer and use it in GitHub Desktop.
Save adamjuhasz/30912f6f1a457d1dc758bb4d2297c844 to your computer and use it in GitHub Desktop.
Serverless example for the alana bot framework
addGreeting((user, response) => {
response.sendText('πŸ“’ πŸ€–')
})
newScript()
.dialog((session, response) => {
if (session.message.type === 'text') {
switch (session.message.text) {
// solved better with intents, https://www.alana.tech/concepts/intents.html
case 'hello':
case 'hi':
case 'hey':
return response.sendText('hello world');
case 'echo':
response.sendText(session.message.text);
response.sendText(session.message.text);
response.sendText(session.message.text);
return;
default:
return response.sendText(session.message.text);
}
}
});
test('hello world', function() {
return newTest()
.expectText('πŸ“’ πŸ€–')
.sendText('hello')
.expectText('hello world')
.run();
})
test('echo', function() {
return newTest()
.expectText('πŸ“’ πŸ€–')
.sendText('echo')
.expectText('echo')
.expectText('echo')
.expectText('echo')
.run();
})
test('random', function() {
return newTest()
.expectText('πŸ“’ πŸ€–')
.sendText('random text')
.expectText('random text')
.run();
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment