i have a bot made in framework v4 using c#. i am using a adaptive card as welcome message in my bot and also card to take feedback from user, it is working fine in emulator but when bot is integrated with slack , welcome card doesn't appear and more over feedback card doesn't show its proper look in slack rather than it come in a form of a image. does anyone know the reason?? Even the problem doesn't come while integrating it with any other channel. Does slack channel have any kind of limitations? I am also attaching the image that i get in slack without the welcome card.
public class Welcomeuser : DialogBot<MainDialog>
{
protected readonly string[] _cards =
{
Path.Combine(".", "Resources", "WelcomeCard.json"),
};
public Welcomeuser(ConversationState conversationState, UserState userState,
MainDialog dialog, ILogger<DialogBot<MainDialog>> logger, IConfiguration configuration, IHttpClientFactory httpClientFactory)
: base(conversationState, userState, dialog, logger, configuration, httpClientFactory)
{
}
protected override async Task OnMembersAddedAsync(IList<ChannelAccount>
membersAdded, ITurnContext<IConversationUpdateActivity> turnContext, CancellationToken cancellationToken)
{
await SendWelcomeMessageAsync(turnContext, cancellationToken);
Random r = new Random();
var cardAttachment = CreateAdaptiveCardAttachment(_cards[r.Next(_cards.Length)]);
await turnContext.SendActivityAsync(MessageFactory.Attachment(cardAttachment), cancellationToken);
}
private static Attachment CreateAdaptiveCardAttachment(string filePath)
{
var adaptiveCardJson = File.ReadAllText(filePath);
var adaptiveCardAttachment = new Attachment()
{
ContentType = "application/vnd.microsoft.card.adaptive",
Content = JsonConvert.DeserializeObject(adaptiveCardJson),
};
return adaptiveCardAttachment;
}
private static async Task SendWelcomeMessageAsync(ITurnContext turnContext, CancellationToken cancellationToken)
{
foreach (var member in turnContext.Activity.MembersAdded)
{
if (member.Id != turnContext.Activity.Recipient.Id)
{
if (DateTime.Now.Hour < 12)
{
await turnContext.SendActivityAsync($"Hi,Good Morning {member.Name}", cancellationToken: cancellationToken);
}
else if (DateTime.Now.Hour < 17)
{
await turnContext.SendActivityAsync($"Hi,Good Afternoon {member.Name}", cancellationToken: cancellationToken);
}
else
{
await turnContext.SendActivityAsync($"Hi,Good Evening {member.Name}", cancellationToken: cancellationToken);
}
}
}
}
}