如何在调用 Dialogflow API 时指定代理 ID?
How to specify agent ID when calling Dialogflow API?
我正在使用以下 NodeJS 代码对 Dialogflow 进行 API 调用以发送消息 "Hello there",我可以指定项目 ID、会话 ID,但我不确定在哪里可以指定代理 ID。
let projectId = 'DEMO PROJECT';
let message ='Hello there';
// A unique identifier for the given session
const sessionId = uuid.v4();
// Create a new session
const sessionClient = new dialogflow.SessionsClient();
const sessionPath = sessionClient.sessionPath(projectId, sessionId);
// The text query request.
const request = {
session: sessionPath,
queryInput: {
text: {
// The query to send to the dialogflow agent
text: message,
// The language used by the client (en-US)
languageCode: 'en-US',
},
},
};
// Send request and log result
const responses = await sessionClient.detectIntent(request);
问题是我在 DEMO 项目下实际创建代理,因此,我需要指定此对话将发送给哪个代理。
目前我只能指定项目 ID 和会话 ID,但是,我的问题是如何指定 agent ID?
根据google官方文档
这就是为什么您无法指定代理 ID,因为每个项目下只有 1 个代理。
我正在使用以下 NodeJS 代码对 Dialogflow 进行 API 调用以发送消息 "Hello there",我可以指定项目 ID、会话 ID,但我不确定在哪里可以指定代理 ID。
let projectId = 'DEMO PROJECT';
let message ='Hello there';
// A unique identifier for the given session
const sessionId = uuid.v4();
// Create a new session
const sessionClient = new dialogflow.SessionsClient();
const sessionPath = sessionClient.sessionPath(projectId, sessionId);
// The text query request.
const request = {
session: sessionPath,
queryInput: {
text: {
// The query to send to the dialogflow agent
text: message,
// The language used by the client (en-US)
languageCode: 'en-US',
},
},
};
// Send request and log result
const responses = await sessionClient.detectIntent(request);
问题是我在 DEMO 项目下实际创建代理,因此,我需要指定此对话将发送给哪个代理。 目前我只能指定项目 ID 和会话 ID,但是,我的问题是如何指定 agent ID?
根据google官方文档
这就是为什么您无法指定代理 ID,因为每个项目下只有 1 个代理。