如何使用 Dialogflow CX API 获取默认起始页并编辑其默认路由?
How to get the default start page with Dialogflow CX API and edit its default route?
我一直在尝试获取起始页,但没有成功将其默认路由的过渡路由更新到另一个页面(以编程方式进行),我在文档中看到起始页的 id 是 START_PAGE here 但问题是当我实际尝试获取页面时出现此错误:
com.google.apps.framework.request.NotFoundException: Page 'START_PAGE' does not exist in the flow.
我将 Dialogflow CX 提供的 client libraries 用于 node.js
我也在使用同一资源中的默认启动流程。
我也尝试过使用 listPages 方法查看我的所有页面,我的所有页面都出现了,但出现了起始页
起始页是我应该在其他地方寻找的特殊元素吗?
起始页中的Properties(routes/event handler) 实际上在流程本身中。
您可以使用 GetFlow Node.js 方法获取起始页的路由。
然后要编辑它的默认转换路由,您可以使用 updateFlow Node.js 方法并更新 transitionRoutes 字段以路由到另一个页面。
下面是供您参考的示例代码:
const {FlowsClient} = require('@google-cloud/dialogflow-cx');
const client = new FlowsClient();
async function updateFlow() {
const flowPath = client.flowPath(
projectId,
location,
agentId,
flowId
);
console.info(flowPath);
const request = {
flow: {
name: flowPath,
transitionRoutes: [{
intent: "projects/<PROJECT_ID>/locations/<LOCATION_ID>/agents/<AGENT_ID>/intents/<INTENT_ID>",
condition: "",
triggerFulfillment: {
messages: [{
text: {
"text": ["<TEXT>"],
},
message: "text"
}],
setParameterActions: [],
conditionalCases: [],
webhook: "",
tag: ""
},
name: "<NAME>"
}]
},
updateMask: {
paths: ["UPDATE_MASK"]
},
languageCode: "<LANGUAGE_CODE>"
};
const [response] = await client.updateFlow(request);
console.log(response);
}
const projectId = "<PROJECT_ID>"
const agentId = "<AGENT_ID>"
const location = "<LOCATION ID>"
const flowId = "<FLOW ID>"
updateFlow(projectId, agentId, location, flowId);
您可以 get the IDs 从代理 URL。对于 Flow ID,您必须先 select 所需的流,然后再复制代理 URL。
您还可以查看 REST API 中的等效方法以获取更多信息:projects.locations.agents.flows.get and projects.locations.agents.flows.patch.
我一直在尝试获取起始页,但没有成功将其默认路由的过渡路由更新到另一个页面(以编程方式进行),我在文档中看到起始页的 id 是 START_PAGE here 但问题是当我实际尝试获取页面时出现此错误:
com.google.apps.framework.request.NotFoundException: Page 'START_PAGE' does not exist in the flow.
我将 Dialogflow CX 提供的 client libraries 用于 node.js
我也在使用同一资源中的默认启动流程。
我也尝试过使用 listPages 方法查看我的所有页面,我的所有页面都出现了,但出现了起始页
起始页是我应该在其他地方寻找的特殊元素吗?
Properties(routes/event handler) 实际上在流程本身中。
您可以使用 GetFlow Node.js 方法获取起始页的路由。
然后要编辑它的默认转换路由,您可以使用 updateFlow Node.js 方法并更新 transitionRoutes 字段以路由到另一个页面。
下面是供您参考的示例代码:
const {FlowsClient} = require('@google-cloud/dialogflow-cx');
const client = new FlowsClient();
async function updateFlow() {
const flowPath = client.flowPath(
projectId,
location,
agentId,
flowId
);
console.info(flowPath);
const request = {
flow: {
name: flowPath,
transitionRoutes: [{
intent: "projects/<PROJECT_ID>/locations/<LOCATION_ID>/agents/<AGENT_ID>/intents/<INTENT_ID>",
condition: "",
triggerFulfillment: {
messages: [{
text: {
"text": ["<TEXT>"],
},
message: "text"
}],
setParameterActions: [],
conditionalCases: [],
webhook: "",
tag: ""
},
name: "<NAME>"
}]
},
updateMask: {
paths: ["UPDATE_MASK"]
},
languageCode: "<LANGUAGE_CODE>"
};
const [response] = await client.updateFlow(request);
console.log(response);
}
const projectId = "<PROJECT_ID>"
const agentId = "<AGENT_ID>"
const location = "<LOCATION ID>"
const flowId = "<FLOW ID>"
updateFlow(projectId, agentId, location, flowId);
您可以 get the IDs 从代理 URL。对于 Flow ID,您必须先 select 所需的流,然后再复制代理 URL。
您还可以查看 REST API 中的等效方法以获取更多信息:projects.locations.agents.flows.get and projects.locations.agents.flows.patch.