简体   繁体   English

如何使用 Dialogflow CX API 获取默认起始页面并编辑其默认路由?

[英]How to get the default start page with Dialogflow CX API and edit its default route?

I've been trying to get the start page with no success to update its default route's transition route to another page (doing it programmatically), I saw in the docs that the id of the start page is START_PAGE here but the problem is when I actually try to get the page I get this error:我一直在尝试获取起始页面但没有成功将其默认路由的转换路由更新到另一个页面(以编程方式进行),我在文档中看到起始页面的 id 是 START_PAGE 但问题是当我实际上尝试获取我收到此错误的页面:

com.google.apps.framework.request.NotFoundException: Page 'START_PAGE' does not exist in the flow.

I used the client libraries for node.js that Dialogflow CX offers我使用了 Dialogflow CX 提供的 node.js 的 客户端库

I'm also using the default start flow which is in the same resource.我还使用同一资源中的默认启动流程。

I've also tried looking though all my pages with the listPages method and all my pages appear but the start page我还尝试使用 listPages 方法查看我的所有页面,并且我的所有页面都出现了,但起始页

Is the start page a special element I should be looking in other places?起始页是我应该在其他地方查看的特殊元素吗?

Properties(routes/event handler) in the Start Page are actually in the Flow itself.起始页中的属性(路由/事件处理程序)实际上在流本身中。

You can get the routes for the Start Page by utilizing GetFlow Node.js Method.您可以使用GetFlow Node.js 方法获取起始页的路线。

Then to edit its default route for transitioning, you can use the updateFlow Node.js Method and update the transitionRoutes field to route to another page.然后要编辑其默认路由以进行转换,您可以使用updateFlow Node.js 方法并更新 transitionRoutes 字段以路由到另一个页面。

Here is the sample code for your reference:以下是供您参考的示例代码:

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);

You can get the IDs from the agent URL.您可以从代理 URL获取 ID For the Flow ID you would have to select first the desired flow before copying the agent URL.对于流 ID,您必须先 select,然后再复制代理 URL 所需的流。

You can also check the equivalent methods in REST API for more information: projects.locations.agents.flows.get and projects.locations.agents.flows.patch .您还可以查看 REST API 中的等效方法以获取更多信息: projects.locations.agents.flows.getprojects.locations.agents.flows.patch

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM