实际上,我想将一些其他参数(例如用户名,用户ID)传递给webhook,但我无法执行此操作。
我正在使用sessionClient的detectIntent()方法。以下是请求:
function detectEventIntent(projectId, sessionId, eventName, languageCode) {
// Imports the Dialogflow library
const dialogflow = require('dialogflow');
// Instantiates a sessison client
const sessionClient = new dialogflow.SessionsClient();
// The path to identify the agent that owns the created intent.
const sessionPath = sessionClient.sessionPath(projectId, sessionId);
// The text query request.
const request = {
session: sessionPath,
queryInput: {
text: {
text: query,
languageCode: languageCode,
},
},
queryParams:{
payload: {
data:{
username: 'gaurav',
userId: usr1
}
}
}
};
sessionClient
.detectIntent(request)
.then(responses => {
console.log('Detected intent');
logQueryResult(sessionClient, responses[0].queryResult);
})
.catch(err => {
console.error('ERROR:', err);
});
}
答案 0 :(得分:0)
There are differences in passing some additional parameters such as username, user ID in dialogFlow V1 and dialogFlow V2. In dialogFlow V1 its relatively hard to pass additional parameters whereas in dialogFlow V2 one can easily pass user ID, project ID. Just give additional functions in the dialogFlow after
const dialogflow = require('dialogflow');
Just give as:-
let projectId = 'Name as you like';
let sessionId = ' As you Like ';
let dialogflow = require('dialogflow');
let config = {
credentials: {
private_key: "....Your Key.....",
client_email: "....Your Service Account mail...."
}
}