我正在制作一个聊天机器人应用程序,用于搜索航班。找到航班后,我将返回一个带有按钮的轮播,并希望用户在单击按钮后将其重定向到该网站。它起作用了,唯一的问题是单击按钮会将URL放入对话中。有什么方法可以打开URL而不进行对话吗?
我要发送到Viber REST API的JSON:
{
"type":"rich_media",
"min_api_version":6.8,
"receiver":"asmS1TwIYkPVxpod3rNCYg==",
"rich_media":{
"Type":"rich_media",
"ButtonsGroupColumns":6,
"ButtonsGroupRows":7,
"Buttons":[
{
"Columns":6,
"Rows":4,
"ActionType":"open-url",
"OpenURLType":"external",
"ActionBody":"http://localhost:60219/Booking?flightId=1&sessionid=3b0f51f5-cf88-4d1e-a64b-1222e19b4702&adults=1&children=0&infants=0",
"Text":"<b>Best Offer - 68.99 EUR</b><br />Bratislava to Nis on 18Oct at 14:10",
"Image":"http://localhost:60219/api/v1/FlightInfo/FlightDetail/Viber?flightId=1&returnFlightId=",
"TextVAlign":"bottom",
"TextHAlign":"center"
},
{
"Columns":6,
"Rows":1,
"ActionType":"open-url",
"OpenURLType":"external",
"ActionBody":"http://localhost:60219/Booking?flightId=1&sessionid=3b0f51f5-cf88-4d1e-a64b-1222e19b4702&adults=1&children=0&infants=0",
"Text":"DEMO booking",
"TextVAlign":"center",
"TextHAlign":"center"
},
{
"Columns":6,
"Rows":1,
"ActionType":"open-url",
"OpenURLType":"external",
"ActionBody":"https://www.ryanair.com/gb/en/booking/home/BTS/INI/2019-10-18//1/0/0/0",
"Text":"Book now",
"TextVAlign":"center",
"TextHAlign":"center"
},
{
"Columns":6,
"Rows":1,
"ActionType":"open-url",
"OpenURLType":"external",
"ActionBody":"http://localhost:60219/FlightDetail?flightid=1",
"Text":"Flight Details",
"TextVAlign":"center",
"TextHAlign":"center"
},
{
"Columns":6,
"Rows":4,
"ActionType":"open-url",
"OpenURLType":"external",
"ActionBody":"http://localhost:60219/PriceAlert?departureAirportId=ce43057e-afe6-4592-8759-9ea9643bb566&arrivalAirportId=3f43e185-bba3-4216-813d-473bfdbb024d",
"Text":"<b>Set the Price Alert for BTS-INI</b><br />We will notify you when the price will be below level set by you.",
"Image":"http://localhost:60219//content/images/price_alerts_default_image.jpg",
"TextVAlign":"bottom",
"TextHAlign":"center"
},
{
"Columns":6,
"Rows":3,
"ActionType":"open-url",
"OpenURLType":"external",
"ActionBody":"http://localhost:60219/PriceAlert?departureAirportId=ce43057e-afe6-4592-8759-9ea9643bb566&arrivalAirportId=3f43e185-bba3-4216-813d-473bfdbb024d",
"Text":"Set Price Alert ",
"TextVAlign":"center",
"TextHAlign":"center"
}
]
}
}
Run Code Online (Sandbox Code Playgroud)
\n\nRich Media 消息及其按钮的参数也用于键盘。您可以在以下文章中找到有关它们的更多信息。
\n
他们还提到,
\n\n\n按下键盘按钮将触发不同的回复,具体取决于按钮 \xe2\x80\x9cactionType\xe2\x80\x9d 值。
\n对于 ActionType open-url:
\n\n
\n- \n
ActionBody 的值作为文本消息发送到帐户(通过消息事件)。
\n- \n
ActionBody的值在浏览器中打开。
\n- \n
ActionBody 的值作为来自用户的消息显示在聊天线程中。
\n
似乎出现了第三个选项,而不是上面列表中的第二个选项。
\n