如何在Dialogflow中触发意图?我需要在没有用户响应的情况下触发意图。我知道我们需要在这里召集一个活动,但是不知道如何在V2 api中做同样的活动?
答案 0 :(得分:0)
答案 1 :(得分:-1)
您可以通过dialogflow触发事件,detectIntent
const dialogflow = require('dialogflow');
const config = require('../config');
// Import the JSON to gRPC struct converter
const credentials = {
client_email: config.GOOGLE_CLIENT_EMAIL,
private_key: config.GOOGLE_PRIVATE_KEY,
};
const sessionClient = new dialogflow.SessionsClient(
{
projectId: config.GOOGLE_PROJECT_ID,
credentials
}
);
module.exports = {
async sendEventToDialogFlow(event, params = {}) {
const sessionPath = sessionClient.sessionPath(config.GOOGLE_PROJECT_ID, sessionId);
const request = {
session: sessionPath,
queryInput: {
event: {
name: event,
languageCode: config.DF_LANGUAGE_CODE,
},
}
};
const responses = await sessionClient.detectIntent(request);
return responses[0].queryResult;
}
}