0

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.

enter image description here Welcome.cs

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);
            }
        }
    }
}

}

  • Do you have an onMembersAdded function for the welcome message? If you could share the code that would be helpful. I suspect is it related to the condition on the if statement which leads to sending the welcome message. – billoverton Jan 30 '20 at 18:31
  • @billoverton, i just added the code of welcome card..do you need anything more? – shivani singh Feb 04 '20 at 03:40
  • @billoverton do you know any way to cancel all waterfallstep from onturnasync method – shivani singh Feb 04 '20 at 08:25
  • https://stackoverflow.com/questions/59926945/unable-to-use-cancelalldialogsasync-method-in-onturnasync-method here is the issue explained in deatils – shivani singh Feb 04 '20 at 08:28
  • @ mdrichardson-MSFT can plez look into this issue – shivani singh Feb 04 '20 at 08:29
  • @mdrichardson-MSFT here is the link of my issue https://stackoverflow.com/questions/59926945/unable-to-use-cancelalldialogsasync-method-in-onturnasync-method – shivani singh Feb 04 '20 at 08:29

1 Answers1

2

For Welcome card, make sure you send it in one of the activities supported in Slack

  • Message
  • ConversationUpdate
  • Event.TokenResponse

The Adaptive card is converted to an image in Slack channel

Check out the channels reference here for more detail

Giang Nguyen
  • 131
  • 3
  • do you know any way to cancel all water fall steps from onturnasync method...https://stackoverflow.com/questions/59926945/unable-to-use-cancelalldialogsasync-method-in-onturnasync-method plez go though this link..i am facing this issue – shivani singh Feb 04 '20 at 08:28
  • That seems to be unrelated to this inquiry. It seems Giang has provided an answer to this specific question? Is it satisfactory? – billoverton Feb 05 '20 at 15:36