A card representing a request to sign in
Ejemplo n.º 1
0
        private void RequestLogin(Microsoft.Bot.Connector.Activity message)
        {
            var resumptionCookie        = new ResumptionCookie(message);
            var encodedResumptionCookie = UrlToken.Encode <ResumptionCookie>(resumptionCookie);

            Microsoft.Bot.Connector.Activity oriMessage = resumptionCookie.GetMessage();


            var reply = oriMessage.CreateReply(Messages.BOT_PLEASE_LOGIN);

            reply.Recipient   = oriMessage.From;
            reply.Type        = Microsoft.Bot.Connector.ActivityTypes.Message;
            reply.Attachments = new List <Microsoft.Bot.Connector.Attachment>();
            List <Microsoft.Bot.Connector.CardAction> cardButtons = new List <Microsoft.Bot.Connector.CardAction>();
            var encodedCookie = UrlToken.Encode(resumptionCookie);

            Microsoft.Bot.Connector.CardAction button = new Microsoft.Bot.Connector.CardAction()
            {
                Value = $"{ConfigurationHelper.GetString("AgentLogin_URL")}?cookie={encodedCookie}",
                Type  = "signin",
                Title = Messages.BOT_SIGNIN_BUTTON_TEXT,
                Image = "https://michistorageea.blob.core.windows.net/cdn/login.png"
            };
            cardButtons.Add(button);
            Microsoft.Bot.Connector.SigninCard plCard = new Microsoft.Bot.Connector.SigninCard(
                text: $"{Messages.BOT_PLEASE_LOGIN}",
                buttons: cardButtons);
            Microsoft.Bot.Connector.Attachment plAttachment = plCard.ToAttachment();
            reply.Attachments.Add(plAttachment);
            ConnectorClient connector = new ConnectorClient(new Uri(message.ServiceUrl));
            var             response  = connector.Conversations.SendToConversation(reply);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates a new attachment from <see cref="SigninCard"/>.
 /// </summary>
 /// <param name="card"> The instance of <see cref="SigninCard"/>.</param>
 /// <returns> The generated attachment.</returns>
 public static Attachment ToAttachment(this SigninCard card)
 {
     return(new Attachment
     {
         Content = card,
         ContentType = SigninCard.ContentType
     });
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates a new attachment from <see cref="SigninCard"/>.
 /// </summary>
 /// <param name="card"> The instance of <see cref="SigninCard"/>.</param>
 /// <returns> The generated attachment.</returns>
 public static Attachment ToAttachment(this SigninCard card)
 {
     return(CreateAttachment(card, SigninCard.ContentType));
 }