I am using hero card to display a list of carousels on FB messenger. I want to put an url link behind the image I am displaying so that when user selects the carousel he is redirected to the payment page. How to achieve this with the latest Botframework v4. In version 3 Action types included OpenUrl. but in V4 I didn't found a way to this in the docs.
Kindly Help. I am adding my code here.
// Create the hero cards. Add the carousels to it.
var heroCard = new HeroCard
{
Title = "We are a travel agency trusted over 30 years, with 95 % positive customer reviews. and ",
Subtitle = "Call us from anywhere, anytime.",
Text = "We have A+ rating from BBB",
Images = new List<CardImage> { new CardImage(CarouselResult.Data[0].ImageUrl.ToString()) },
Buttons = new List<CardAction> { new CardAction(ActionTypes.OpenUrl, "Search Results", value: CarouselResult.Data[0].ApiUrl.ToString()) },
};
var heroCard1 = new HeroCard
{
Title = "We are a travel agency trusted over 30 years, with 95 % positive customer reviews. and ",
Subtitle = "Call us from anywhere, anytime.",
Text = "We have A+ rating from BBB",
Images = new List<CardImage> { new CardImage(CarouselResult.Data[1].ImageUrl.ToString()) },
Buttons = new List<CardAction> { new CardAction(ActionTypes.OpenUrl, "Search Results", value: CarouselResult.Data[0].ApiUrl.ToString()) },
};
var heroCard2 = new HeroCard
{
Title = "We are a travel agency trusted over 30 years, with 95 % positive customer reviews. and ",
Subtitle = "Call us from anywhere, anytime.",
Text = "We have A+ rating from BBB",
Images = new List<CardImage> { new CardImage(CarouselResult.Data[2].ImageUrl.ToString()) },
Buttons = new List<CardAction> { new CardAction(ActionTypes.OpenUrl, "Search Results", value: CarouselResult.Data[0].ApiUrl.ToString()) },
};
/////convert the hero cards to attachments
var attachments = new List<Attachment>() {
{ heroCard.ToAttachment() },
{ heroCard1.ToAttachment() },
{ heroCard2.ToAttachment() }
};
////add attachments to carousels
var reply1 = MessageFactory.Carousel(attachments);
Please suggest suitable solution. Thanks in advance.
The simplest way to make card images clickable in the Facebook Messenger channel is to use Messenger Templates. You can add a default action to the image that can either direct the user to a URL or open a Webview. To use a Messenger Template with the Microsoft Bot Framework, you need to add the template to the outgoing activity's channel data. You can create a carousel by adding multiple template elements. Take a look at the example below.
Messenger Template
Screenshot
Note, any URL that you use in your template must be Whitelisted; otherwise, the template won't render. For more details, check out Facebook Messenger's Documentation on Whitelisting a URL and Messenger Templates.
Hope this helps!