Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 谷歌正确回应行动_C#_Asp.net Core_Dialogflow Es_Actions On Google - Fatal编程技术网

C# 谷歌正确回应行动

C# 谷歌正确回应行动,c#,asp.net-core,dialogflow-es,actions-on-google,C#,Asp.net Core,Dialogflow Es,Actions On Google,我的C#web API已成功收到来自我在google对话流上的操作的请求。但我在理解响应格式时遇到了一些问题 { "responseId": "96ee6c11-8f73-409f-8dac-8b6141d08483", "queryResult": { "queryText": "History", "action": &quo

我的C#web API已成功收到来自我在google对话流上的操作的请求。但我在理解响应格式时遇到了一些问题

{
    "responseId": "96ee6c11-8f73-409f-8dac-8b6141d08483",
    "queryResult": {
        "queryText": "History",
        "action": "tell.fact",
        "parameters": {
            "category": "history"
        },
        "allRequiredParamsPresent": true,
        "fulfillmentMessages": [
            {
                "text": {
                    "text": [
                        ""
                    ]
                }
            }
        ],
        "outputContexts": [
            {
                "name": "projects/project--6162817918903295576/agent/sessions/1530877719318/contexts/google_assistant_input_type_touch",
                "parameters": {
                    "category.original": "History",
                    "category": "history"
                }
            },
            {
                "name": "projects/project--6162817918903295576/agent/sessions/1530877719318/contexts/actions_capability_screen_output",
                "parameters": {
                    "category.original": "History",
                    "category": "history"
                }
            },
            {
                "name": "projects/project--6162817918903295576/agent/sessions/1530877719318/contexts/choose_fact-followup",
                "lifespanCount": 2,
                "parameters": {
                    "category.original": "History",
                    "category": "history"
                }
            },
            {
                "name": "projects/project--6162817918903295576/agent/sessions/1530877719318/contexts/actions_capability_audio_output",
                "parameters": {
                    "category.original": "History",
                    "category": "history"
                }
            },
            {
                "name": "projects/project--6162817918903295576/agent/sessions/1530877719318/contexts/actions_capability_media_response_audio",
                "parameters": {
                    "category.original": "History",
                    "category": "history"
                }
            },
            {
                "name": "projects/project--6162817918903295576/agent/sessions/1530877719318/contexts/actions_capability_web_browser",
                "parameters": {
                    "category.original": "History",
                    "category": "history"
                }
            }
        ],
        "intent": {
            "name": "projects/project--6162817918903295576/agent/intents/4a35cf33-e446-4b2b-a284-c70bc4dfce17",
            "displayName": "choose_fact"
        },
        "intentDetectionConfidence": 1,
        "languageCode": "en-us"
    },
    "originalDetectIntentRequest": {
        "source": "google",
        "version": "2",
        "payload": {
            "isInSandbox": true,
            "surface": {
                "capabilities": [
                    {
                        "name": "actions.capability.AUDIO_OUTPUT"
                    },
                    {
                        "name": "actions.capability.SCREEN_OUTPUT"
                    },
                    {
                        "name": "actions.capability.MEDIA_RESPONSE_AUDIO"
                    },
                    {
                        "name": "actions.capability.WEB_BROWSER"
                    }
                ]
            },
            "requestType": "SIMULATOR",
            "inputs": [
                {
                    "rawInputs": [
                        {
                            "query": "History",
                            "inputType": "TOUCH"
                        }
                    ],
                    "arguments": [
                        {
                            "rawText": "History",
                            "textValue": "History",
                            "name": "text"
                        }
                    ],
                    "intent": "actions.intent.TEXT"
                }
            ],
            "user": {
                "lastSeen": "2018-07-06T11:44:24Z",
                "locale": "en-US",
                "userId": "AETml1TDDPgKmK2GqQ9ugHJc5hQM"
            },
            "conversation": {
                "conversationId": "1530877719318",
                "type": "ACTIVE",
                "conversationToken": "[]"
            },
            "availableSurfaces": [
                {
                    "capabilities": [
                        {
                            "name": "actions.capability.AUDIO_OUTPUT"
                        },
                        {
                            "name": "actions.capability.SCREEN_OUTPUT"
                        },
                        {
                            "name": "actions.capability.WEB_BROWSER"
                        }
                    ]
                }
            ]
        }
    },
    "session": "projects/project--6162817918903295576/agent/sessions/1530877719318"
}
试一试 文档说明我的回答应该是这样的

{"fulfillmentText":"Hello from C# v2","fulfillmentMessages":[{"card":{"title":"card title","subtitle":"sub title","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":"Thi sis a simple response "}}]}},"facebook":{"text":"Hello facebook"},"slack":{"text":"Hello facebook"}},"outputContexts":[{"name":"projects/project--6162817918903295576/agent/sessions/2a210c67-4355-d565-de81-4d3ee7439e67","lifespanCount":5,"parameters":{"param":"parm value"}}],"followupEventInput":{"name":"event name","languageCode":"en-Us","parameters":{"param":"parm value"}}}
这将导致以下错误

必须设置格式错误的响应“最终响应”

由于语音响应为空,无法将Dialogflow响应解析为AppResponse

尝试2 所以我继续尝试

这也导致了

必须设置格式错误的响应“最终响应”

由于语音响应为空,无法将Dialogflow响应解析为AppResponse

我可以验证我的请求是否以
application/json


有人知道正确的响应格式吗?

以下是JSON响应格式:

根本问题实际上是ASP.NET内核默认使用传输编码:chunked for ActionResult,由于某些原因Dialogflow不支持解析分块传输

actions接受以下响应

[HttpPost]

public ContentResult Post([FromBody] FulfillmentRequst data)
    {

        var response = new FulfillmentResponse
        {
            fulfillmentText = "Hello from C# v2",
            };

        return Content(JsonConvert.SerializeObject(response), "application/json");
    }

我想是你联系的那个
[HttpPost]

public ContentResult Post([FromBody] FulfillmentRequst data)
    {

        var response = new FulfillmentResponse
        {
            fulfillmentText = "Hello from C# v2",
            };

        return Content(JsonConvert.SerializeObject(response), "application/json");
    }