Modify Start Page Routes Node.js Client Libraries

308 views
Skip to first unread message

Pablo Montoya

unread,
Jun 15, 2021, 3:10:11 AM6/15/21
to Dialogflow CX Edition users
I want to modify the Start Page default route to add a transition route to another page.

I'm trying to do this with the Client libraries, I've successfully created new pages and edited its routes and transition routes, but I can't get the Start Page trough the client libraries and modify it, I get an error saying that the Start Page doesn't exists on the default route or that I can't modify the built-in Start Page. Is there any way to achieve is with the Client Libraries?

Thanks!

Marianne Lerin

unread,
Jun 24, 2021, 5:46:49 PM6/24/21
to Dialogflow CX Edition users

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 modify the Start Page routes 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.

Hossam Hassan

unread,
Aug 17, 2021, 10:18:50 AM8/17/21
to Dialogflow CX Edition users
I have tried your solution but I always get "Invalid update mask" response
I tried changing the update mask to ["description"] to see if it will work instead of ["transitionRoutes"] and it works just fine
I don't know what's wrong with "transitionRoutes" as update mask

my "transitionRoutes" array :
[{
                "intent": "projects/alpine-keep-322312/locations/global/agents/c0da88bd-3f77-4855-9cb3-a758b8615524/intents/00000000-0000-0000-0000-000000000000",
                "condition": "",
                "triggerFulfillment": {
                    "messages": [
                        {
                            "text": {
                                "text": ["أهلا"]
                            }
                        }],
                    "setParameterActions": [], "conditionalCases": [], "webhook": "", "tag": "", "returnPartialResponses": false
                },
                "targetPage": "projects/alpine-keep-322312/locations/global/agents/c0da88bd-3f77-4855-9cb3-a758b8615524/flows/00000000-0000-0000-0000-000000000000/pages/6e5bc00d-a2bb-4f6b-b8a7-ce8224226f56",
            }]
Reply all
Reply to author
Forward
0 new messages