Bot Framework V4不显示FB信使上的轮播图像

问题描述 投票:1回答:1

我正在使用Bitbucket的连续部署选项将我的Botframework v4代码部署到AZure。我正在使用英雄卡来显示一组带按钮的旋转木马。图像和按钮重定向是基于API调用的结果动态生成的。

旋转木马在Azure上的Web Chat和Botframework Emulator(本地)上都得到了完美的显示。但是当在azure上使用信使通道时,我无法显示旋转木马。服务器返回错误 -

对不起,看起来出了问题。 Microsoft.Bot.Schema.ErrorResponseException:Operation在Microsoft.Bot.Connector上的Microsoft.Bot.Connector.Conversations.ReplyToActivityWithHttpMessagesAsync(String conversationId,String activityId,Activity activity,Dictionary2 customHeaders,CancellationToken cancellationToken)返回了无效的状态代码'BadRequest'。在Microsoft.Bot.Builder.TurnContext上的Microsoft.Bot.Builder.BotFrameworkAdapter.SendActivitiesAsync(ITurnContext turnContext,Activity []活动,CancellationToken cancellationToken)上的ConversationsExtensions.ReplyToActivityAsync(IConversations操作,String conversationId,String activityId,Activity activity,CancellationToken cancellationToken)。

虽然我必须报告我能够轻松地将单个图像显示为附件。这些图像具有硬编码的URL链接,并且它们正在显示。但是当我使用具有动态按钮和链接的英雄卡时,我收到上述错误。我正在输入用于显示轮播的示例代码。

var client = new RestClient("https://XXXXXXXXXXXXXXXXXX/");
var request = new RestRequest($"api/Flights/carousel/summary?to={state.Destination}&from={state.Origin}&departDate={state.FlyDate}&returnDate=&adult=1&child=0&infant=0&queryType=1&roundTrip=FALSE&classOfTravel=Y&userName=Satadal", Method.GET);
var queryResult = client.Execute(request).Content;
CarouselMap CarouselResult = JsonConvert.DeserializeObject<CarouselMap>(queryResult);

if (CarouselResult.Status)
{
    // Create an attachment. Add the carousels to it.

    var activity1 = MessageFactory.Carousel(new Attachment[]
{
new HeroCard(
    title: "We are a travel agency trusted over 30 years, with 95 % positive customer reviews and A+ rating from BBB",
    images: new CardImage[] { new CardImage(url: CarouselResult.Data[0].ImageUrl.ToString())},
    buttons: new CardAction[]
    {
        new CardAction(title: "🤖 Chat with Bot ", type: ActionTypes.ImBack, value: "Book some flight tickets"),
        new CardAction(title: "☎️ Call Us 24/7", type: ActionTypes.Call, value: "+18888898005"),
        new CardAction(title: "✈️ Search Results ", type: ActionTypes.OpenUrl, value: CarouselResult.Data[0].ApiUrl.ToString())

    })
.ToAttachment(),
new HeroCard(
    title: "We are a travel agency trusted over 30 years, with 95 % positive customer reviews and A+ rating from BBB",
    images: new CardImage[] { new CardImage(url: CarouselResult.Data[1].ImageUrl.ToString()) },
    buttons: new CardAction[]
    {
       new CardAction(title: "🤖 Chat with Bot ", type: ActionTypes.ImBack, value: "Book some flight tickets"),
        new CardAction(title: "☎️ Call Us 24/7", type: ActionTypes.Call, value: "+18888898005"),
        new CardAction(title: "✈️ Search Results ", type: ActionTypes.OpenUrl, value: CarouselResult.Data[1].ApiUrl.ToString())
    })
.ToAttachment(),

new HeroCard(
    title: "We are a travel agency trusted over 30 years, with 95 % positive customer reviews and A+ rating from BBB",
    images: new CardImage[] { new CardImage(url: CarouselResult.Data[2].ImageUrl.ToString()) },
    buttons: new CardAction[]
    {
       new CardAction(title: "🤖 Chat with Bot ", type: ActionTypes.ImBack, value: "Book some flight tickets"),
        new CardAction(title: "☎️ Call Us 24/7", type: ActionTypes.Call, value: "+18888898005"),
        new CardAction(title: "✈️ Search Results ", type: ActionTypes.OpenUrl, value: CarouselResult.Data[2].ApiUrl.ToString())
    })
.ToAttachment()


});
    /////Printing carousels for One way trips here.

    await stepContext.Context.SendActivityAsync(activity1, cancellationToken: cancellationToken);

我究竟做错了什么?或者这些是否是关于Fb信使支持的问题?

facebook botframework facebook-messenger
1个回答
0
投票

不幸的是,Facebook频道不支持电话卡行动。将操作类型从Call更改为所有附件上的ImBack或OpenUrl应解决该错误。

希望这可以帮助!

© www.soinside.com 2019 - 2024. All rights reserved.