Skip to content

Instantly share code, notes, and snippets.

@leemeichin
Created March 1, 2017 16:39
Show Gist options
  • Save leemeichin/4c292755a3fac2c5035c566eeb477523 to your computer and use it in GitHub Desktop.
Save leemeichin/4c292755a3fac2c5035c566eeb477523 to your computer and use it in GitHub Desktop.
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