我正在尝试响应对Dialogflow的简单调用。
我去了V2文档,从字面上复制了他们的示例文本,仍然遇到问题。
Here is the response documentation
我有一个DialogflowController
带有创建操作:
def create
result = ChatService.formulate_response(params)
render json: { status: 200, data: result }, content_type: 'application/json'
end
在我的聊天服务中,我有一种可以建立响应的方法:
module ChatService
extend self
def formulate_response(params)
result = params['queryResult']
return sign_up_response if result['action'] == 'input.sign-up'
end
private
def sign_up_response
{
"fulfillmentText": "This is a text response",
"fulfillmentMessages": [
{
"card": {
"title": "card title",
"subtitle": "card text",
"imageUri": "https://assistant.google.com/static/images/molecule/Molecule-Formation-stop.png",
"buttons": [
{
"text": "button text",
"postback": "https://assistant.google.com/"
}
]
}
}
],
"source": "example.com",
"payload": {
"google": {
"expectUserResponse": true,
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": "this is a simple response"
}
}
]
}
},
"facebook": {
"text": "Hello, Facebook!"
},
"slack": {
"text": "This is a text response for Slack."
}
},
"outputContexts": [
{
"name": "projects/${PROJECT_ID}/agent/sessions/${SESSION_ID}/contexts/context name",
"lifespanCount": 5,
"parameters": {
"param": "param value"
}
}
],
"followupEventInput": {
"name": "event name",
"languageCode": "en-US",
"parameters": {
"param": "param value"
}
}
}
end
end
Dialogflow的履行响应正好显示了这一点,但fulfilment status
显示了:
Webhook call failed. Error: Failed to parse webhook JSON response: Cannot find field: status in message google.cloud.dialogflow.v2.WebhookResponse.
我正在回应一个Facebook集成,就像一个简单的文本回复。