首页 文章

具有多个actions_intent_OPTION处理程序的Google智能助理流程

提问于
浏览
1

我通过Dialogflow配置了webhooks,以便轻松处理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' . 但是当Google智能助理尝试处理"@type":"type.googleapis.com/google.actions.v2.OptionValueSpec"的项目时,需要在Dialogflow中的事件上执行actions_intent_OPTION来处理响应 . 如果我的应用程序中只有一个,它工作正常,但是当我添加OptionValueSpec类型的第二个列表项/ carousel项时,流程会阻塞 . 我有附加图像的详细信息 . 我的猜测是需要actions_intent_OPTION来处理列表,但是当我把它放在事件部分的多个意图上时,流程不知道如何处理它 .

Facebook Messenger(工作)与Google智能助理的比较(有bug)

enter image description here

Google智能助理的详细完整流程视图

enter image description here

发送给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"
            }
          }
        ]
      }
    }
  }
}

意图参考

2 回答

  • 1

    最终有效!谢谢@Prisoner!

    在Dialogflow中......

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

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

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

    在你的webhook中......

    (使其成功的拼图的缺失部分)设置列表选项的输出上下文

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

    从广义上讲,问题是Dialogflow在获得 action_intent_OPTION 事件时不知道您在对话中的位置 . 对于那个事件,它不会尝试进行实体匹配,但是会话上下文的问题通常是一个问题(例如,如果你有两个不同的选项轮播有重叠的答案会发生什么?) .

    解决方案有两个方面:

    • 当您发回包含选项信息的响应时,还应设置传出上下文 . 您可以在此上下文中包含其他信息,但在您的情况下,听起来就像您只想跟踪您在对话中的位置 .

    • 然后,您可以通过指定每个应触发的上下文来区分两个Intent和option事件 . Dialogflow将匹配事件和上下文,以确定要使用的最佳Intent .

相关问题