具有多个 actions_intent_OPTION 处理程序的 Google Assistant 流程

2024-02-28

我通过 Dialogflow 配置了 webhooks模板聊天机器人 UI 入门项目 https://github.com/ianrichard/common-chatbot-ui-starter-project我正在 Github 上制作。我有一个通过 Facebook Messenger 和 Google Assistant 集成的机器人。 Facebook 的所有功能都运行良好,因为这些操作会返回字符串并且很容易处理。但是,当 Google Assistant 尝试处理“@type”:“type.googleapis.com/google.actions.v2.OptionValueSpec”的项目时,Dialogflow 中的事件需要 actions_intent_OPTION 来处理响应。如果我的应用程序中只有一个,它可以正常工作,但是当我添加 OptionValueSpec 类型的第二个列表项/轮播项时,流程就会阻塞。我有附图的详细信息。我的猜测是需要 actions_intent_OPTION 来处理列表,但是当我将其放在事件部分的多个意图上时,流程不知道如何处理它。

Facebook Messenger(正常)与 Google Assistant(有错误)的比较

Google Assistant详细全流程视图

发送到 Dialogflow 的响应随后会发送到 Google Actions...

与上面的 UI 图片相关的确切响应。

// working as expected

{
  "richResponse": {
    "items": [{
        "simpleResponse": {
          "textToSpeech": "Hey there! This is a guided tour of common components between Facebook Messenger and Google Assistant."
        }
      },
      {
        "simpleResponse": {
          "textToSpeech": "You can start coding the sample project at github.com/ianrichard."
        }
      }
    ],
    "suggestions": [{
        "title": "Show me demos!"
      },
      {
        "title": "Show code & docs"
      }
    ]
  }
}

// working as expected

{
  "richResponse": {
    "items": [{
        "simpleResponse": {
          "textToSpeech": "Animated GIFs are always fun to add to the mix!"
        }
      },
      {
        "basicCard": {
          "image": {
            "url": "https://somewebsite.com/colbert.gif",
            "accessibilityText": "Stephen Colbert at the beginning of the show being happy."
          }
        }
      }
    ],
    "suggestions": [{
      "title": "What about a card?"
    }]
  }
}

// working as expected

{
  "richResponse": {
    "items": [{
        "simpleResponse": {
          "textToSpeech": "Absolutely!"
        }
      },
      {
        "simpleResponse": {
          "textToSpeech": "Named for a winding stretch of Hill Country highway, Devil’s Backbone is a Belgian-style tripel. Featuring a beautiful pale-golden color, this ale’s spicy hops and Belgian yeast work together to create a distinctive flavor and aroma. Don’t let the light color fool you, this one has a dark side too. Traditional Belgian brewing techniques add strength without increasing heaviness."
        }
      },
      {
        "basicCard": {
          "image": {
            "url": "https://somewebsite.com/devils-backbone.jpg",
            "accessibilityText": "Devil’s Backbone"
          },
          "title": "Devil’s Backbone",
          "subtitle": "Belgian-Style Tripel",
          "buttons": [{
            "title": "Read More",
            "openUrlAction": {
              "url": "https://realalebrewing.com/beers/devils-backbone/"
            }
          }]
        }
      }
    ],
    "suggestions": [{
      "title": "How about a list?"
    }]
  }
}

// working as expected

{
  "richResponse": {
    "items": [{
        "simpleResponse": {
          "textToSpeech": "Absolutely!"
        }
      },
      {
        "simpleResponse": {
          "textToSpeech": "Who’s your favorite GOT character!?"
        }
      }
    ]
  },
  "systemIntent": {
    "intent": "actions.intent.OPTION",
    "data": {
      "@type": "type.googleapis.com/google.actions.v2.OptionValueSpec",
      "listSelect": {
        "items": [{
            "optionInfo": {
              "key": "tyrion"
            },
            "title": "Tyrion Lannister",
            "description": "Peter Dinklage",
            "image": {
              "url": "https://somewebsite.com/got-tyrion.jpg",
              "accessibilityText": "Tyrion Lannister"
            }
          },
          {
            "optionInfo": {
              "key": "daene"
            },
            "title": "Daenerys Targaryen",
            "description": "Emilia Clarke",
            "image": {
              "url": "https://somewebsite.com/got-daenerys.jpg",
              "accessibilityText": "Daenerys Targaryen"
            }
          },
          {
            "optionInfo": {
              "key": "jon"
            },
            "title": "Jon Snow",
            "description": "Kit Harington",
            "image": {
              "url": "https://somewebsite.com/got-jon.jpg",
              "accessibilityText": "Jon Snow"
            }
          }
        ]
      }
    }
  }
}

// if two events with the same actions_intent_OPTION are defined, it goes straight to the end and the list option handler is never invoked

