Dialogflow Messenger CX intercept and add queryParams to responseBody

725 views
Skip to first unread message

Arsenio Aguirre

unread,
Feb 18, 2021, 10:01:39 AM2/18/21
to Dialogflow CX Edition users
Hi,

I want to intercept the request from dialogflow messenger CX and add parameters to responseBody by queryParams, I have read the documentation but it is not clear about how to add the new parameters using javascript event. I understand that there is a event called df-request-sent but the documentation doesn't show about how to send the new parameters in the event. I have searched similar question but i didn't find information.


The code is:

         const dfMessenger = document.querySelector('df-messenger')
         dfMessenger.addEventListener('df-request-sent', function (event) {
             console.log(event)
             // how to send the new parameters?
         })
I have tried changing the value of event.detail but it didn't work.

Anybody know how to do it?

Thanks for your help.

Regards,
Arsenio

Hannah Jane Nicole Altares

unread,
Apr 28, 2021, 7:23:24 PM4/28/21
to Dialogflow CX Edition users

Unfortunately, adding parameters on the queryParams of the Dialogflow Messenger event’s df-request-sent isn’t possible. Please note that this event occurs when a request is made to the Dialogflow API, and we cannot edit the event structure as this is dependent on Dialogflow Messenger’s detectIntent request. 

As a workaround, you can use custom integration. You can utilize Dialogflow CX’s Client Libraries, REST API, or RPC API to create your own implementation/integration. Then, you can add parameters in your detectIntent request.

Here is a sample of detectIntent request body:

      {

        "queryInput": {

          "text": {

            "text": "Hi"

          },

          "languageCode": "en"

        },

        "queryParams": {

          "timeZone": "America/Los_Angeles",

          "parameters": {

              //set your parameters here

Reply all
Reply to author
Forward
0 new messages