set parameters in EventInput in Dialogflow V2 API

前端 未结 2 897
無奈伤痛
無奈伤痛 2020-12-19 09:02

I desperatly try to set parameters in a

dialogflow.types.EventInput

in python.

This doc says the parameters need to be of type

相关标签:
2条回答
  • 2020-12-19 09:20

    Information in accepted answer is incorrect.

    You don't have to provide default values.

    You can reference event parameters directly in Value column of Parameters table.

    To reference an event parameter in the parameter table or a response, use the following format: #event-name.parameter-name.

    dialogflow docs

    Therefore, putting #greetPerson.given-name in Value would be enough.

    0 讨论(0)
  • 2020-12-19 09:33

    This is how I did this:

    import dialogflow
    from google.protobuf import struct_pb2
    
    session_client = dialogflow.SessionsClient()
    session = session_client.session_path(project_id, session_id)
    
    parameters = struct_pb2.Struct()
    parameters["given-name"] = 'Jeff'
    parameters["last-name"] = 'Bridges'
    
    query_input = {
        'event': {
            "name": "greetPerson",
            "parameters": parameters,
            "language_code": "de"
        }
    }
    
    response = session_client.detect_intent(
        session=session,
        query_input=query_input)
    

    Note:
    In dialogflow console, you must give default values of parameters as #even_name.parameter_name.
    In this case for parameter given-name it would be #greetPerson.given-name and for last-name it would be #greetPerson.last-name.

    Docs Reference:
    We are using DetectIntent, in which we are using QueryInput, in which finally we are using EvenInput

    Hope it helps.

    0 讨论(0)
提交回复
热议问题