BotFramework V4无法在FB Messenger上显示轮播图片

时间:2019-03-11 13:43:50

标签: facebook botframework facebook-messenger

我正在通过Bitbucket使用连续部署选项将Botframework v4代码部署到AZure。我正在使用英雄卡来显示一组带有按钮的轮播。图像和按钮重定向是根据API调用的结果动态生成的。

轮播已完美地显示在Azure上的Web聊天和Botframework Emulator(本地)上。但是在天蓝色上使用Messenger通道时,我无法显示轮播。服务器返回错误-

  

对不起,看来好像出了点问题。 Microsoft.Bot.Schema.ErrorResponseException:操作在Microsoft.Bot.Connector返回了无效的状态码“ BadRequest”,该状态码在Microsoft.Bot.Connector.Conversations.ReplyToActivityWithHttpMessagesAsync(String sessionId,String activityId,Activity activity,Dictionary2 customHeaders,CancellationToken cancelleToken)。 Microsoft.Bot.Builder.BotFrameworkAdapter.SendActivitiesAsync(ITurnContext turnContext,Activity []活动,Activation []活动,CancelationToken cancelToken)在Microsoft.Bot.Builder.TurnContext处的ConversationsExtensions.ReplyToActivityAsync(IConversations操作,字符串sessionId,字符串activityId,活动活动,CancellationToken cancelleToken)。

尽管我必须报告说,我能够轻松显示单个图像作为附件。这些图像具有硬编码的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 Messenger支持有关的问题?

0 个答案:

没有答案