Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Version 0.4 of Botkit #433

Merged
merged 330 commits into from
Oct 7, 2016
Merged
Changes from 5 commits
Commits
Show all changes
330 commits
Select commit Hold shift + click to select a range
b4ba058
add custom handler for oauth events
Nov 24, 2015
e4d828a
Remove older files. Update gitignore
Nov 24, 2015
67ef2a0
Merge branch 'master' of github.com:xoxco/botkit
Nov 24, 2015
b868a4c
change terminology (multi-team bot to slack button)
Nov 24, 2015
0c460db
Merge branch 'master' of github.com:xoxco/botkit
Nov 24, 2015
0280c6f
adjust some stuff
Nov 24, 2015
2a23c7d
update appinfo
Nov 24, 2015
5b93986
fixes in syntax
Nov 24, 2015
99bffe1
add better callbacks etc
Nov 24, 2015
130de94
fix typuo
Nov 24, 2015
96a8fb0
update method of returning response
Nov 24, 2015
18446af
better testing of the public/private responses
Nov 24, 2015
b54ad1f
a fix
Nov 24, 2015
fc9faf9
add identifyTeam and identifyBot methods
Nov 24, 2015
f9ac1a3
add the very most basic elements of how to use the built in simple js…
Nov 24, 2015
c17ac79
add a note about the web api
Nov 24, 2015
a0af463
fix formatting of attachment field
Nov 24, 2015
57e8337
add more info about handling other types of events
Nov 24, 2015
699941d
add getting started section
Nov 24, 2015
468dba5
formatting
Nov 24, 2015
1e10b83
formatting
Nov 24, 2015
a47890a
add placeholders for examples
Nov 24, 2015
7d1634c
experiments into refactoring the bot into multipe sub-bots
Nov 27, 2015
17ba2f1
marvelously refactoring the objects into smaller more discrete and mo…
Nov 27, 2015
2feaa76
clean up examples
Nov 27, 2015
bf1c309
clean up some slash command stuff
Nov 27, 2015
7de33db
update docs
Nov 28, 2015
3e84f02
doc typo fix
Nov 28, 2015
b672c54
much better handling of oauth details via the built in storage stuff
Nov 28, 2015
c2672ca
Camel cased SlackBot.js file to accommodate case-sensitive file systems'
Dec 2, 2015
e0dc1d9
lots more docs
Dec 7, 2015
471947c
updated slackbutton bot example
Dec 8, 2015
9881658
stop if slack tokens not in env
Dec 8, 2015
c62275d
more delightful examples
Dec 8, 2015
8eb7b76
update examples fix doc formatting
Dec 8, 2015
e02f7c9
add links for docs
Dec 8, 2015
401b835
add links to examples
Dec 8, 2015
2a2e002
more link fixes
Dec 8, 2015
c44b0be
more docs
Dec 8, 2015
2ce3508
more docs
Dec 8, 2015
697215f
clean
Dec 8, 2015
dec26b0
Add descriptions of user/message events
Dec 10, 2015
5199506
update package.json
Dec 11, 2015
ca98160
update package for npm
Dec 11, 2015
dc8519a
add a sample bot at the root of the project that can be run by most p…
Dec 12, 2015
6536905
update ignore
Dec 12, 2015
c6f9b0c
updating some docs
Dec 12, 2015
d448dfa
remove old test files
Dec 12, 2015
ee11c09
move some files around for cleaner structure
Dec 13, 2015
2536a8f
more docs
Dec 13, 2015
aa0079f
capitalization
Dec 13, 2015
2bb43e1
add howdy mention in intro
Dec 13, 2015
728b8a4
try to normalize headers
Dec 13, 2015
689e1ce
header size
Dec 13, 2015
b4156ac
header size
Dec 13, 2015
4f29bd4
header
Dec 13, 2015
a060d43
header
Dec 13, 2015
a085449
header
Dec 13, 2015
1a5b0cf
header
Dec 13, 2015
3172ac7
header
Dec 13, 2015
1b66028
header
Dec 13, 2015
9f2fd52
doc cleanup
Dec 14, 2015
a337760
add license
Dec 14, 2015
f1fe1bd
remove more old test files
Dec 14, 2015
a1f8bad
doc formatting
Dec 14, 2015
033b5e7
doc formatting
Dec 14, 2015
3530ca8
update npm info
Dec 14, 2015
295caaa
change name of slack token field
Dec 14, 2015
5a0f3fc
update packag
Dec 14, 2015
9b95017
add beginning of pro features
May 13, 2016
17182af
refine pro bot
May 13, 2016
7b13bf2
Merge branch 'master' of github.com:howdyai/botkit into pro
May 19, 2016
caffb3c
updates
Jun 16, 2016
91d6081
merged upstream master into pro
Jun 21, 2016
5a75d0a
adding stats module
Jun 21, 2016
9aa595b
added md5 and built framework for recording stats
Jun 21, 2016
52d55ad
bot spitting stats at service
Jun 21, 2016
c08b90c
added stats for spawn
Jun 22, 2016
4441d3c
working calls to the command service!
Jun 22, 2016
3fa4a90
add additional events particular to remote triggers
Jun 22, 2016
5ebe64e
more stats stuff
Jun 28, 2016
b00430a
merge
Jun 28, 2016
ae51743
added more stats stuff
Jun 28, 2016
6e7cd31
passing meta correctly to stats
Jun 29, 2016
ca42109
upgraded trigger to not pass bot id
Jun 29, 2016
5bb8032
change url
Jul 1, 2016
a310389
Merge branch 'pro' of github.com:xoxco/botkit into pro
Jul 1, 2016
59a0eb3
adjust url of BKP server
Jul 1, 2016
7af79ab
sending more stats need to figure out why command_triggered gets call…
Jul 6, 2016
0683534
Merge branch 'pro' of github.com:xoxco/botkit into pro
Jul 6, 2016
d02e1d2
fixed double command triggered issue
Jul 7, 2016
7d9ed2e
sending more types of stats
Jul 7, 2016
9828c2f
sending more data with convo ended
Jul 11, 2016
e218739
allow date to be overridden
Jul 11, 2016
f021263
Merge branch 'pro' of github.com:xoxco/botkit into pro
Jul 11, 2016
a1de5dc
more
Jul 11, 2016
8491419
added status to remote command end stats call
Jul 12, 2016
3160feb
Merge branch 'pro' of github.com:xoxco/botkit into pro
Jul 12, 2016
67123c5
putting in some notes and cleaning up
Jul 12, 2016
7ffe2ec
update to support new events
Jul 12, 2016
34f5c6a
refactoring stuff in botkit
Jul 12, 2016
7709c6b
add ability to create before and after hooks for API-powered commands
Jul 20, 2016
cfc5850
add list variable example
Jul 20, 2016
ff3c960
works with updated service
Jul 20, 2016
8c0e578
add support for mustache in attachments
Jul 20, 2016
e7acacf
Merge branch 'BKP-152' of github.com:xoxco/botkit into BKP-152
Jul 20, 2016
515b28b
updates
Jul 21, 2016
85ab2d3
updates to the pro bot
Jul 21, 2016
1160cc5
updates
Jul 22, 2016
7bf0ab5
Merge branch 'BKP-152' into pro
Jul 26, 2016
9d5ce87
Merge branch 'pro' of github.com:xoxco/botkit into pro
Jul 26, 2016
48e5dcc
allow human middleware to specify a specific field to trigger
Jul 27, 2016
b497365
slice
Jul 27, 2016
a3b4315
add context object to convo
Jul 27, 2016
bb9e4c6
add getCommandByName
Jul 27, 2016
7e71d47
add cloneMessage to extract a single message and format it
Jul 27, 2016
f98f167
add mrkdnw
Aug 3, 2016
b35474b
add support for multiple lines option in pro
Aug 4, 2016
f379773
fully functioning multiline responses
Aug 4, 2016
8de6e2a
fix issue where question text was not being properly captured if it w…
Aug 4, 2016
4bca8fe
git pushMerge branch 'pro' of github.com:xoxco/botkit into pro
Aug 4, 2016
97855b1
fixed where command service is pointing
Aug 4, 2016
ee71329
run human hooks even for matched keywords
Aug 4, 2016
d56f602
clean up multiline input BEFORE running hooks
Aug 4, 2016
11e4e64
return empty string for a blank multiline message
Aug 4, 2016
0fe01ee
fix
Aug 4, 2016
794973e
fix combinemessages
Aug 4, 2016
0a9b9d1
add runRemote function
Aug 5, 2016
6219424
Merge branch 'pro' of github.com:xoxco/botkit into pro
Aug 5, 2016
c1a5259
improve the way BKP conditions are processed
Aug 9, 2016
9a26377
Merge branch 'pro' of github.com:xoxco/botkit into pro
Aug 9, 2016
b1b3964
re-enabled stats service
Aug 9, 2016
b5b4977
Merge branch 'pro' of github.com:xoxco/botkit into pro
Aug 9, 2016
90d3135
set default timeout to 15 minuets for remote script
Aug 9, 2016
15fe69d
Merge branch 'pro' of github.com:xoxco/botkit into pro
Aug 9, 2016
5914c7e
added extra if statement to determine if howdy toekn is attached to b…
Aug 11, 2016
7123a30
Merge branch 'pro' of github.com:xoxco/botkit into pro
Aug 11, 2016
5f56dea
added startTyping, stopTyping, replyWithTyping
luisfarzati Aug 29, 2016
e9afda1
updated documentation
luisfarzati Aug 29, 2016
272d578
replaced console.log with botkit.debug
luisfarzati Aug 29, 2016
51f8d88
adjust how startprivateconversation gets the DM id
Aug 30, 2016
211b307
fix reference to bot object
Aug 30, 2016
adb3776
wrapped json parsing in a try catch so things dont explode when they …
Sep 9, 2016
2d2ba6b
Merge branch 'pro' of github.com:xoxco/botkit into pro
Sep 9, 2016
0205489
merged most recent public master
Sep 12, 2016
22e3519
added studio stuff
Sep 13, 2016
fddecd1
got more of the stats back online
Sep 13, 2016
5ee018e
move pro stuff into a sub-objct
Sep 13, 2016
6c637b7
fixed stats issue
Sep 14, 2016
8339049
finished migrating stats stuff cohesively
Sep 14, 2016
d0fe793
merges sub object and pub merge
Sep 14, 2016
8821497
cleaned console
Sep 14, 2016
c0330cd
pointed at new instances
Sep 14, 2016
a59c99a
removed catch from api calls
Sep 14, 2016
b956e58
made stuff https
Sep 14, 2016
67e30d1
added configurable uris that default to botkit.ai
Sep 14, 2016
e07f48d
missed something
Sep 14, 2016
f240c4c
updated pro_stat too
Sep 14, 2016
15618e8
fix urls
Sep 14, 2016
1263bd1
changed where to find external uris
Sep 15, 2016
f0b9645
made compile script public
Sep 15, 2016
9b18514
fixed some stuff
Sep 15, 2016
5540363
Merge branch 'master' of github.com:howdyai/botkit into pubsubmerge
Sep 16, 2016
bef3d9e
removed console logg stuff
Sep 16, 2016
0e7c00e
Merge remote-tracking branch 'origin/master' into psmmerge
Sep 16, 2016
074fb52
cleaned out console.log madness in the stats api
Sep 16, 2016
583c8b7
added read me for studio. still needs work
Sep 19, 2016
4955bf9
Added narrative to middleware section
Sep 19, 2016
20d519d
more work on documentation
Sep 19, 2016
8052979
more work on documentation
Sep 19, 2016
08b96fd
Update readme-studio.md
ccruson Sep 19, 2016
0111269
blah
Sep 19, 2016
1e965fe
got obnoxious markdown list working
Sep 19, 2016
278b024
more documentation
Sep 19, 2016
1caaba5
more documentation
Sep 19, 2016
9319660
more documentation
Sep 19, 2016
a5bd5c7
more documentation
Sep 19, 2016
bb0cdd9
more documentation
Sep 19, 2016
ea3ebdb
more documentation
Sep 19, 2016
094a560
more documentation
Sep 19, 2016
675148f
more documentation
Sep 19, 2016
4bb7584
more documentation
Sep 19, 2016
75a65b6
more documentation
Sep 19, 2016
0e73df0
more documentation
Sep 19, 2016
88d8bfa
a more complete tutorial
Sep 20, 2016
a764247
add gotoThread as an alias for changeTopic
Sep 20, 2016
6fbcdd6
started makeing actually functional code so thought i should branch. …
Sep 20, 2016
b58c8f4
more docs
Sep 20, 2016
f01b265
almost complete tutorial stuff. syill needs an after and more thoroug…
Sep 20, 2016
6bec60f
updtes to readme
Sep 20, 2016
df01025
Merge branch 'clint_docs' of github.com:xoxco/botkit into bendocs
Sep 21, 2016
78e8ab8
updates to cover conversation variables
Sep 21, 2016
79963b2
final working bot
Sep 21, 2016
961e299
minor tweaks
Sep 21, 2016
ce5cc66
remove tutorial stuff
Sep 21, 2016
d6b6aa5
Merge branch 'clint_docs' into bendocs
Sep 21, 2016
93cb627
more complete studio documentation for studio
Sep 21, 2016
b4eb2e7
Lock down stats functionality and clean up some code
Sep 22, 2016
32961a8
slightly rejigger parameters to run, runTrigger, and get
Sep 22, 2016
b397f3f
Merge branch 'master' of github.com:xoxco/botkit into bendocs
Sep 22, 2016
d711fe2
add function definitions to studio readme
Sep 22, 2016
e5667c0
more studio docs
Sep 22, 2016
5df82f5
add more docs for studio features
Sep 22, 2016
23a5bb2
remove some unnecessary stuff
Sep 22, 2016
cb6cce5
more
Sep 22, 2016
2026cb2
remove old files
Sep 22, 2016
4b10ca3
fix linter errors
Sep 22, 2016
3903029
Added BotFramework connector
Stevenic Sep 22, 2016
105372f
fix url
Sep 22, 2016
b124b8c
add links
Sep 22, 2016
d2593a0
added readme for botframework
Stevenic Sep 23, 2016
a3dd875
more readme
Sep 23, 2016
9abfaec
many more pieces of documentation
Sep 23, 2016
373d426
more sdocs
Sep 23, 2016
d8c5d2f
docs
Sep 23, 2016
8eaa136
docs
Sep 23, 2016
55e99d5
docs
Sep 23, 2016
e3e2455
updated readme
Stevenic Sep 23, 2016
3c70f79
docs
Sep 23, 2016
bfa7f7f
add image
Sep 23, 2016
858d758
docs
Sep 23, 2016
19b95f0
docs
Sep 23, 2016
3ed153c
docs
Sep 23, 2016
9481ad5
docs
Sep 23, 2016
c362fa8
add testTrigger, returns resolves true a trigger is matched
Sep 24, 2016
54ccd40
remove unnecessary return
Sep 24, 2016
f3db298
add successful boolean to conversation object
Sep 25, 2016
1143fff
remove console
Sep 25, 2016
bdbeff0
add proper support for string vs regex pattern
Sep 25, 2016
b26a80a
verify user specified regexp
Sep 25, 2016
cb93482
Finished initial botframework readme.
Stevenic Sep 26, 2016
643f350
updated comments section of sample
Stevenic Sep 26, 2016
aa1bcae
Merge pull request #426 from Stevenic/master
Sep 26, 2016
e756ee5
App ID & Password should be passed to spawn() instead of controller c…
Stevenic Sep 27, 2016
bf0216d
preparing for public release
Oct 6, 2016
80f14be
updates in prep for launch
Oct 6, 2016
b9b9687
update readmes and changelog
Oct 7, 2016
9814619
add links
Oct 7, 2016
54b5dda
fix typos in docs
Oct 7, 2016
cc383a4
fix typos in docs
Oct 7, 2016
3175a99
Merge pull request #427 from Stevenic/talkabot
Oct 7, 2016
570c986
typo in docs
Oct 7, 2016
00abb2c
Merge branch 'talkabot' of github.com:howdyai/botkit into talkabot
Oct 7, 2016
238843b
slight change to wording of readme
Oct 7, 2016
06a72c7
Merge branch 'master' of github.com:howdyai/botkit into talkabot
Oct 7, 2016
7392136
update changelog
Oct 7, 2016
9d3f1b9
Merge branch 'facebook-sender-action-support' of https://github.com/l…
Oct 7, 2016
6543d9b
Merge branch 'luisfarzati-facebook-sender-action-support' into talkabot
Oct 7, 2016
0f72962
Merge branch 'master' of github.com:howdyai/botkit into talkabot
Oct 7, 2016
263b691
more changes merged
Oct 7, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 58 additions & 12 deletions lib/Facebook.js
Original file line number Diff line number Diff line change
@@ -23,11 +23,13 @@ function Facebookbot(configuration) {
botkit.startConversation(this, message, cb);
};



