This file contains hidden or 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
// In the main process. | |
var window = null; | |
app.on('ready', function() { | |
window = new BrowserWindow({width: 800, height: 600}); | |
window.loadURL('file://' + __dirname + '/index.html'); | |
window.webContents.on('did-finish-load', function() { | |
window.webContents.send('ping', 'whoooooooh!'); | |
}); | |
}); |
This file contains hidden or 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
// From https://github.com/howdyai/botkit#botsay | |
bot.say( | |
{ | |
text: 'my message text', | |
channel: 'C0H338YH4' // a valid slack channel, group, mpim, or im ID | |
} | |
); |
This file contains hidden or 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
bot.say( | |
{ | |
text: 'my message text', | |
channel: 'C0H338YH4' // a valid slack channel, group, mpim, or im ID | |
} | |
); |
This file contains hidden or 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
var values = convo.extractResponses(); | |
var value = values.key; | |
// alternatively, you can use | |
var value = convo.extractResponse('key'); |
This file contains hidden or 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
// From https://github.com/howdyai/botkit#conversation-control-functions | |
convo.say(message) | |
convo.sayFirst(message) // inject a mmessage into the first spot in the queue | |
convo.stop() // end the convo immediately and set convo.status to stopped | |
convo.repeat() // repeat the last question and continue to wait for a response | |
convo.silentRepeat() // simply wait for another response without saying anything | |
convo.next() // must be called at the end of each handler |
This file contains hidden or 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
// From https://github.com/howdyai/botkit#multi-stage-conversations | |
controller.hears(['pizzatime'], 'message_recieved', function(bot,message) { | |
askFlavor = function(response, convo) { | |
convo.ask('What flavor of pizza do you want?', function(response, convo) { | |
convo.say('Awesome.'); | |
askSize(response, convo); | |
convo.next(); | |
}); | |
} | |
askSize = function(response, convo) { |
This file contains hidden or 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
// From https://github.com/howdyai/botkit#using-conversationask-with-an-array-of-callbacks | |
controller.hears(['question me'], 'message_received', function(bot,message) { | |
// start a conversation to handle this response. | |
bot.startConversation(message,function(err,convo) { | |
convo.ask('Shall we proceed Say YES, NO or DONE to quit.',[ | |
{ | |
pattern: 'done', | |
callback: function(response,convo) { |
This file contains hidden or 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
// From https://github.com/howdyai/botkit#using-conversationask-with-a-callback | |
controller.hears(['question me'], 'message_received', function(bot,message) { | |
// start a conversation to handle this response. | |
bot.startConversation(message,function(err,convo) { | |
convo.ask('How are you?',function(response,convo) { | |
convo.say('Cool, you said: ' + response.text); | |
convo.next(); |
This file contains hidden or 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
bot.reply(message, { | |
attachment: { | |
'type':'template', | |
'payload':{ | |
'template_type':'generic', | |
'elements':[ | |
{ | |
'title':'Classic White T-Shirt', | |
'image_url':'http://petersapparel.parseapp.com/img/item100-thumb.png', | |
'subtitle':'Soft white cotton t-shirt is back in style', |
This file contains hidden or 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
var reply_with_attachments = { | |
'username': 'My bot' , | |
'text': 'This is a pre-text', | |
'attachments': [ | |
{ | |
'fallback': 'To be useful, I need you to invite me in a channel.', | |
'title': 'How can I help you?', | |
'text': 'To be useful, I need you to invite me in a channel ', | |
'color': '#7CD197' | |
} |