使用输出上下文响应来操纵特定上下文

问题描述 投票:0回答:1

我目前正在尝试使用webhook响应来更改我的上下文之一的特定值,并且根据我的found,以下应能起作用:

       {
            "fulfillmentText": ${textToSpeech},
            "fulfillmentMessages": [{ "text": { "text": [${text}] } }],
            "payload": {
                "google": {
                    "expectUserResponse": true,
                    "richResponse": {
                        "items": [
                            {
                                "simpleResponse": {
                                    "textToSpeech": ${textToSpeech},
                                    "displayText": ${text}
                                }
                            }
                        ],
                        "suggestions": ${suggestions},
                        "linkOutSuggestion": {
                            "destinationName": "Feedback",
                            "url": ${feedbackURL}
                        }
                    }
                }
            },
            "outputContexts": [
                {
                  "name": "projects/${projectID}/agent/sessions/${conversationID}/contexts/${context}",
                  "lifespanCount": 15,
                  "parameters": { 
                    "param":"value"
                   }
                }]
        }

但是,这不会更改在该上下文中指定的任何参数。我是在做错什么,还是有更好的方法使用webhook响应来更改输出上下文的参数?

dialogflow actions-on-google dialogflow-fulfillment
1个回答
0
投票

您可能要检查传入上下文的命名方式。

名称可以有either of the following formats

  • projects/<Project ID>/agent/sessions/<Session ID>/contexts/<Context ID>
  • projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>/contexts/<Context ID>

如果上下文使用第二种格式(包括环境和用户ID),那么您需要创建名称相似的上下文。

具体来说,您/contexts/<Context ID>之前的部分应与WebhookRequest中提供的完整会话字符串匹配,您猜到它与以下两种模式之一匹配:

  • projects/<Project ID>/agent/sessions/<Session ID>
  • projects/<Project ID>/agent/environments/<Environment ID>/users/<User ID>/sessions/<Session ID>
© www.soinside.com 2019 - 2024. All rights reserved.