[英]How to get the default start page with Dialogflow CX API and edit its default route?
我一直在嘗試獲取起始頁面但沒有成功將其默認路由的轉換路由更新到另一個頁面(以編程方式進行),我在文檔中看到起始頁面的 id 是 START_PAGE 但問題是當我實際上嘗試獲取我收到此錯誤的頁面:
com.google.apps.framework.request.NotFoundException: Page 'START_PAGE' does not exist in the flow.
我使用了 Dialogflow CX 提供的 node.js 的 客戶端庫
我還使用同一資源中的默認啟動流程。
我還嘗試使用 listPages 方法查看我的所有頁面,並且我的所有頁面都出現了,但起始頁
起始頁是我應該在其他地方查看的特殊元素嗎?
起始頁中的屬性(路由/事件處理程序)實際上在流本身中。
您可以使用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,您必須先 select,然后再復制代理 URL 所需的流。
您還可以查看 REST API 中的等效方法以獲取更多信息: projects.locations.agents.flows.get和projects.locations.agents.flows.patch 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.