简体   繁体   中英

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:

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

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

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.

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.

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. For the Flow ID you would have to select first the desired flow before copying the agent 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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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