jschnurr / botkit-middleware-dialogflow Goto Github PK
View Code? Open in Web Editor NEWBotkit middleware for Dialogflow (formerly api.ai). Supports Dialogflow API v1 and V2.
License: MIT License
Botkit middleware for Dialogflow (formerly api.ai). Supports Dialogflow API v1 and V2.
License: MIT License
Dear Jeff and experts
I am trying to build myjabber bot app by adding module "botkit-middleware-dialogflow": "^2.0.4" , but it returns the below error could you please help find the cause of the issue
Thanks
4:04:35 PM (Builder) Build of "/CiscoJabber/myjabber" started.
4:04:44 PM (DIBuild) Build of "/CiscoJabber/myjabber" in progress.
4:04:45 PM (DIBuild) Service provisioning for module: '/myjabber'[INFO] Injecting source code into builder...[INFO] Source code injection finished[INFO] ------------------------------------------------------------------------
4:05:13 PM (DIBuild) > [email protected] install /home/vcap/app/.java-buildpack/tomcat/temp/builder/sap.nodejs/builds/build-6798269379419657313/myjabber/node_modules/grpc> node-pre-gyp install --fallback-to-build --library=static_librarygyp ERR! configure error gyp ERR! stack Error: ENOENT: no such file or directory, open '/home/vcap/app/META-INF/resources/nodejs/aggr.pem'gyp ERR! stack at Object.fs.openSync (fs.js:646:18)gyp ERR! stack at Object.fs.readFileSync (fs.js:551:33)gyp ERR! stack at readCAFile (/home/vcap/app/.java-buildpack/tomcat/temp/nodejsbin5846029318158714442/node-v8.9.1-linux-x64/lib/node_modules/npm/node_modules/node-gyp/lib/install.js:466:15)gyp ERR! stack at download (/home/vcap/app/.java-buildpack/tomcat/temp/nodejsbin5846029318158714442/node-v8.9.1-linux-x64/lib/node_modules/npm/node_modules/node-gyp/lib/install.js:438:22)gyp ERR! stack at /home/vcap/app/.java-buildpack/tomcat/temp/nodejsbin5846029318158714442/node-v8.9.1-linux-x64/lib/node_modules/npm/node_modules/node-gyp/lib/install.js:185:19gyp ERR! stack at /home/vcap/app/.java-buildpack/tomcat/temp/nodejsbin5846029318158714442/node-v8.9.1-linux-x64/lib/node_modules/npm/node_modules/mkdirp/index.js:48:26gyp ERR! stack at FSReqWrap.oncomplete (fs.js:153:5)gyp ERR! System Linux 4.15.0-39-genericgyp ERR! command "/home/vcap/app/.java-buildpack/tomcat/temp/nodejsbin5846029318158714442/node-v8.9.1-linux-x64/bin/node" "/home/vcap/app/.java-buildpack/tomcat/temp/nodejsbin5846029318158714442/node-v8.9.1-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--library=static_library" "--module=/home/vcap/app/.java-buildpack/tomcat/temp/builder/sap.nodejs/builds/build-6798269379419657313/myjabber/node_modules/grpc/src/node/extension_binary/node-v57-linux-x64-glibc/grpc_node.node" "--module_name=grpc_node" "--module_path=/home/vcap/app/.java-buildpack/tomcat/temp/builder/sap.nodejs/builds/build-6798269379419657313/myjabber/node_modules/grpc/src/node/extension_binary/node-v57-linux-x64-glibc" "--napi_version=1" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v57"gyp ERR! cwd /home/vcap/app/.java-buildpack/tomcat/temp/builder/sap.nodejs/builds/build-6798269379419657313/myjabber/node_modules/grpcgyp ERR! node -v v8.9.1gyp ERR! node-gyp -v v3.6.2gyp ERR! not ok node-pre-gyp ERR! build error node-pre-gyp ERR! stack Error: Failed to execute '/home/vcap/app/.java-buildpack/tomcat/temp/nodejsbin5846029318158714442/node-v8.9.1-linux-x64/bin/node /home/vcap/app/.java-buildpack/tomcat/temp/nodejsbin5846029318158714442/node-v8.9.1-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --library=static_library --module=/home/vcap/app/.java-buildpack/tomcat/temp/builder/sap.nodejs/builds/build-6798269379419657313/myjabber/node_modules/grpc/src/node/extension_binary/node-v57-linux-x64-glibc/grpc_node.node --module_name=grpc_node --module_path=/home/vcap/app/.java-buildpack/tomcat/temp/builder/sap.nodejs/builds/build-6798269379419657313/myjabber/node_modules/grpc/src/node/extension_binary/node-v57-linux-x64-glibc --napi_version=1 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v57' (1)node-pre-gyp ERR! stack at ChildProcess. (/home/vcap/app/.java-buildpack/tomcat/temp/builder/sap.nodejs/builds/build-6798269379419657313/myjabber/node_modules/grpc/node_modules/node-pre-gyp/lib/util/compile.js:83:29)node-pre-gyp ERR! stack at emitTwo (events.js:126:13)node-pre-gyp ERR! stack at ChildProcess.emit (events.js:214:7)node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:925:16)node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)node-pre-gyp ERR! System Linux 4.15.0-39-genericnode-pre-gyp ERR! command "/home/vcap/app/.java-buildpack/tomcat/temp/nodejsbin5846029318158714442/node-v8.9.1-linux-x64/bin/node" "/home/vcap/app/.java-buildpack/tomcat/temp/builder/sap.nodejs/builds/build-6798269379419657313/myjabber/node_modules/grpc/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build" "--library=static_library"node-pre-gyp ERR! cwd /home/vcap/app/.java-buildpack/tomcat/temp/builder/sap.nodejs/builds/build-6798269379419657313/myjabber/node_modules/grpcnode-pre-gyp ERR! node -v v8.9.1node-pre-gyp ERR! node-pre-gyp -v v0.12.0node-pre-gyp ERR! not ok Failed to execute '/home/vcap/app/.java-buildpack/tomcat/temp/nodejsbin5846029318158714442/node-v8.9.1-linux-x64/bin/node /home/vcap/app/.java-buildpack/tomcat/temp/nodejsbin5846029318158714442/node-v8.9.1-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --library=static_library --module=/home/vcap/app/.java-buildpack/tomcat/temp/builder/sap.nodejs/builds/build-6798269379419657313/myjabber/node_modules/grpc/src/node/extension_binary/node-v57-linux-x64-glibc/grpc_node.node --module_name=grpc_node --module_path=/home/vcap/app/.java-buildpack/tomcat/temp/builder/sap.nodejs/builds/build-6798269379419657313/myjabber/node_modules/grpc/src/node/extension_binary/node-v57-linux-x64-glibc --napi_version=1 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v57' (1)npm ERR! code ELIFECYCLEnpm ERR! errno 1npm ERR! [email protected] install: node-pre-gyp install --fallback-to-build --library=static_librarynpm ERR! Exit status 1npm ERR! npm ERR! Failed at the [email protected] install script.npm ERR! This is probably not a problem with npm. There is likely additional logging output above.npm ERR! A complete log of this run can be found in:npm ERR! /home/vcap/app/META-INF/cache/8.9.1/.npm/_logs/2019-01-13T12_05_22_461Z-debug.log
4:05:17 PM (Builder) Build of /CiscoJabber/myjabber failed.
This is the code i used
var apiai = require('botkit-middleware-dialogflow')({
token:process.env.API_AI_ACCESS_TOKEN,
skip_bot: true // false. If true, the middleware doesn't send the bot reply/says to Dialogflow
})
controller.middleware.receive.use(apiai.receive);
controller.hears(['hello'],'message_received',apiai.hears,function(bot, message) {
console.log("api .ai detected entities", message.entities);
});
Hi,
Is possible to persist outputContexts through conversations ?
To have followup intents working ?
Tks
Dialog has a limit of 256, it triggers an error and it isn't handled in this module and causes that the message does not reach botkit
The V2 version of requires a keyfilename to the private key file that includes app secrets. I would rather not put those things in version control if I can avoid it to reduce the risk of compromise. If I'm deploying to Heroku, I can put all the secrets I want in environment variables.
Is it possible to pass the secrets I need through environment variables rather than through the keyfile?
Hello,
Awesome plugin. Worked great with Botkit 0.7.x. However, I am having trouble integrating with Botkit 4.x.x. I can't seem to access message.intent
when using the controller.hears
function. See below:
controller.on('message', async(bot, message) => {
console.log(message) // message contains message.intent
});
controller.hears('hello', 'message', async(bot, message) => {
console.log(message) // message does not contain message.intent
});
I am not sure what I could be messing. Hopefully you can help me out?
node: 8.11.2
botkit-middleware-dialogflow: 2.1.0
botkit: 4.0.1
attempt registry request try #1 at 5:30:16 PM
npm http request GET https://registry.npmjs.org/botkit-middleware-dialogflow
npm http 404 https://registry.npmjs.org/botkit-middleware-dialogflow
npm ERR! Linux 4.9.49-moby
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "botkit-middleware-dialogflow" "--save"
npm ERR! node v7.10.1
npm ERR! npm v4.2.0
npm ERR! code E404
npm ERR! 404 Registry returned 404 for GET on https://registry.npmjs.org/botkit-middleware-dialogflow
npm ERR! 404
npm ERR! 404 'botkit-middleware-dialogflow' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
When receiving a postback (button or quick reply) the middleware will trigger a call to the Dialogflow API. But in this case it doesn't make sense (at least for me) because I don't need the NLP if I get the postback. Is there a way to work around this?
Example:
dialogflow-middleware Sending message to dialogflow chocolate +6m
dialogflow-middleware dialogflow annotated message: { recipient: { id: '195287897753341' },
dialogflow-middleware timestamp: 1525034045447,
dialogflow-middleware sender: { id: '1853453368055024' },
dialogflow-middleware postback: { payload: 'chocolate', title: 'Eat Cookie' },
dialogflow-middleware raw_message:
dialogflow-middleware { recipient: { id: '195287897753341' },
dialogflow-middleware timestamp: 1525034045447,
dialogflow-middleware sender: { id: '1853453368055024' },
dialogflow-middleware postback: { payload: 'chocolate', title: 'Eat Cookie' } },
dialogflow-middleware _pipeline: { stage: 'receive' },
dialogflow-middleware user: '1853453368055024',
dialogflow-middleware channel: '1853453368055024',
dialogflow-middleware page: '195287897753341',
dialogflow-middleware text: 'chocolate',
dialogflow-middleware payload: 'chocolate',
dialogflow-middleware referral: undefined,
dialogflow-middleware type: 'facebook_postback',
dialogflow-middleware intent: 'Default Fallback Intent',
dialogflow-middleware entities: {},
dialogflow-middleware fulfillment:
dialogflow-middleware { speech: 'Ich verstehe deine Frage leider nicht.',
dialogflow-middleware messages: [ [Object] ] },
dialogflow-middleware confidence: 1,
dialogflow-middleware nlpResponse:
dialogflow-middleware { id: '280a7cf7-c4a6-4b6b-9a64-93faee757a1d',
dialogflow-middleware timestamp: '2018-04-29T20:34:06.013Z',
dialogflow-middleware lang: 'de',
dialogflow-middleware result:
dialogflow-middleware { source: 'agent',
dialogflow-middleware resolvedQuery: 'chocolate',
dialogflow-middleware action: 'input.unknown',
dialogflow-middleware actionIncomplete: false,
dialogflow-middleware parameters: {},
dialogflow-middleware contexts: [],
dialogflow-middleware metadata: [Object],
dialogflow-middleware fulfillment: [Object],
dialogflow-middleware score: 1 },
dialogflow-middleware status: { code: 200, errorType: 'success', webhookTimedOut: false },
dialogflow-middleware sessionId: 'b9e85910-4beb-11e8-8ba5-5f5c6e9cb7ad' } } +255ms
DialogflowMiddleware.hears - works, but any trigger in action doesn't received.
would have been helpful to put a package.json
and .env
file in the examples folder
also it seems that botkit should be a dependency not a devDependency
Hello!
I've been trying to integrate this with the web template for botkit. I couldn't find any examples for it, there are only examples for facebook and slack.
Just to get it to work, my current basic code involves just bot.js
and not the features
directory.
Please take a look as this doesn't seem to work! More examples for web integration would also be a blessing.
const { Botkit } = require('botkit');
const { BotkitCMSHelper } = require('botkit-plugin-cms');
//Import dialogflow middleware
const dialogflowMiddleware = require('botkit-middleware-dialogflow')({
keyFilename: 'keys/testaction-service-key.json', // service account private key file from Google Cloud Console
});
// Import a platform-specific adapter for web.
const { WebAdapter } = require('botbuilder-adapter-web');
const { MongoDbStorage } = require('botbuilder-storage-mongodb');
const path = require('path');
// Load process.env values from .env file
require('dotenv').config();
let storage = null;
if (process.env.MONGO_URI) {
storage = mongoStorage = new MongoDbStorage({
url: process.env.MONGO_URI,
});
}
const adapter = new WebAdapter({});
const controller = new Botkit({
debug: true,
webhook_uri: '/api/messages',
adapter: adapter,
storage
});
// if (process.env.cms_uri) {
// controller.usePlugin(new BotkitCMSHelper({
// cms_uri: process.env.cms_uri,
// token: process.env.cms_token,
// }));
// }
controller.middleware.receive.use(dialogflowMiddleware.receive);
controller.hears(['Default Welcome Intent'], 'message,direct_message,message_received', dialogflowMiddleware.hears, function (bot, message) {
replyText = message.fulfillment.text; // message object has new fields added by Dialogflow
console.log(replyText, typeof replyText);
bot.reply(message, replyText);
});
// make public/index.html available as localhost/index.html
// by making the /public folder a static/public asset
controller.publicFolder('/', path.join(__dirname,'.','public'));
console.log('Chat with me: http://localhost:' + (process.env.PORT || 3000));
Hi,
Any idea when version 2 of the Dialogflow API would be implemented since it's now generally available and out of beta.
Official Dialogflow v2 SDK for Node.js
โ H
Hello,
I tried to handle small talk in my bot, but Dialogflow has more than 20 different intents for small talk, as per https://dialogflow.com/docs/reference/small-talk
Apparently this does not match anything:
controller.hears('smalltalk(.*)', 'direct_message,direct_mention', dialogflowMiddleware.hears, function(bot, message) { // do something });
A similar issue was raised on botman and fixed, as per https://github.com/botman/botman/issues/252
Is this possible, or already supported ?
Thanks !
projectId
is undefined when passed as a config option.
DialogflowMiddleware({
version: 'V2',
projectId: 'test-project',
keyFilename: 'keyfile.json'
});
dialogflow returned error TypeError: Cannot read property 'charCodeAt' of undefined
at peg$parsetemplate (node_modules/google-gax/lib/path_template_parser.js:309:17)
at Object.peg$parse [as parse] (node_modules/google-gax/lib/path_template_parser.js:640:18)
at new PathTemplate (node_modules/google-gax/lib/path_template.js:52:47)
at node_modules/google-gax/lib/path_template.js:139:17
at Array.forEach (<anonymous>)
at PathTemplate.render (node_modules/google-gax/lib/path_template.js:129:17)
at SessionsClient.sessionPath (node_modules/dialogflow/src/v2/sessions_client.js:320:52)
at DialogFlowAPI_V2.query (node_modules/botkit-middleware-dialogflow/src/api.js:101:25)
at Object.middleware.receive (node_modules/botkit-middleware-dialogflow/src/botkit-middleware-dialogflow.js:39:34)
...
I have defined my agent in AU region, alongside with my project which is also defaulted to AU.
ERROR 5 is received with No Dialog Agent found when i use the package and define that as middleware.
However, establishing the bot in US/Global region seems to do the trick. This workaround is not viable as our platform is limited to use AU only services.
Did i miss some parameter there that i could potentially pass location to the adaptor?
https://github.com/googleapis/nodejs-dialogflow-cx/blob/master/samples/quickstart.js
This is for dialogflow cx which i am sure botkit-middleware-dialogflow is only for ES. however, the example work as long as the location is defined correctly.
I am led to believe that location parameter is missing from this middleware...
do you have an example for the implementation?
npm WARN deprecated [email protected]: Use uuid module instead
Hi, the images that are referenced from the README.md file cannot be shown.
For example https://s8.postimg.org/450f8dak5/message_dif.png
Hello,
I have a small issue, the newlines that I add in Dialogflow are dissapering. Is this normal behaviour?
Thank you
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.