问题
I haven't been able to create a Session Entity in Inline Editor, using this plugin: actions-on-google-dialogflow-session-entities-plugin.
I declared the variable/package:
const { sessionEntitiesHelper } = require('actions-on-google-dialogflow-session-entities-plugin');
Updated my json package
"dependencies": {
"actions-on-google": "^2.12.0",
"firebase-admin": "^6.4.0",
"firebase-functions": "^2.1.0",
"dialogflow": "^4.0.3",
"dialogflow-fulfillment": "^0.6.1",
"google-auth-library": "^1.6.1",
"googleapis": "^39.2.0",
"actions-on-google-dialogflow-session-entities-plugin": "^1.0.1"
But when I call the the function
let conv = agent.conv();
conv.sessionEntities.add({
name: 'processo',
entities: [{
value: 'descarte',
}, {
value: 'cobrança',
}]
});
conv.sessionEntities.send();
It says that: TypeError: Cannot read property 'sessionEntities' of null
Can't figure out how to make that work. I found lots of examples (even here) but no one implemented in Inline Editor.
Just a reminder, as I'm using Inline Editor, I'm inside these functions context:
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
const agent = new WebhookClient({ request, response });
So, examples like this one: https://cloud.google.com/dialogflow/docs/entities-session did not help.
Am I missing something?
Thanks for helping, I appreciate any clue...
Diego Mesquita
回答1:
The issue is that you're also using the "dialogflow-fulfillment" library, and it doesn't know how to create a conv
object that also has the sessionEntities
object created when you call agent.conv()
.
The easiest solution is to stop using the 'dialogflow-fulfillment" library and just use the "actions-on-google" library. You don't need to use "dialogflow-fulfillment" just because you're using the Inline Editor. The two are fairly similar, and if you're just developing for Actions on Google, there isn't much reason to use "dialogflow-fulfillment".
If you need to use "dialogflow-fulfillment" since you need to support other platforms besides Actions on Google, things may be trickier. I haven't tried this but code something like this might work
const entity = {/* Put your entity definition here */};
agent.client.addJson_({sessionEntityTypes: [entity]});
As an aside, keep in mind that the "dialogflow-fulfillment" package has been deprecated, apparently in favor of writing the JSON manually. The "actions-on-google" package has also been deprecated as it does not support Actions v3 and the Actions Builder/SDK (which do not use Dialogflow).
来源:https://stackoverflow.com/questions/63065559/actions-on-google-dialogflow-session-entities-plugin-not-working-in-dialogflows