Skip to content

Commit f4817ef

Browse files
author
Ben Brown
committed
Clean import of latest Twilio IPM code
0 parents  commit f4817ef

38 files changed

+7252
-0
lines changed

.editorconfig

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 4
9+
10+
[*.json]
11+
indent_size = 2

.gitignore

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
node_modules/
2+
start.sh
3+
start_button.sh
4+
db/
5+
examples/db_slackbutton_bot/
6+
examples/db_slackbutton_incomingwebhook/
7+
examples/db_slackbutton_slashcommand/
8+
examples/db_team_bot/
9+
.DS_Store
10+
*/.DS_Store
11+
.env

.jscsrc

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"preset": "google",
3+
"disallowKeywords": ["with"],
4+
"disallowMultipleLineBreaks": null,
5+
"disallowMultipleVarDecl": null,
6+
"maximumLineLength": 120,
7+
"disallowSpacesInsideObjectBrackets": null,
8+
"requireCamelCaseOrUpperCaseIdentifiers": null,
9+
"requireCurlyBraces": null,
10+
"validateIndentation": 4,
11+
"requireSpaceAfterComma": true
12+
}

CONTRIBUTING.md

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Contributing to Botkit
2+
3+
The following is a set of guidelines for contributing to Botkit.
4+
These are just guidelines, not rules, use your best judgment and feel free to
5+
propose changes to this document in a pull request.
6+
7+
## Submitting Issues
8+
9+
* You can create an issue [here](https://github.com/howdyai/botkit/issues/new),
10+
but before doing that please read the notes below and include as many details as
11+
possible with your report. If you can, please include:
12+
* The version of Botkit you are using
13+
* The operating system you are using
14+
* If applicable, what you were doing when the issue arose and what you
15+
expected to happen
16+
* Other things that will help resolve your issue:
17+
* Screenshots and animated GIFs
18+
* Error output that appears in your terminal, dev tools or as an alert
19+
* Perform a [cursory search](https://github.com/howdyai/botkit/issues?utf8=✓&q=is%3Aissue+)
20+
to see if a similar issue has already been submitted
21+
22+
## Submitting Pull Requests
23+
24+
* Include screenshots and animated GIFs in your pull request whenever possible.
25+
* Follow the JavaScript coding style with details from `.jscsrc` and `.editorconfig` files and use necessary plugins for your text editor.
26+
* Write documentation in [Markdown](https://daringfireball.net/projects/markdown).
27+
* Please follow, [JSDoc](http://usejsdoc.org/) for proper documentation.
28+
* Use short, present tense commit messages. See [Commit Message Styleguide](#git-commit-messages).
29+
30+
## Styleguides
31+
32+
### General Code
33+
34+
* End files with a newline.
35+
* Place requires in the following order:
36+
* Built in Node Modules (such as `path`)
37+
* Local Modules (using relative paths)
38+
* Avoid platform-dependent code:
39+
* Use `path.join()` to concatenate filenames.
40+
* Using a plain `return` when returning explicitly at the end of a function.
41+
* Not `return null`, `return undefined`, `null`, or `undefined`
42+
43+
### Git Commit Messages
44+
45+
* Use the present tense ("Add feature" not "Added feature")
46+
* Use the imperative mood ("Move cursor to..." not "Moves cursor to...")
47+
* Limit the first line to 72 characters or less
48+
* Reference issues and pull requests liberally

LICENSE.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright XOXCO, Inc, http://xoxco.com, http://howdy.ai
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

changelog.md

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Change Log
2+
3+
## 0.2
4+
5+
Adds support for Twilio IP Messenging bots
6+
7+
Add example bot: twilio_ipm_bot.js
8+
9+
## 0.1.1
10+
11+
Fix issue with over-zealous try/catch in Slack_web_api.js
12+
13+
## 0.1.0
14+
15+
Adds support for Facebook Messenger bots.
16+
17+
Rename example bot: bot.js became slack_bot.js
18+
19+
Add example bot: facebook_bot.js
20+
21+
## 0.0.15
22+
23+
Changes conversation.ask to use the same pattern matching function as
24+
is used in `hears()`
25+
26+
Adds `controller.changeEars()` Developers can now globally change the
27+
way Botkit matches patterns.
28+
29+
30+
## 0.0.14
31+
32+
Add new middleware hooks. Developers can now change affect a message
33+
as it is received or sent, and can also change the way Botkit matches
34+
patterns in the `hears()` handler.
35+
36+
## 0.0.~
37+
38+
Next time I promise to start a change log at v0.0.0

examples/convo_bot.js

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2+
______ ______ ______ __ __ __ ______
3+
/\ == \ /\ __ \ /\__ _\ /\ \/ / /\ \ /\__ _\
4+
\ \ __< \ \ \/\ \ \/_/\ \/ \ \ _"-. \ \ \ \/_/\ \/
5+
\ \_____\ \ \_____\ \ \_\ \ \_\ \_\ \ \_\ \ \_\
6+
\/_____/ \/_____/ \/_/ \/_/\/_/ \/_/ \/_/
7+
8+
9+
This is a sample Slack bot built with Botkit.
10+
11+
This bot demonstrates a multi-stage conversation
12+
13+
# RUN THE BOT:
14+
15+
Get a Bot token from Slack:
16+
17+
-> http://my.slack.com/services/new/bot
18+
19+
Run your bot from the command line:
20+
21+
token=<MY TOKEN> node demo_bot.js
22+
23+
# USE THE BOT:
24+
25+
Find your bot inside Slack
26+
27+
Say: "pizzatime"
28+
29+
The bot will reply "What flavor of pizza do you want?"
30+
31+
Say what flavor you want.
32+
33+
The bot will reply "Awesome" "What size do you want?"
34+
35+
Say what size you want.
36+
37+
The bot will reply "Ok." "So where do you want it delivered?"
38+
39+
Say where you want it delivered.
40+
41+
The bot will reply "Ok! Goodbye."
42+
43+
...and will refrain from billing your card because this is just a demo :P
44+
45+
# EXTEND THE BOT:
46+
47+
Botkit has many features for building cool and useful bots!
48+
49+
Read all about it here:
50+
51+
-> http://howdy.ai/botkit
52+
53+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
54+
55+
var Botkit = require('../lib/Botkit.js');
56+
57+
if (!process.env.token) {
58+
console.log('Error: Specify token in environment');
59+
process.exit(1);
60+
}
61+
62+
var controller = Botkit.slackbot({
63+
debug: false
64+
});
65+
66+
controller.spawn({
67+
token: process.env.token
68+
}).startRTM(function(err) {
69+
if (err) {
70+
throw new Error(err);
71+
}
72+
});
73+
74+
controller.hears(['pizzatime'],['ambient'],function(bot,message) {
75+
bot.startConversation(message, askFlavor);
76+
});
77+
78+
askFlavor = function(response, convo) {
79+
convo.ask("What flavor of pizza do you want?", function(response, convo) {
80+
convo.say("Awesome.");
81+
askSize(response, convo);
82+
convo.next();
83+
});
84+
}
85+
askSize = function(response, convo) {
86+
convo.ask("What size do you want?", function(response, convo) {
87+
convo.say("Ok.")
88+
askWhereDeliver(response, convo);
89+
convo.next();
90+
});
91+
}
92+
askWhereDeliver = function(response, convo) {
93+
convo.ask("So where do you want it delivered?", function(response, convo) {
94+
convo.say("Ok! Goodbye.");
95+
convo.next();
96+
});
97+
}

examples/demo_bot.js

+127
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2+
______ ______ ______ __ __ __ ______
3+
/\ == \ /\ __ \ /\__ _\ /\ \/ / /\ \ /\__ _\
4+
\ \ __< \ \ \/\ \ \/_/\ \/ \ \ _"-. \ \ \ \/_/\ \/
5+
\ \_____\ \ \_____\ \ \_\ \ \_\ \_\ \ \_\ \ \_\
6+
\/_____/ \/_____/ \/_/ \/_/\/_/ \/_/ \/_/
7+
8+
9+
This is a sample Slack bot built with Botkit.
10+
11+
This bot demonstrates many of the core features of Botkit:
12+
13+
* Connect to Slack using the real time API
14+
* Receive messages based on "spoken" patterns
15+
* Send a message with attachments
16+
* Send a message via direct message (instead of in a public channel)
17+
18+
# RUN THE BOT:
19+
20+
Get a Bot token from Slack:
21+
22+
-> http://my.slack.com/services/new/bot
23+
24+
Run your bot from the command line:
25+
26+
token=<MY TOKEN> node demo_bot.js
27+
28+
# USE THE BOT:
29+
30+
Find your bot inside Slack to send it a direct message.
31+
32+
Say: "Hello"
33+
34+
The bot will reply "Hello!"
35+
36+
Say: "Attach"
37+
38+
The bot will send a message with a multi-field attachment.
39+
40+
Send: "dm"
41+
42+
The bot will reply with a direct message.
43+
44+
Make sure to invite your bot into other channels using /invite @<my bot>!
45+
46+
# EXTEND THE BOT:
47+
48+
Botkit has many features for building cool and useful bots!
49+
50+
Read all about it here:
51+
52+
-> http://howdy.ai/botkit
53+
54+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
55+
56+
var Botkit = require('../lib/Botkit.js');
57+
58+
59+
if (!process.env.token) {
60+
console.log('Error: Specify token in environment');
61+
process.exit(1);
62+
}
63+
64+
var controller = Botkit.slackbot({
65+
debug: false
66+
});
67+
68+
controller.spawn({
69+
token: process.env.token
70+
}).startRTM(function(err) {
71+
if (err) {
72+
throw new Error(err);
73+
}
74+
});
75+
76+
77+
controller.hears(['hello','hi'],['direct_message','direct_mention','mention'],function(bot,message) {
78+
bot.reply(message,"Hello.");
79+
});
80+
81+
controller.hears(['attach'],['direct_message','direct_mention'],function(bot,message) {
82+
83+
var attachments = [];
84+
var attachment = {
85+
title: 'This is an attachment',
86+
color: '#FFCC99',
87+
fields: [],
88+
};
89+
90+
attachment.fields.push({
91+
label: 'Field',
92+
value: 'A longish value',
93+
short: false,
94+
});
95+
96+
attachment.fields.push({
97+
label: 'Field',
98+
value: 'Value',
99+
short: true,
100+
});
101+
102+
attachment.fields.push({
103+
label: 'Field',
104+
value: 'Value',
105+
short: true,
106+
});
107+
108+
attachments.push(attachment);
109+
110+
bot.reply(message,{
111+
text: 'See below...',
112+
attachments: attachments,
113+
},function(err,resp) {
114+
console.log(err,resp);
115+
});
116+
});
117+
118+
controller.hears(['dm me'],['direct_message','direct_mention'],function(bot,message) {
119+
bot.startConversation(message,function(err,convo) {
120+
convo.say('Heard ya');
121+
});
122+
123+
bot.startPrivateConversation(message,function(err,dm) {
124+
dm.say('Private reply!');
125+
});
126+
127+
});

examples/incoming_webhooks.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* TODO bot that demonstrates sending incmoing webhooks to one specific team */

0 commit comments

Comments
 (0)