andresharpe/dotbot/integrate-graph-api

Claude Code and agent skill by andresharpe/dotbot

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Install

npx vskill@latest install andresharpe/dotbot/integrate-graph-api

SKILL.md

Integrate Microsoft Graph API

Guide for working with Microsoft Graph API to access Microsoft 365 data.

When to Use

  • Accessing user email and messages
  • Reading and managing calendar events
  • Getting organizational hierarchy and user profiles
  • Sending emails on behalf of users

Authentication Setup

App Registration
  1. Register app in Azure AD
  2. Configure API permissions (Mail.Read, Calendars.ReadWrite, User.Read, etc.)
  3. Get client ID, tenant ID, and client secret
Authentication Flow
csharp
var scopes = new[] { "https://graph.microsoft.com/.default" };
var options = new TokenCredentialOptions
{
AuthorityHost = AzureAuthorityHosts.AzurePublicCloud
};
var clientSecretCredential = new ClientSecretCredential(
tenantId, clientId, clientSecret, options);
var graphClient = new GraphServiceClient(clientSecretCredential, scopes);

Common Operations

Email Operations

List Messages

csharp
var messages = await graphClient.Users[userId]
.Messages
.Request()
.Select("id,subject,from,receivedDateTime,bodyPreview")
.Filter($"receivedDateTime ge {sinceDate:o}")
.OrderBy("receivedDateTime desc")
.Top(50)
.GetAsync();

Send Email

csharp
var message = new Message
{
Subject = subject,
Body = new ItemBody
{
ContentType = BodyType.Html,
Content = htmlBody
},
ToRecipients = recipients.Select(r => new Recipient
{
EmailAddress = new EmailAddress { Address = r }
}).ToList()
};
await graphClient.Users[userId]
.SendMail(message, saveToSentItems: true)
.Request()
.PostAsync();
Calendar Operations

Get Calendar Events

csharp
var events = await graphClient.Users[userId]
.CalendarView
.Request()
.Header("Prefer", "outlook.timezone=\"UTC\"")
.Select("id,subject,start,end,attendees,location")
.Top(100)
.GetAsync(startDateTime, endDateTime);

Create Calendar Event

csharp
var newEvent = new Event
{
Subject = subject,
Start = new DateTimeTimeZone
{
DateTime = startTime.ToString("o"),
TimeZone = "UTC"
},
End = new DateTimeTimeZone
{
DateTime = endTime.ToString("o"),
TimeZone = "UTC"
},
Attendees = attendees.Select(a => new Attendee
{
EmailAddress = new EmailAddress { Address = a.Email, Name = a.Name },
Type = AttendeeType.Required
}).ToList()
};
await graphClient.Users[userId]
.Events
.Request()
.AddAsync(newEvent);
User Operations

Get User Profile

csharp
var user = await graphClient.Users[userId]
.Request()
.Select("displayName,jobTitle,department,officeLocation,manager")
.Expand("manager")
.GetAsync();

Error Handling

csharp
try
{
var messages = await graphClient.Users[userId].Messages.Request().GetAsync();
}
catch (ServiceException ex) when (ex.StatusCode == System.Net.HttpStatusCode.NotFound)
{
// Handle not found
}
catch (ServiceException ex) when (ex.StatusCode == System.Net.HttpStatusCode.Unauthorized)
{
// Handle auth failure - refresh token
}
catch (ServiceException ex)
{
// Log and handle other Graph API errors
_logger.LogError(ex, "Graph API error: {Code} - {Message}", ex.Error.Code, ex.Error.Message);
}

Best Practices

  • Use $select - Request only needed properties
  • Batch requests - Use batch API for multiple operations
  • Handle rate limits - Implement retry logic with exponential backoff
  • Use delta queries - For incremental sync
  • Cache tokens - Don't authenticate on every request
  • Use UTC - Always work in UTC for dates

Common Pitfalls

  • ❌ Not selecting specific properties (over-fetching)
  • ❌ Not handling pagination
  • ❌ Ignoring rate limit headers
  • ❌ Not refreshing expired tokens
  • ❌ Using wrong permission scopes
  • ❌ Not handling time zones properly

Checklist

  • [ ] App registered with correct permissions
  • [ ] Authentication configured and tested
  • [ ] Proper error handling for API failures
  • [ ] Rate limiting/retry logic implemented
  • [ ] Only necessary properties selected
  • [ ] Pagination handled for large result sets
  • [ ] Timezone handling is correct (use UTC)
  • [ ] Tokens refreshed appropriately

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
50
Repository forks
24
7-day trend score
20

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/andresharpe/dotbot/integrate-graph-api/badge)](https://verified-skill.com/skills/andresharpe/dotbot/integrate-graph-api)

Something wrong with this skill or its page? Tell us.