Access to parameter data

dialogflow
google-assistant

#1

Hello all!

To access a parameter for example a color, what I use is:
this.$inputs.color.value
But I have a question, how could I access the parameter that is generated called color.original.
I tried to access with:
this.$inputs.color.original.value
but it doesn’t work. Is this parameter accessible?

Thank you so much!

Greetings,

Alberto.


#2

I think this could work:

this.$inputs['color.original'].value

An alternative is also to log this.$inputs and see all the values of the element.


#3

Thank you very much for you answer Jan!

The first alternative doesn’t work. The error is:

Message: Cannot read property 'value' of undefined

The second alternative, I have tried:

console.log(this.$inputs)
and
this.$inputs.color to see all the values but the result is [object Object]


#4

Can you stringify the object before you call console.log?

console.log(JSON.stringify(this.$inputs, null, '\t'));

#5

Hi Alex!

I have tried this and the result is: (In the photo I added the parameters and then the result of console.log(JSON.stringify(this.$inputs, null, '\t'));

image

I don’t know how access to color.original

Thanks a lot!!


#6

Is there a reason you need color.original? Is there a difference to color ?


#7

In this case, color and color.original are equals. But look at the following example:

Captura%20de%20pantalla%20de%202019-04-25%2019-30-26

I want to get the value semana because I need it and I don’t know how get it.


#8

Ok, looks like a bug.

I wrote a small workaround until we publish a better solution:

getOriginalParameter(this, 'date-period.original')
function getOriginalParameter(jovo, parameterName) {
   
        if (jovo.$request && jovo.$request.queryResult && jovo.$request.queryResult.outputContexts) {
            const outputContext = jovo.$request.queryResult.outputContexts.find((context) => {
                  return context.parameters[parameterName];
            })
            
            if (outputContext) {
                return outputContext.parameters[parameterName];
            }
        }
}

#9

Sorry it took so long to get back to you, Alex!

I just tested your solution and it works correctly!

If you publish another solution, if you can, put it here if it’s not too much trouble!

Thank you very much for your help! :smile:

Greetings,

Alberto


#10

Since the last update the .original parameter is also stored in this.$inputs


#11

Thank you so much Alex!

It works correctly! :grin:

Regards,

Alberto.


#12

When I console.log() I get this error “There was an error loading Log Streams. Please try again by refreshing this page.” in my cloudwatch.