bot.send = function(message, cb) {

var facebook_message = {
recipient: {},
message: {}
message: message.sender_action ? undefined : {}
};

if (typeof(message.channel) == 'string' && message.channel.match(/\+\d+\(\d\d\d\)\d\d\d\-\d\d\d\d/)) {
@@ -36,20 +38,25 @@ function Facebookbot(configuration) {
facebook_message.recipient.id = message.channel;
}

if (message.text) {
facebook_message.message.text = message.text;
}
if (!message.sender_action) {
if (message.text) {
facebook_message.message.text = message.text;
}

if (message.attachment) {
facebook_message.message.attachment = message.attachment;
}
if (message.attachment) {
facebook_message.message.attachment = message.attachment;
}

if (message.sticker_id) {
facebook_message.message.sticker_id = message.sticker_id;
}
if (message.sticker_id) {
facebook_message.message.sticker_id = message.sticker_id;
}

if (message.quick_replies) {
facebook_message.message.quick_replies = message.quick_replies;
if (message.quick_replies) {
facebook_message.message.quick_replies = message.quick_replies;
}
}
else {
facebook_message.sender_action = message.sender_action;
}

if (message.sender_action) {
@@ -87,6 +94,45 @@ function Facebookbot(configuration) {
});
};

bot.startTyping = function (src, cb) {
var msg = {};
msg.channel = src.channel;
msg.sender_action = 'typing_on';
bot.say(msg, cb);
};

bot.stopTyping = function (src, cb) {
var msg = {};
msg.channel = src.channel;
msg.sender_action = 'typing_off';
bot.say(msg, cb);
};

bot.replyWithTyping = function(src, resp, cb) {
var text;

if (typeof(resp) == 'string') {
text = resp;
} else {
text = resp.text;
}

var avgWPM = 85
var avgCPM = avgWPM * 7

var typingLength = Math.min(Math.floor(text.length / (avgCPM / 60)) * 1000, 5000)

botkit.debug('typing takes', typingLength, 'ms')
bot.startTyping(src, function (err) {
if (err) console.log(err)
setTimeout(function() {
bot.reply(src, resp, cb);
}, typingLength);
});

};


bot.reply = function(src, resp, cb) {
var msg = {};

19 changes: 17 additions & 2 deletions readme-facebook.md
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ Table of Contents
* [Facebook-specific Events](#facebook-specific-events)
* [Working with Facebook Webhooks](#working-with-facebook-messenger)
* [Using Structured Messages and Postbacks](#using-structured-messages-and-postbacks)
* [Simulate typing](#simulate-typing)
* [Running Botkit with an Express server](#use-botkit-for-facebook-messenger-with-an-express-web-server)

## Getting Started
@@ -199,16 +200,30 @@ controller.on('facebook_postback', function(bot, message) {

Use a message with a sender_action field with "typing_on" to create a typing indicator. The typing indicator lasts 20 seconds, unless you send another message with "typing_off"

```
```javascript
var reply_message = {
sender_action: "typing_on"
}

bot.reply(message, reply_message)
```

## Simulate typing
To make it a bit more realistic, you can trigger a "user is typing" signal (shown in Messenger as a bubble with 3 animated dots) by using the following convenience methods.

```javascript
bot.startTyping(message, function () {
// do something here, the "is typing" animation is visible
});

bot.stopTyping(message, function () {
// do something here, the "is typing" animation is not visible
});

bot.replyWithTyping(message, 'Hello there, my friend!');
```

## Use BotKit for Facebook Messenger with an Express web server
Instead of the web server generated with setupWebserver(), it is possible to use a different web server to receive webhooks, as well as serving web pages.

Here is an example of [using an Express web server alongside BotKit for Facebook Messenger](https://github.com/mvaragnat/botkit-messenger-express-demo).