{
  "richResponse": {
    "items": [{
        "simpleResponse": {
          "textToSpeech": "The end"
        }
      },
      {
        "simpleResponse": {
          "textToSpeech": "Well, that’s the end of the demo.  Hope you enjoyed!"
        }
      }
    ],
    "suggestions": [{
      "title": "Start over"
    }]
  }
}

// otherwise, it will show the last carousel


{
  "richResponse": {
    "items": [{
        "simpleResponse": {
          "textToSpeech": "I drink and I know things!"
        }
      },
      {
        "simpleResponse": {
          "textToSpeech": "What are you going to buy your wife from Tiffany?"
        }
      }
    ]
  },
  "systemIntent": {
    "intent": "actions.intent.OPTION",
    "data": {
      "@type": "type.googleapis.com/google.actions.v2.OptionValueSpec",
      "carouselSelect": {
        "items": [{
            "optionInfo": {
              "key": "sunglasses"
            },
            "title": "Aviator Sunglasses",
            "description": "$360",
            "image": {
              "url": "https://somewebsite.com/tiffany-glasses.jpg",
              "accessibilityText": "Aviator Sunglasses"
            }
          },
          {
            "optionInfo": {
              "key": "ring"
            },
            "title": "Infinity Ring",
            "description": "$200",
            "image": {
              "url": "https://somewebsite.com/tiffany-ring.jpg",
              "accessibilityText": "Infinity Ring"
            }
          },
          {
            "optionInfo": {
              "key": "earrings"
            },
            "title": "Soleste Earrings",
            "description": "$5,600",
            "image": {
              "url": "https://somewebsite.com/tiffany-earrings.jpg",
              "accessibilityText": "Soleste Earrings"
            }
          },
          {
            "optionInfo": {
              "key": "pendant"
            },
            "title": "Infinity Pendant",
            "description": "$250",
            "image": {
              "url": "https://somewebsite.com/tiffany-necklace.jpg",
              "accessibilityText": "Infinity Pendant"
            }
          },
          {
            "optionInfo": {
              "key": "watch"
            },
            "title": "East West Mini",
            "description": "$7,500",
            "image": {
              "url": "https://somewebsite.com/tiffany-watch.jpg",
              "accessibilityText": "East West Mini"
            }
          }
        ]
      }
    }
  }
}

// but the carousel option handler isn't processed correctly :( - keeps repeating this same thing.

{
  "richResponse": {
    "items": [{
        "simpleResponse": {
          "textToSpeech": "What!? None of them?"
        }
      },
      {
        "simpleResponse": {
          "textToSpeech": "What are you going to buy your wife from Tiffany?"
        }
      }
    ]
  },
  "systemIntent": {
    "intent": "actions.intent.OPTION",
    "data": {
      "@type": "type.googleapis.com/google.actions.v2.OptionValueSpec",
      "carouselSelect": {
        "items": [{
            "optionInfo": {
              "key": "sunglasses"
            },
            "title": "Aviator Sunglasses",
            "description": "$360",
            "image": {
              "url": "https://somewebsite.com/tiffany-glasses.jpg",
              "accessibilityText": "Aviator Sunglasses"
            }
          },
          {
            "optionInfo": {
              "key": "ring"
            },
            "title": "Infinity Ring",
            "description": "$200",
            "image": {
              "url": "https://somewebsite.com/tiffany-ring.jpg",
              "accessibilityText": "Infinity Ring"
            }
          },
          {
            "optionInfo": {
              "key": "earrings"
            },
            "title": "Soleste Earrings",
            "description": "$5,600",
            "image": {
              "url": "https://somewebsite.com/tiffany-earrings.jpg",
              "accessibilityText": "Soleste Earrings"
            }
          },
          {
            "optionInfo": {
              "key": "pendant"
            },
            "title": "Infinity Pendant",
            "description": "$250",
            "image": {
              "url": "https://somewebsite.com/tiffany-necklace.jpg",
              "accessibilityText": "Infinity Pendant"
            }
          },
          {
            "optionInfo": {
              "key": "watch"
            },
            "title": "East West Mini",
            "description": "$7,500",
            "image": {
              "url": "https://somewebsite.com/tiffany-watch.jpg",
              "accessibilityText": "East West Mini"
            }
          }
        ]
      }
    }
  }
}

Intent Referencesenter image description here


终于成功了!谢谢@囚犯!

在对话框流中...

  1. 第一个列表,定义输出上下文
  2. 第二个列表,定义输入上下文和输出上下文
  3. 第二个列表之后的问题,定义输入上下文

在您的网络钩子中...

(让它发挥作用的拼图中缺失的一块) 设置列表选项的输出上下文

{
    "speech": "",
    "displayText": "",
    "data": { "google": { ... } },
    "contextOut": [
        {
            "name": "carouselExample",
            "lifespan": 0,
            "parameters": null
        }
    ]
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

具有多个 actions_intent_OPTION 处理程序的 Google Assistant 流程 的相关文章

随机推荐