具有多个action_intent_OPTION处理程序的Google Assistant流 [英] Google Assistant flow with multiple actions_intent_OPTION handlers

查看:32
本文介绍了具有多个action_intent_OPTION处理程序的Google Assistant流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过Dialogflow为



详细的Google Assistant完整视图





发送给Dialogflow的响应,随后又发送给Google Actions ...



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



  //可以按预期运行{ richResponse:{ items:[{ simpleResponse:{ textToSpeech:嘿!这是Facebook Messenger和Google Assistant之间常见组件的导览。}},{ simpleResponse:{ textToSpeech:您可以在github.com/ianrichard上开始对示例项目进行编码。}},建议:[{ title: Show me demos!},{ title:显示代码& docs}]}} //可以按预期工作{{richResponse:{ items:[{ simpleResponse:{ textToSpeech:动画GIF添加到混合中总是很有趣!}},{ basicCard:{ image:{ url: https://somewebsite.com/colbert.gif, accessibilityText:在节目开始时斯蒂芬·科尔伯特很高兴。}}}],建议:[{标题:卡片怎么样?}]}} //可以按预期工作{ richResponse:{ items:[{ simpleResponse:{ textToSpeech:绝对! }},{ simpleResponse:{ textToSpeech:魔鬼的骨干(Devil's Backbone)是比利时风格的三脚架,以蜿蜒的希尔乡村公路而得名。淡啤酒的麻辣啤酒花和比利时酵母具有美丽的浅金色,共同创造出独特的风味和香气。不要让浅色欺骗您,这也有黑暗的一面。传统的比利时酿造技术可增加强度而不会增加重量。}},{ 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/}}]}}]],建议:[{ title:列表如何?}]}} ///按预期工作{ richResponse:{ items:[{ simpleResponse:{ textToSpeech:绝对!}},{ simpleResponse:{ textToSpeech:谁是您最喜欢的GOT角色!?}}}},  systemIntent:{ intent: actions.intent.OPTION, data:{ @type: type.googleapis.com/goo gle.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 }}]}}}} //如果定义了两个具有相同actions_intent_OPTION的事件,它将直接结束,并且永远不会调用列表选项处理程序{ richResponse:{ items:[{ simpleResponse:{  textToSpeech:结束}},{ simpleResponse:{ textToSpeech:好,演示到此结束。希望您喜欢!}}],建议:[{ title:重新开始}]}} //否则,它将显示最后一个轮播{{richResponse:{ items:[{ simpleResponse:{ textToSpeech:我喝着酒,我知道!}},{ simpleResponse:{ textToSpeech:您打算从蒂凡尼那里购买妻子吗?}}]}, systemIntent :{意图: actions.intent.OPTION,数据:{ @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:飞行员太阳镜}},{ optionInfo:{ key: ring},  title: Infinity Ring, description: $ 200, image:{ url: https://somewebsite.com/tiffany-ring.jpg, accessibilityText: Infinity Ring }},{ optionInfo:{ key:耳环}, title: Soleste耳环, description: $ 5,600, image:{ url: https:// somewebsite .com / tiffany-earrings.jpg, accessibilityText: Soleste耳环}},{ optionInfo:{ key:坠饰}, title: Infinity坠饰, 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}}]}}}} / /,但轮播选项处理程序未正确处理:(--重复此操作。{ richResponse:{ items:[{ simpleResponse:{ textToSpeech:什么!?它们都不是吗?}},{ simpleResponse:{ textToSpeech:您打算从蒂凡尼那里购买妻子吗?}}]}, systemIntent:{ intent: actions.intent。 OPTION,数据:{ @type: type.googleapis.com/google.actions.v2.OptionValueSpec, carouselSelect:{ items:[{ optionInfo:{ key:太阳眼镜},标题:飞行员太阳镜,说明: $ 360,图像:{ url: https://somewebsite.com/tiffany-glasses.jpg, accessibilityText: 飞行员太阳镜}},{ optionInfo:{ key: ring}, title: Infinity Ring, description: $ 200, image:{ url: https ://somewebsite.com/tiffany-ring.jpg, accessibilityText:无限环}},{  optionInfo:{键:耳环}, title: Soleste耳环, description: $ 5,600, image:{ url: https://somewebsite.com/tiffany -earrings.jpg, accessibilityText: Soleste耳环}},{ optionInfo:{ key:链坠}, title:无限链坠,描述: $ 250,图片:{ url: https://somewebsite.com/tiffany-necklace.jpg, accessibilityText:无限吊坠}},{ optionInfo:{ key: watch},  title: East West Mini, description: $ 7,500, image:{ url: https://somewebsite.com/tiffany-watch.jpg, accessibilityText: East West迷你}}}}}}}  



意图引用


解决方案

最终有效!谢谢@Prisoner!



在Dialogflow中...




  1. 第一个列表,定义输出上下文

  2. 第二个列表,定义输入上下文和输出上下文

  3. 第二个列表后的问题,定义输入上下文



在您的网络钩子中...



(使之起作用的难题的缺失部分)
设置列表选项的输出上下文

  {
speech:,
displayText:,
数据:{ google:{...}},
contextOut:[
{
name: carouselExample ,
寿命:0,
参数:空
}
]
}


I have webhooks configured through Dialogflow for a template chatbot UI starter project I'm making on Github. I have a bot integrated through Facebook Messenger and Google Assistant. All of Facebook works fine because the actions send back strings and it's easy to handle. But when Google Assistant tries to handle items of "@type": "type.googleapis.com/google.actions.v2.OptionValueSpec", actions_intent_OPTION is needed on the event in Dialogflow to handle the response. If I have just one in my app, it works fine, but when I add a second list item / carousel item of type OptionValueSpec, the flow chokes. I have details on the attached image. My guess is actions_intent_OPTION is needed to handle the list, but when I put that on multiple intents on the events section, the flow doesn't know how to handle it.

Comparison of Facebook Messenger (working) to Google Assistant (with bug)

Detailed full flow view of Google Assistant

Responses sent to Dialogflow that subsequently get sent to Google Actions...

Exact responses related to the UI pics above.

// 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 References

解决方案

FINALLY works! Thanks @Prisoner!

In Dialogflow...

  1. First list, define the output context
  2. Second list, define the input context and output context
  3. Question after the second list, define the input context

In your webhook...

(The missing piece of the puzzle that made it work) Set the output context for the list options

{
    "speech": "",
    "displayText": "",
    "data": { "google": { ... } },
    "contextOut": [
        {
            "name": "carouselExample",
            "lifespan": 0,
            "parameters": null
        }
    ]
}

这篇关于具有多个action_intent_OPTION处理程序的Google Assistant流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