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

Commit

Permalink
Merge pull request #2 from howdyai/master
Browse files Browse the repository at this point in the history
update twilio / messenger
  • Loading branch information
mvaragnat committed Jun 2, 2016
2 parents 67fb05c + 30f21f0 commit 9f54942
Show file tree
Hide file tree
Showing 30 changed files with 3,653 additions and 902 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ possible with your report. If you can, please include:
* Include screenshots and animated GIFs in your pull request whenever possible.
* Follow the JavaScript coding style with details from `.jscsrc` and `.editorconfig` files and use necessary plugins for your text editor.
* Write documentation in [Markdown](https://daringfireball.net/projects/markdown).
* Please follow, [JSDoc](http://usejsdoc.org/) for proper documentation.
* Use short, present tense commit messages. See [Commit Message Styleguide](#git-commit-messages).

## Styleguides
Expand Down
62 changes: 62 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Change Log

## 0.2

Adds support for Twilio IP Messenging bots

Add example bot: twilio_ipm_bot.js

## 0.1.2

*Slack changes:*

Adds authentication of incoming Slack webhooks if token specified. [More info](readme_slack.md#securing-outgoing-webhooks-and-slash-commands) [Thanks to [@sgud](https://github.com/howdyai/botkit/pull/167)]

Improves support for direct_mentions of bots in Slack (Merged [PR #189](https://github.com/howdyai/botkit/pull/189))

Make the oauth identity available to the user of the OAuth endpoint via `req.identity` (Merged [PR #174](https://github.com/howdyai/botkit/pull/174))

Fix issue where single team apps had a hard time receiving slash command events without funky workaround. (closes [Issue #108](https://github.com/howdyai/botkit/issues/108))

Add [team_slashcommand.js](/examples/team_slashcommand.js) and [team_outgoingwebhook.js](/examples/team_outgoingwebhook.js) to the examples folder.



*Facebook changes:*

The `attachment` field may now be used by Facebook bots within a conversation for both convo.say and convo.ask. In addition, postback messages can now be received as the answer to a convo.ask in addition to triggering their own facebook_postback event. [Thanks to [@crummy](https://github.com/howdyai/botkit/pull/220) and [@tkornblit](https://github.com/howdyai/botkit/pull/208)]

Include attachments field in incoming Facebook messages (Merged [PR #231](https://github.com/howdyai/botkit/pull/231))

Adds built-in support for opening a localtunnel.me tunnel to expose Facebook webhook endpoint while developing locally. (Merged [PR #234](https://github.com/howdyai/botkit/pull/234))

## 0.1.1

Fix issue with over-zealous try/catch in Slack_web_api.js

## 0.1.0

Adds support for Facebook Messenger bots.

Rename example bot: bot.js became slack_bot.js

Add example bot: facebook_bot.js

## 0.0.15

Changes conversation.ask to use the same pattern matching function as
is used in `hears()`

Adds `controller.changeEars()` Developers can now globally change the
way Botkit matches patterns.


## 0.0.14

Add new middleware hooks. Developers can now change affect a message
as it is received or sent, and can also change the way Botkit matches
patterns in the `hears()` handler.

## 0.0.~

Next time I promise to start a change log at v0.0.0
16 changes: 8 additions & 8 deletions examples/convo_bot.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
______ ______ ______ __ __ __ ______
______ ______ ______ __ __ __ ______
/\ == \ /\ __ \ /\__ _\ /\ \/ / /\ \ /\__ _\
\ \ __< \ \ \/\ \ \/_/\ \/ \ \ _"-. \ \ \ \/_/\ \/
\ \_____\ \ \_____\ \ \_\ \ \_\ \_\ \ \_\ \ \_\
\/_____/ \/_____/ \/_/ \/_/\/_/ \/_/ \/_/
\ \_____\ \ \_____\ \ \_\ \ \_\ \_\ \ \_\ \ \_\
\/_____/ \/_____/ \/_/ \/_/\/_/ \/_/ \/_/
This is a sample Slack bot built with Botkit.
Expand Down Expand Up @@ -38,13 +38,13 @@ This bot demonstrates a multi-stage conversation
Say where you want it delivered.
The bot will reply "Ok! Good by."
The bot will reply "Ok! Goodbye."
...and will refrain from billing your card because this is just a demo :P
# EXTEND THE BOT:
Botkit is has many features for building cool and useful bots!
Botkit has many features for building cool and useful bots!
Read all about it here:
Expand Down Expand Up @@ -91,7 +91,7 @@ askSize = function(response, convo) {
}
askWhereDeliver = function(response, convo) {
convo.ask("So where do you want it delivered?", function(response, convo) {
convo.say("Ok! Good by.");
convo.say("Ok! Goodbye.");
convo.next();
});
}
}
10 changes: 5 additions & 5 deletions examples/demo_bot.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
______ ______ ______ __ __ __ ______
______ ______ ______ __ __ __ ______
/\ == \ /\ __ \ /\__ _\ /\ \/ / /\ \ /\__ _\
\ \ __< \ \ \/\ \ \/_/\ \/ \ \ _"-. \ \ \ \/_/\ \/
\ \_____\ \ \_____\ \ \_\ \ \_\ \_\ \ \_\ \ \_\
\/_____/ \/_____/ \/_/ \/_/\/_/ \/_/ \/_/
\ \_____\ \ \_____\ \ \_\ \ \_\ \_\ \ \_\ \ \_\
\/_____/ \/_____/ \/_/ \/_/\/_/ \/_/ \/_/
This is a sample Slack bot built with Botkit.
Expand Down Expand Up @@ -37,15 +37,15 @@ This bot demonstrates many of the core features of Botkit:
The bot will send a message with a multi-field attachment.
Send: "dm"
Send: "dm me"
The bot will reply with a direct message.
Make sure to invite your bot into other channels using /invite @<my bot>!
# EXTEND THE BOT:
Botkit is has many features for building cool and useful bots!
Botkit has many features for building cool and useful bots!
Read all about it here:
Expand Down
65 changes: 54 additions & 11 deletions bot.js → examples/middleware_example.js
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
______ ______ ______ __ __ __ ______
______ ______ ______ __ __ __ ______
/\ == \ /\ __ \ /\__ _\ /\ \/ / /\ \ /\__ _\
\ \ __< \ \ \/\ \ \/_/\ \/ \ \ _"-. \ \ \ \/_/\ \/
\ \_____\ \ \_____\ \ \_\ \ \_\ \_\ \ \_\ \ \_\
\/_____/ \/_____/ \/_/ \/_/\/_/ \/_/ \/_/
\ \_____\ \ \_____\ \ \_\ \ \_\ \_\ \ \_\ \ \_\
\/_____/ \/_____/ \/_/ \/_/\/_/ \/_/ \/_/
This is a sample Slack bot built with Botkit.
Expand Down Expand Up @@ -55,7 +55,7 @@ This bot demonstrates many of the core features of Botkit:
# EXTEND THE BOT:
Botkit is has many features for building cool and useful bots!
Botkit has many features for building cool and useful bots!
Read all about it here:
Expand All @@ -69,7 +69,7 @@ if (!process.env.token) {
process.exit(1);
}

var Botkit = require('./lib/Botkit.js');
var Botkit = require('../lib/Botkit.js');
var os = require('os');

var controller = Botkit.slackbot({
Expand All @@ -81,7 +81,49 @@ var bot = controller.spawn({
}).startRTM();


controller.hears(['hello','hi'],'direct_message,direct_mention,mention',function(bot, message) {
// Example receive middleware.
// for example, recognize several common variations on "hello" and add an intent field to the message
// see below for example hear_intent function
controller.middleware.receive.use(function(bot, message, next) {

console.log('Receive middleware!');
// make changes to bot or message here before calling next
if (message.text == 'hello' || message.text == 'hi' || message.text == 'howdy' || message.text == 'hey') {
message.intent = 'hello';
}

next();

});

// Example send middleware
// make changes to bot or message here before calling next
// for example, do formatting or add additional information to the message
controller.middleware.send.use(function(bot, message, next) {

console.log('Send middleware!');
next();

});


// Example hear middleware
// Return true if one of [patterns] matches message
// In this example, listen for an intent field, and match using that instead of the text field
function hear_intent(patterns, message) {

for (var p = 0; p < patterns.length; p++) {
if (message.intent == patterns[p]) {
return true;
}
}

return false;
}


/* note this uses example middlewares defined above */
controller.hears(['hello'],'direct_message,direct_mention,mention',hear_intent, function(bot, message) {

bot.api.reactions.add({
timestamp: message.ts,
Expand All @@ -96,16 +138,17 @@ controller.hears(['hello','hi'],'direct_message,direct_mention,mention',function

controller.storage.users.get(message.user,function(err, user) {
if (user && user.name) {
bot.reply(message,'Hello ' + user.name + '!!');
bot.reply(message, 'Hello ' + user.name + '!!');
} else {
bot.reply(message,'Hello.');
bot.reply(message, 'Hello.');
}
});
});

controller.hears(['call me (.*)'],'direct_message,direct_mention,mention',function(bot, message) {
var matches = message.text.match(/call me (.*)/i);
var name = matches[1];
controller.hears(['call me (.*)','my name is (.*)'],'direct_message,direct_mention,mention',function(bot, message) {

// the name will be stored in the message.match field
var name = message.match[1];
controller.storage.users.get(message.user,function(err, user) {
if (!user) {
user = {
Expand Down
Loading

0 comments on commit 9f54942

Please sign in to comment.