Dialogflow无法解释地失去上下文

时间:2018-11-30 17:52:46

标签: dialogflow

我不知道我的机器人会发生什么,在对话过程中的某个时刻,它失去了一些上下文变量。

在以下屏幕截图中,您可以看到变量schoolcampus为空。这很奇怪,因为该机器人所做的回复是

  

Voici les bourse负责人倒入IDRAC Paris

其中IDRACschool变量,而Pariscampus。 我不明白该漫游器如何既可以显示正确的值(之前由不同的Intent设置),又没有设置值。

enter image description here

这是诊断信息

{
  "responseId": "759621b6-58cc-417e-a635-46df7627d279",
  "queryResult": {
    "queryText": "bourses",
    "parameters": {
      "type": "Bourses",
      "school": "",
      "campus": ""
    },
    "allRequiredParamsPresent": true,
    "fulfillmentText": "Voici les Bourses disponibles pour IDRAC Paris",
    "fulfillmentMessages": [
      {
        "text": {
          "text": [
            "Voici les Bourses disponibles pour IDRAC Paris"
          ]
        }
      },
      {
        "text": {
          "text": [
            "Vous pouvez me demander des détails sur celles qui vous intéressent"
          ]
        }
      }
    ],
    "outputContexts": [
      {
        "name": "projects/hep-playground/agent/sessions/f69b9423-25d0-bc30-bfff-5f71da18f62d/contexts/school_campus_set",
        "lifespanCount": 249,
        "parameters": {
          "school.original": "",
          "type": "Bourses",
          "school": "",
          "type.original": "bourses",
          "campus.original": "",
          "campus": ""
        }
      },
      {
        "name": "projects/hep-playground/agent/sessions/f69b9423-25d0-bc30-bfff-5f71da18f62d/contexts/awaiting_solution_id",
        "lifespanCount": 1,
        "parameters": {
          "school.original": "",
          "type": "Bourses",
          "school": "",
          "campus.original": "",
          "type.original": "bourses",
          "campus": ""
        }
      },
      {
        "name": "projects/hep-playground/agent/sessions/f69b9423-25d0-bc30-bfff-5f71da18f62d/contexts/awaiting_campus",
        "lifespanCount": 1,
        "parameters": {
          "type": "Bourses",
          "school": "",
          "campus.original": "",
          "type.original": "bourses",
          "campus": "",
          "school.original": ""
        }
      },
      {
        "name": "projects/hep-playground/agent/sessions/f69b9423-25d0-bc30-bfff-5f71da18f62d/contexts/current_session",
        "lifespanCount": 250,
        "parameters": {
          "type": "Bourses",
          "school": "",
          "campus.original": "",
          "type.original": "bourses",
          "campus": "",
          "school.original": ""
        }
      },
      {
        "name": "projects/hep-playground/agent/sessions/f69b9423-25d0-bc30-bfff-5f71da18f62d/contexts/type_set",
        "lifespanCount": 15,
        "parameters": {
          "type": "Bourses",
          "school": "",
          "campus.original": "",
          "type.original": "bourses",
          "campus": "",
          "school.original": ""
        }
      },
      {
        "name": "projects/hep-playground/agent/sessions/f69b9423-25d0-bc30-bfff-5f71da18f62d/contexts/school_set",
        "lifespanCount": 23,
        "parameters": {
          "type": "Bourses",
          "school": "",
          "campus.original": "",
          "type.original": "bourses",
          "campus": "",
          "school.original": ""
        }
      }
    ],
    "intent": {
      "name": "projects/hep-playground/agent/intents/e3236893-676e-4e53-8c87-5b1aa974411e",
      "displayName": "UserSetsType"
    },
    "intentDetectionConfidence": 1,
    "languageCode": "fr"
  }
}

我不明白为什么在每种情况下都一遍又一遍地重复相同的键,这没有道理。

我们试图将current_session作为每个意图的输出,希望它可以使上下文以某种方式保持活动状态(遵循本指南:https://miningbusinessdata.com/better-dialogflow-bots-part-4-session-variables/

该机器人的更多配置:

enter image description here enter image description here

1 个答案:

答案 0 :(得分:1)

问题在于您的UserSetsType意向定义了所有三个参数。如果用户没有说任何可以填满它们的参数,则schoolcampus参数为空字符串,并且您的大多数响应都没有包含填入它们的方式。

所有活动上下文(均在GUI中指定并由您定义)会捕获为触发的Intent定义的参数,即使用户未填写也是如此。它们用空字符串填充,表明它们没有特别填充,即使它们以前有值,也表明您正在尝试从特定的Intent中获取值,将它们替换为空字符串,表明您没有不能从那个意向中获得它们。

因此,即使在先前的Intent中设置了schoolcampus。您在UserSetsType意向中指定了它们的事实意味着这些值将被与那个意向匹配的任何值替换,并且这些新值将被放入current_session上下文中。

虽然您处于正确的状态,可以在Context中存储累积状态,但是,如果您有可能由多个Intent指定的参数,则应该将它们添加到该会话Context中,且使用不同的参数名称(非-冲突。 (因此,您可以将school映射到savedSchool。)