buttons of type OpenUrl not shown in herocard with Kik channel
Bot Info
- SDK Platform: .NET
- SDK Version: 3.15.2.2
- Active Channels: Skype, Telegram, Kik, Facebook Messenger
- Deployment Environment: Azure App Service
Issue Description
The same herocard that works fine in Skype, Telegram and Facebook Messenger doesn´t work with Kik where the buttons are not shown.
Buttons are not shown at the bottom as in https://docs.botframework.com/en-us/channel-inspector/channels/Kik?f=HeroCard&e=example1
Can you please share your herocard code so we can take a look?
if (bComCard && objRet.CardTitulo != "" && objRet.CardFigura != "")
{
var heroCard = new HeroCard();
heroCard.Title = objRet.CardTitulo;
heroCard.Subtitle = "";
heroCard.Text = "";
if (objRet.CardFigura != "")
{
heroCard.Images = new List<CardImage>
{
new CardImage(objRet.CardFigura)
};
}
heroCard.Buttons = new List<CardAction>();
foreach (ClassMsgMSBot objAux in objRet.colMsgs)
{
heroCard.Buttons.Add(new CardAction
{
Text = objAux.BotaoTexto,
DisplayText = objAux.BotaoTexto,
Title = objAux.BotaoTexto,
Type = ActionTypes.OpenUrl,
Value = objAux.BotaoURL
});
};
// Use the data stored previously to create the required objects.
var userAccount = new ChannelAccount(objEntrada.IdRemetente, objEntrada.NomeRemetente);
var botAccount = new ChannelAccount(objEntrada.IdReceptor, objEntrada.NomeReceptor);
//var appCredentials = new MicrosoftAppCredentials("ac573e18-18eb-48e7-856a-51ddeb3b6185", "ijmUSN3}|surlTPNE0194[{");
MicrosoftAppCredentials.TrustServiceUrl(objEntrada.ServiceUrl, DateTime.Now.AddDays(7));
var connector = new ConnectorClient(new Uri(objEntrada.ServiceUrl));
// Create a new message.
IMessageActivity message = Activity.CreateMessageActivity();
message.ServiceUrl = objEntrada.ServiceUrl;
message.ChannelId = objEntrada.IDCanal;
if (string.IsNullOrEmpty(objEntrada.IdConversa) )
{
// Conversation ID was not stored previously, so create a conversation.
// Note: If the user has an existing conversation in a channel, this will likely create a new conversation window.
objEntrada.IdConversa = (await connector.Conversations.CreateDirectConversationAsync(botAccount, userAccount)).Id;
}
// Set the address-related properties in the message and send the message.
message.From = botAccount;
message.Recipient = userAccount;
message.Conversation = new ConversationAccount(id: objEntrada.IdConversa);
message.Text = "";
message.Locale = "pt-BR";
message.Attachments.Add(heroCard.ToAttachment());
await connector.Conversations.SendToConversationAsync((Activity)message);
I took a look at this and was able to determine in my testing that buttons are not showing up in kik is that the title does not have a value. Once I put a value in there the buttons showed up.
However, This is unfortunately still not going to work for you. In order to display "Hero Cards" in kik we have to use keyboards specifically the Suggested Response Keyboard which does not support an open url type. According to their documentation: "The type of response to send. Must be one of: text, friend-picker, picture". So there is no way to actually open a url from a button in a herocard on kik.
I see you are including the title, which is odd. Also interesting because not including it was the only way I could make the buttons not show up. Is there a chance your title on the cardAction is an empty string or null?
I used this code to get it to show up:
Activity reply = activity.CreateReply("BarbM wuz here");
var card = new HeroCard
{
Title = "title",
Text = "text",
Buttons = new List<CardAction> {new CardAction(ActionTypes.OpenUrl,"open url 1", text: "open url 1", value:@"https://www.google.com/"),
new CardAction(ActionTypes.OpenUrl,title:@"open url 2", text: "open url 2", value:@"https://www.google.com/"),
new CardAction(ActionTypes.OpenUrl,title:@"open url 3", text: "open url 3", value:@"https://www.google.com/")
}
};
reply.Attachments.Add(card.ToAttachment());
await context.PostAsync(reply);
Hi,
Buttons are shown but almost immediately disappear.
You may keep this issue closed because there are higher priority ones, like 4733.
Best regards,
Jones