I'm currently programming with the dialogflow library for python, but when I get the list of parameters I get from an attempt, it returns me a Struct object that I don't know how to read.
fields {
key: "apellido1"
value {
string_value: "Baena"
}
}
fields {
key: "apellido2"
value {
string_value: "P\303\251rez"
}
}
fields {
key: "nombre"
value {
string_value: "Rub\303\251n"
}
}
the documentation of the dialogflow library is very limited and there are no examples.
The best I can guess is that Struct is from the following route
google.protobuf.struct_pb2
Thank you very much for your help
There are Dialogflow samples up on Github, the following are the Python-related samples: weather sample using WWO API and a translation sample . In general though, the Dialogflow documentation discusses how to access parameters off an intent. A snippet from the weather sample below:
import json
from flask import Flask, request, make_response, jsonify
app = Flask(__name__)
log = app.logger
@app.route('/', methods=['POST'])
def webhook():
req = request.get_json(silent=True, force=True)
try:
action = req.get('queryResult').get('action')
except AttributeError:
return 'json error'
if action == 'weather':
res = weather(req)
elif action == 'weather.activity':
res = weather_activity(req)
elif action == 'weather.condition':
res = weather_condition(req)
elif action == 'weather.outfit':
res = weather_outfit(req)
elif action == 'weather.temperature':
res = weather_temperature(req)
else:
log.error('Unexpected action.')
print('Action: ' + action)
print('Response: ' + res)
return make_response(jsonify({'fulfillmentText': res}))
def weather(req):
parameters = req['queryResult']['parameters']
print('Dialogflow Parameters:')
print(json.dumps(parameters, indent=4))
.....
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.