Dialogflow CX - Detect Intent API Session Params

Hey!

Would really appreciate some help, as I'm a little stuck! New to Dialogflow CX and trying to integrate it with an existing Chat UI via the API (node.JS specifically).

I've got an instance of dialogflow CX setup, which I've (for test purposes) asked to repeat session parameters back to me. Specifically responding with

Allergies List: $session.params.allergies

I'm then invoking the 'detectIntent' API in order to resolve this response to the user's input

const request = {
session: sessionPath,
queryInput: {
text: {
text: messages[messages.length - 1].content
},
languageCode
},
queryParams: {
parameters: {
allergies: "nuts, seeds, dairy"
}
}
}

const [response] = await client.detectIntent(request)

When tested via the Agent Simulator in the Dialogflow CX UI, I see, as expected, the parameter value repeated back to me.

However, when I invoke with the API, I just see the parameter path (not the value) repeated back, as the parameter is seemingly never set, despite being in the request.

I'd really appreciate any help or advice!

0 8 998
8 REPLIES 8

hi!

it should be an array not a comma separated string:

const request = {
session: sessionPath,
queryInput: {
text: {
text: messages[messages.length - 1].content
},
languageCode
},
queryParams: {
parameters: {
allergies: ["nuts", "seeds," "dairy"]
}
}
}

const [response] = await client.detectIntent(request)

Hey @xavidop , appreciate the response!

I don't think that's it - I'd still expect any string parameter to be templated in correctly too?

However, I tried this, and noted that it still isn't filling the value into the response.

I have however, tried manually with the REST API directly, rather than the Node.JS client and that is succeeding with my original request.

So it appears to be some misunderstanding of the documentation or bug in the Node.JS client.

I'll continue to explore and update this thread, though if anyone knows where I'm going wrong in my usage of the Node.JS client, that'd be really helpful.

keep me posted please!

Hi, @tryhardmcgee ! Did you find the problem that works in REST API directly, but not with Node.JS client?
I find myself in the same situation

 

Hi, @tryhardmcgee did you find the problem? Why works with REST API directly and not with Node.JS client?
I find myself in the same situation

did you configure the authentication properly?

Im also stuck on this.

 

      const userName = "Nick";
      const userLocation = "Maastricht";

      // Construct the session path
      const sessionPath = "xxxxxxxxxx" ; In my function this actually holds the correct path

      // Prepare the request
      const request = {
        session: sessionPath,
        queryInput: {
          text: {
            text: message,
          },
          languageCode: "en",
          queryParams: {
            context: {
              parameters: {
                user,
                session,
              },
            },
          },
          parameters:
            fields: {
              userName: {kind: "stringValue", stringValue: userName},
              userLocation: {kind: "stringValue", stringValue: userLocation},
            },
          },
        },
      };

I've tried without "kind" and the solution with the array Xavi proposed.

The function as a whole is working fine, im sending a message, getting a reply and extracting parameters, intents set by dialogflow itself and storing them for use in my app

I'm trying to pass a name to the agent to get a personalized reponse.

Any help is appreciated

Found the solution: 

queryParams: {
          parameters: {
            fields: {
              userName: {stringValue: userName},
              sessionId: {stringValue: sessionId},
              userId: {stringValue: userId},
            },
          },
        },
This now sets those values as session params.
I also had queryParams inside queryInput,.....maybe outdated code that Gemini gave me..