microsoft / botframework-sdk

Bot Framework provides the most comprehensive experience for building conversation applications.
MIT License
7.51k stars 2.45k forks source link

Message text is below Hero Card in Facebook Messenger #4966

Closed Zhashkha closed 6 years ago

Zhashkha commented 6 years ago

Bot Info

Issue Description

I'm sending attachment Hero Card and simple text message in Facebook channel with channelData property. Somehow text is always below the Hero Card and I can't find out why it's happening.

https://prnt.sc/khgeen

Code Example

// add text to message string messageText = OperatorHelper.ReminderNotificationTextGet(operatorCode);

        string cardImage = OperatorHelper.OperatorCardImageGet(operatorCode);
        var channelData = new
        {
            type = "template",
            payload = new
            {
                template_type = "generic",
                elements = new[]
                {
                    new
                    {
                        title = OperatorHelper.ReminderNotificationOperatorTitleGet(operatorCode),
                        subtitle = balance,
                        image_url = imageUrl,
                        buttons = new[]
                        {
                            new
                            {
                                type = ActionTypes.PostBack,
                                title = TemplateTexts.ReminderNotificationLinkRedirectionTitle,
                                payload = BotticelliApplicationConsts.ReminderNotificationLinkRedirectionValue
                            },
                            new
                            {
                                type = ActionTypes.PostBack,
                                title = TemplateTexts.ReminderNotificationSumTitle,
                                payload = BotticelliApplicationConsts.ReminderNotificationSumValue
                            }
                        }
                    }
                }
            }
        };

        replyToConversation.ChannelData = JObject.FromObject(
            new
            {
                messaging_type = "RESPONSE",
                notification_type = "REGULAR",
                attachment = channelData,
                text = messageText
            });
JasonSowers commented 6 years ago

This is happening because that is the way that hero cards are rendered. You can see how most features will render on different channels by using the Channel Inspector. It is not 100% accurate and up to date because channels are constantly changing things, but it will give you a good general idea.

If you need fully customizable cards, please look into Adaptive Cards. Adaptive cards will give you much more control over how your rich content will look. They are not fully supported on Facebook, as they will be rendered to an image then have mapping to buttons. This may suffice for your needs though.

Zhashkha commented 6 years ago

Thanks for reply Jason.

Adaptive cards are poorly supported on Facebook, you simply can't rely on them. Now the reason why I've asked you that is next. If you create a Hero card without ChannelData property, but with simple Bot Framework class, it would work normally, the text will be above the card attachment. That's why I thought it's possible with channel specific data too. I'm using channel specific data, because I have to push reminder notifications on Android. Native Bot Framework messages are just sent, but don't give any signal and don't appear in Messenger without your proactivity. It's a different issue, but maybe you can help me with that. Thanks in advance.

JasonSowers commented 6 years ago

I'm not sure I follow your second question. Are you running into issues with the 24+1 policy with proactive messages? Or is this an issue with no notification being sent? Could you please try to explain the issue?

Zhashkha commented 6 years ago

I'm talking about notifications not being sent. I've started with this issue #1339 and it seems there is no workaround with native Bot Framework message to be pushed on mobile Messenger. So now I'm using channel specific message and getting message text below message attachment, which doesn't satisfy me. Any ideas would be greatly appreciated.

JasonSowers commented 6 years ago

Using channel specific data for Facebook is the way this would have to be accomplished. If you have a better solution in mind you could always submit a pull request.

Zhashkha commented 6 years ago

Thank you for you effort Jason. I'm closing this issue.