Exemplo n.º 1
0
        // Displays information about the user in the bot.
        public static async Task ListMeAsync(ITurnContext turnContext, TokenResponse tokenResponse)
        {
            if (turnContext == null)
            {
                throw new ArgumentNullException(nameof(turnContext));
            }

            if (tokenResponse == null)
            {
                throw new ArgumentNullException(nameof(tokenResponse));
            }

            // Pull in the data from the Microsoft Graph.
            var client = new SimpleGraphClient(tokenResponse.Token);
            var me     = await client.GetMeAsync();

            var manager = await client.GetManagerAsync();

            var photoResponse = await client.GetPhotoAsync();

            // Generate the reply activity.
            var reply     = turnContext.Activity.CreateReply();
            var photoText = string.Empty;

            if (photoResponse != null)
            {
                var replyAttachment = new Attachment(photoResponse.ContentType, photoResponse.Base64String);
                reply.Attachments.Add(replyAttachment);
            }
            else
            {
                photoText = "Consider adding an image to your Outlook profile.";
            }

            reply.Text = $"You are {me.DisplayName} and you report to {manager.DisplayName}. {photoText}";
            await turnContext.SendActivityAsync(reply);
        }