起始页中的属性(路由/事件处理程序)实际上在流本身中。
您可以使用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);
您可以从代理 URL获取 ID 。对于流 ID,您必须先选择所需的流,然后再复制代理 URL。
您还可以查看 REST API 中的等效方法以获取更多信息:projects.locations.agents.flows.get和projects.locations.agents.flows.patch。