-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Npm package is outdated. #17
Comments
You can also point directly to the github repo:
|
For others who may be watching this issue, the botkit-witai middleware looks like it's more up to date. With that library I was able to put the following together which assumes that you have already completed at least up to 4) in https://wit.ai/docs/quickstart. Also, Javascript is not my strong suit, but the code should be clear enough to get the message across. let config = null;
try {
config = require('./config.json');
} catch (e) {
console.log('Unable to load ./config.json')
}
const Botkit = require('botkit');
const wit = require('botkit-witai')({
accessToken: process.env.WIT_TOKEN || config.WIT_TOKEN,
minConfidence: 0.4,
logLevel: 'debug'
});
const controller = Botkit.slackbot({
debug: false
});
const bot = controller.spawn({
token: process.env.SLACK_TOKEN || config.SLACK_TOKEN
}).startRTM();
controller.setupWebserver(process.env.PORT || 3001, (err, webserver) => {
controller.createWebhookEndpoints(webserver, bot);
});
controller.middleware.receive.use(wit.receive);
controller.hears(['weather'], 'direct_message', (bot, message) => {
bot.botkit.log("Wit.ai detected entities", message.entities);
bot.botkit.log(`Message: ${prettyJSON(message)}`);
const intent = firstEntityValue(message.entities, 'intent');
bot.botkit.log(`Intent: ${intent}`);
const location = firstEntityValue(message.entities, 'location');
bot.botkit.log(`Location: ${location}`);
bot.reply(message, `You want to know more about ${intent} for ${location} correct?`);
});
const firstEntityValue = (entities, entity) => {
const val = entities && entities[entity] &&
Array.isArray(entities[entity]) &&
entities[entity].length > 0 &&
entities[entity][0].value
;
if (!val) {
return null;
}
return typeof val === 'object' ? val.value : val;
};
function prettyJSON(obj) {
return JSON.stringify(obj, null, 2);
} |
botkit-witai is currently broken due to changes on how intents are handled. |
Hey guys, just a headsup about the npm package.
It looks like it's not up to date to the latest release from this repo and thus doesn't work with the current Wit API version.
To make it work, I've downloaded the code from this repo directly and included in my project.
The text was updated successfully, but these errors were encountered: