I desperatly try to set parameters in a
dialogflow.types.EventInput
in python.
This doc says the parameters need to be of type Struct
.
I read here that the parameters needs to be a google.protobuf.Struct. But it does not work for me.
Is there another Struct
type equivalent in python?
If i send the EventInput
without parameters, the intent is detected correctly.
I tried this so far:
import dialogflow_v2 as dialogflow
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'
event_input = dialogflow.types.EventInput(
name='greetPerson',
language_code='de',
parameters=parameters)
query_input = dialogflow.types.QueryInput(event=event_input)
response = session_client.detect_intent(
session=session, query_input=query_input)
Anybody having experience with this usecase?
Things i also tried:
Pass a
class
named p yields:Parameter to MergeFrom() must be instance of same class: expected Struct got p. for field EventInput.parameters
Pass a dict:
parameters = { 'given-name': 'Jeff', 'last-name': 'Bridges'}
yields:
Protocol message Struct has no "given-name" field.
Generate Struct with constructor:
from google.protobuf.struct_pb2 import Struct, Value parameters = Struct(fields={ 'given-name':Value(string_value='Jeff'), 'last-name':Value(string_value='Bidges') })
yields sometimes:
Exception in thread ptvsd.stopping (most likely raised during interpreter shutdown):
/EventInput