Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 17 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
env: {
browser: true,
commonjs: true,
es6: true
},
extends: ['eslint:recommended', 'prettier', 'airbnb'],
plugins: ['prettier'],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly'
},
parserOptions: {
ecmaVersion: 2018
},
rules: { 'prettier/prettier': 'error' }
};
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
/docs/doc
/**/.vscode
/.idea/
node_modules/
node_modules/
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Use Luis's natural language tools in your Botkit-powered Bot !
# Use Luis's natural language tools in your Botkit-powered Bot!

This middleware plugin for Botkit allows you to seamlessly integrate [Luis](http://luis.ai) natural language intent APIs into your Botkit bot.

Expand All @@ -24,7 +24,7 @@ The first step to using [Luis](http://luis.ai) is to create an application. In t
<img src="https://s26.postimg.org/el6k8ijqx/createApp.png"/>
</p>

From your app's settings page, snag the service url. You will need this to use Luis's API.
From your app's settings page, snag the service url. You will assign this to a meaningful environment variable in `.env` or however you do it.

Next you will need to add botkit-middleware-luis as a dependency to your Botkit bot:

Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./src/luis-middleware.js');
module.exports = require('./src/luis-middleware.js');
35 changes: 21 additions & 14 deletions luis_example_bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,31 +48,38 @@ var Botkit = require('./lib/Botkit.js');
var luis = require('./lib/luis-middleware.js');

if (!process.env.token) {
console.log('Error: Specify token in environment');
process.exit(1);
console.log('Error: Specify token in environment');
process.exit(1);
}

if (!process.env.serviceUri) {
console.log('Error: Specify Luis service uri');
process.exit(1);
console.log('Error: Specify Luis service uri');
process.exit(1);
}

var luisOptions = {serviceUri: process.env.serviceUri};
var luisOptions = { serviceUri: process.env.serviceUri };

var controller = Botkit.slackbot({
debug: false
debug: false,
});

controller.spawn({
token: process.env.token
}).startRTM(function(err) {
controller
.spawn({
token: process.env.token,
})
.startRTM(function(err) {
if (err) {
throw new Error(err);
throw new Error(err);
}
});
});

controller.middleware.receive.use(luis.middleware.receive(luisOptions));

controller.hears(['hello','hi'],['direct_message','direct_mention','mention'], luis.middleware.hereIntent, function(bot,message) {
bot.reply(message,"Hello.");
});
controller.hears(
['hello', 'hi'],
['direct_message', 'direct_mention', 'mention'],
luis.middleware.hearIntent,
function(bot, message) {
bot.reply(message, 'Hello.');
},
);
Loading