Created
March 1, 2017 16:39
-
-
Save leemeichin/4c292755a3fac2c5035c566eeb477523 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
return botBuilder(function (req, ctx) { | |
var date = chrono.parse(req.text) | |
var yearMonthDay = parseTheDate(date[0].start.date()) # make a YYYY-MM-DD string | |
var message = new SlackTemplate() | |
.channelMessage(true) | |
.replaceOriginal(true) | |
message.addConfirmation( | |
'Just double checking!', | |
"I'm going to look for awesome sauces for *" + date[0].text + '*, is that right?', | |
'Aww hell yeah, sauce me up!', | |
'Wait, what? Are you mad!?' | |
) | |
return request | |
.get({uri: 'https://awesomesauce.io/api/recommendation/' + yearMonthDay, json: true}) | |
.then(function (sauce) { | |
return message | |
.addAttachment(sauce.name) | |
.addText(sauce.recipe) | |
.addImage(sauce.image) | |
.get() | |
}) | |
.catch(function (err) { | |
return message.addText(err) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment