Reputation: 183
I am using python and dialogflowcx v3beta1 library, I want to pass a query params to detect intent function but it shows an error.
I have read the doc: https://cloud.google.com/dialogflow/cx/docs/reference/rest/v3beta1/QueryParameters but I am confusing with the format object Struct format.
How it should be pass in the code?
session_client = SessionsClient(client_options=client_options, credentials=credentials)
text_input = session.TextInput(text=message)
query_input = session.QueryInput(text=text_input, language_code=language_code)
query_params = {
"parameters": {
"param1": "value1"
}
}
request = session.DetectIntentRequest(
session=session_path, query_input=query_input, query_params=query_params
)
Thanks in advance.
Upvotes: 1
Views: 1864
Reputation: 121
I have a same concern with dialogflow nodejs api. Could you provide the JSON format data sample for queryParams? As QueryParameters obj can't be found in nodejs v3 sdk package.
var mapParameters = new Map([['Michael', 95], ['Bob', 75], ['Tracy', 85]]);
const request = {
session: sessionPath,
"queryInput": {
"text": {
"text": query,
},
languageCode,
},
'queryParams': {
'timeZone': 'America/Los_Angeles',
'parameters': {
"fields":mapParameters
}
},
};
const [response] = await client.detectIntent(request);
I also tried these, but did not work.
const request = {
session: sessionPath,
"queryInput": {
"text": {
"text": query,
},
languageCode,
},
'queryParams': {
'timeZone': 'America/Los_Angeles',
'parameters': {
"p1":"p1 value"
}
},
};
Upvotes: 1
Reputation: 183
Solved. I used the next code.
text_input = session.TextInput(text=message)
query_input = session.QueryInput(text=text_input, language_code=language_code)
params = {
"session_id": session_id
}
query_params = session.QueryParameters(parameters=params)
request = session.DetectIntentRequest(
session=session_path, query_input=query_input, query_params=query_params
)
Upvotes: 1