Skip to content

A CLI tool to answer all your queries using the power of the Microsoft Graph API.

Notifications You must be signed in to change notification settings

GHArchitecht/magi-msgraph-hackathon

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hack Together: Microsoft Graph and .NET

magi

DALL-E prompt: A wizard watching over the rising sun atop a tower overlooking mountains and valleys but the wizard is a CLI tool for answering user queries using Microsoft Graph API, artistic, classical landscape painting

magi is a smart AI which answers all of your queries using the Microsoft Graph API.

Demo

Untitled.video.mp4

Examples

List all users in the company

$ ./magi "Show all users in the company" | head -n 10
{
  "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users",
  "value": [
    {
      "businessPhones": [
        "\u002B1 425 555 0109"
      ],
      "displayName": "Adele Vance",
      "givenName": "Adele",
      "jobTitle": "Retail Manager",

View unread emails of a user

$ ./magi "Show unread emails of PradeepG@5ybb1m.onmicrosoft.com" | head -n 10
{
  "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users(\u0027PradeepG%405ybb1m.onmicrosoft.com\u0027)/messages(subject,body,sender,sentDateTime,webLink)",
  "value": [
    {
      "@odata.type": "#microsoft.graph.eventMessageRequest",
      "@odata.etag": "W/\u0022CwAAABYAAADL8M9WgOrzQKgOydiWocLBAAAAAAc6\u0022",
      "id": "AAMkAGIwNzMzMjI4LTg5ZWYtNGUwYi1iYzBlLTE2NWY5NjdiYWIwMgBGAAAAAADqxEoU78ilTIGasXHLVnmYBwDL8M9WgOrzQKgOydiWocLBAAAAAAEMAADL8M9WgOrzQKgOydiWocLBAAAAAAFoAAA=",
      "sentDateTime": "2023-03-06T04:11:26Z",
      "subject": "Company All Hands",
      "webLink": "https://outlook.office365.com/owa/?ItemID=AAMkAGIwNzMzMjI4LTg5ZWYtNGUwYi1iYzBlLTE2NWY5NjdiYWIwMgBGAAAAAADqxEoU78ilTIGasXHLVnmYBwDL8M9WgOrzQKgOydiWocLBAAAAAAEMAADL8M9WgOrzQKgOydiWocLBAAAAAAFoAAA%3D\u0026exvsurl=1\u0026viewmodel=ReadMessageItem",

View latest meetings of a user

$ ./magi "What were the last few meetings of PradeepG@5ybb1m.onmicrosoft.com?" | head -n 10
{
  "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users(\u0027PradeepG%405ybb1m.onmicrosoft.com\u0027)/calendar/events",
  "value": [
    {
      "@odata.etag": "W/\u0022y/DPVoDq80CoDsnYlqHCwQAAAAAHXg==\u0022",
      "id": "AAMkAGIwNzMzMjI4LTg5ZWYtNGUwYi1iYzBlLTE2NWY5NjdiYWIwMgBGAAAAAADqxEoU78ilTIGasXHLVnmYBwDL8M9WgOrzQKgOydiWocLBAAAAAAENAADL8M9WgOrzQKgOydiWocLBAAAAAHDnAAA=",
      "createdDateTime": "2023-03-06T04:11:29.0748984Z",
      "lastModifiedDateTime": "2023-03-06T04:13:31.5987848Z",
      "changeKey": "y/DPVoDq80CoDsnYlqHCwQAAAAAHXg==",
      "categories": [],

Running Instructions

  1. Build the project: dotnet publish -c Release -o publish
  2. Go the created directory: cd publish
  3. Create the configuration file: config.json
  4. Invoke the power of magi: ./magi

Structure of config.json

{
    "openApiKey": "YOUR-OPENAI-API-KEY",
    "clientId": "YOUR-AAD-APP-CLIENT-ID",
    "clientSecret": "YOUR-AAD-APP-CLIENT-SECRET",
    "tenantId": "YOUR-AAD-TENANT-ID"
}

Design

    graph LR;
    User--query-->magi;
    magi--query-->ChatGPT;
    ChatGPT--response-->magi;
    magi--request-->Graph;
    Graph--response-->magi;
    magi--response-->User;
Loading

Libraries Used

  • System.CommandLine for building the CLI functionality
  • OpenAI-API-dotnet for interacting with the ChatGPT API

About

A CLI tool to answer all your queries using the power of the Microsoft Graph API.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%