Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
260 views
in Technique[技术] by (71.8m points)

How to pass queryparams in dialogflow CX using python

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.

question from:https://stackoverflow.com/questions/65892295/how-to-pass-queryparams-in-dialogflow-cx-using-python

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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
)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...