首页 文章

Dialogflow未检测到上下文的意图

提问于
浏览
1

我将Dialogflow REST API v2beta1连接到方法: projects.agent.sessions.detectIntent . 在第一个请求中,我发送一个文本,响应返回包含 outputContexts 的预期结果;当我发出第二个请求时,我发送了上下文,它应该找到与该上下文相关联的intent,但不是这样,它返回Default Fallback Intent .

第二次请求可能出现什么问题?

以下是URL和请求及其各自的响应,下面我添加了预期匹配的意图的屏幕截图 .

URL https://dialogflow.googleapis.com/v2beta1/projects/project-name/agent/sessions/12343:detectIntent

1st request

{
    "queryInput":{
        "text":{
            "text":"play a video about love",
            "languageCode":"en"
        }
    }
}

1st response

{
    "responseId": "15a3b767-52fe-4fc2-8ffd-9d7bb9c6961a",
    "queryResult": {
        "queryText": "play a video about love",
        "action": "video.play",
        "parameters": {
            "organization": "",
            "tag": "Love",
            "item": ""
        },
        "allRequiredParamsPresent": true,
        "fulfillmentText": "Here is a video about Love!",
        "fulfillmentMessages": [
            {
                "platform": "ACTIONS_ON_GOOGLE",
                "simpleResponses": {
                    "simpleResponses": [
                        {
                            "textToSpeech": "Here is a video about Love!"
                        }
                    ]
                }
            },
            {
                "text": {
                    "text": [
                        "Here is a video about Love!"
                    ]
                }
            }
        ],
        "outputContexts": [
            {
                "name": "projects/project-name/agent/sessions/12343/contexts/play-video",
                "lifespanCount": 5,
                "parameters": {
                    "tag": "Love",
                    "organization": "",
                    "tag.original": "love",
                    "item": "",
                    "organization.original": "",
                    "item.original": ""
                }
            }
        ],
        "intent": {
            "name": "projects/project-name/agent/intents/9e5d2bbc-81f3-4700-8740-01504b05443f",
            "displayName": "video-play"
        },
        "intentDetectionConfidence": 1,
        "languageCode": "en"
    }
}

2nd request (where the problem should be)

{
    "queryParams":{
        "contexts":[
            {
                "name":"projects/project-name/agent/sessions/12342/contexts/play-video"
            }
        ]
    },
    "queryInput":{
        "text":{
            "text":"that video matters a lot for me",
            "languageCode":"en"
        }
    }
}

2nd response

{
    "responseId": "40d1f94f-4673-4644-aa53-99c854ff2596",
    "queryResult": {
        "queryText": "that video matters a lot for me",
        "action": "input.unknown",
        "parameters": {},
        "allRequiredParamsPresent": true,
        "fulfillmentText": "Can you say that again?",
        "fulfillmentMessages": [
            {
                "text": {
                    "text": [
                        "Sorry, what was that?"
                    ]
                }
            }
        ],
        "intent": {
            "name": "projects/project-name/agent/intents/10c88e8d-f16a-4905-b829-f596d3b3c588",
            "displayName": "Default Fallback Intent",
            "isFallback": true
        },
        "intentDetectionConfidence": 1,
        "languageCode": "en"
    }
}

Screenshots of the intents expected to match

第一意图
enter image description here

第二意图
enter image description here

Useful documentation

1 回答

  • 2

    看起来您的第二个请求具有不完整的上下文 . 虽然您指定的是 name ,但您不包含 lifespanCount 参数 . 由于您未提供参数,因此默认为0,这意味着它已超时 .

    您应该准确地发回您在上一个回复中从 outputContext 属性收到的内容 .

    {
        "queryParams":{
            "contexts":[
                {
                    "name": "projects/project-name/agent/sessions/12343/contexts/play-video",
                    "lifespanCount": 5,
                    "parameters": {
                        "tag": "Love",
                        "organization": "",
                        "tag.original": "love",
                        "item": "",
                        "organization.original": "",
                        "item.original": ""
                    }
                }
            ]
        },
        "queryInput":{
            "text":{
                "text":"that video matters a lot for me",
                "languageCode":"en"
            }
        }
    }
    

相关问题