Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Outlook integration toolkit #3465

Open
wants to merge 74 commits into
base: main
Choose a base branch
from

Conversation

hahahafafa
Copy link

Fixes # 3005 issue
Description: Added basic tools to interact with Microsoft Graph Api that can send or read user's emails. Classes to complete the authentication flows are also added to perform user login or provide accessToken that must be used for Microsoft Graph.
Issue: #3005
Dependencies: openurl package is used during user log in
Tag maintainer: @jacoblee93 , and any of the other maintainers if needed

Hello,

This is our first PR and we hope that our changes will be helpful to the community. We have run make format, make lint and make test locally before submitting the PR. To our knowledge, our changes do not introduce any new errors.

Our PR has added basic tools to interact with Microsoft Graph Api that can send or read user's emails. Classes to complete the authentication flows are also added to perform user login or provide accessToken that must be used for Microsoft Graph. Nonetheless, we have added tests to test our changes, note the test is dependent on the necessary credentials in .env . These changes were put together by me, @oscarchen178, @Qi123123Li, and @SimonLi1020 We're a group of students from UofT submitting this for a project. Please test the code and let us know if there are any issues.

Thank you in advance to the maintainers for their time.

@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Nov 30, 2023
Copy link

vercel bot commented Nov 30, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
langchainjs-api-refs ❌ Failed (Inspect) Jan 23, 2024 2:40am
langchainjs-docs ✅ Ready (Inspect) Visit Preview Jan 23, 2024 2:40am

@@ -0,0 +1,189 @@
import * as http from "http";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR adds a new HTTP request using the fetch function in the getAccessToken and refreshAccessToken methods. This comment is flagging the change for maintainers to review.

@@ -0,0 +1,189 @@
import * as http from "http";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR adds code that explicitly accesses and reads environment variables via the getEnvironmentVariable function, which should be reviewed by maintainers to ensure proper handling and usage of environment variables.

@@ -0,0 +1,103 @@
import { AuthFlowBase } from "./authFlowBase.js";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR introduces a new fetch request in the AuthFlowRefresh class to refresh the access token using the refresh token. This comment is flagging the change for maintainers to review the addition of this new request.

@@ -0,0 +1,103 @@
import { AuthFlowBase } from "./authFlowBase.js";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work on the PR! I've flagged a change in the code that requires an environment variable using the getEnvironmentVariable function. Please review this change to ensure it aligns with the project's requirements.

@@ -0,0 +1,66 @@
import { OutlookBase } from "./base.js";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR introduces a new external HTTP request using fetch to fetch emails from the Microsoft Graph API. Please review this change to ensure it aligns with the project's requirements and best practices.

@@ -0,0 +1,87 @@
import { OutlookBase } from "./base.js";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is flagging the addition of a new external HTTP request using the fetch function to send an email via the Microsoft Graph API. Please review this change to ensure it aligns with the project's requirements and best practices.

@hahahafafa
Copy link
Author

Hello Jacob, it looks like it is still pending approval, can you give the approval when you have time? Thank you so much!


```typescript
import { ChatOpenAI } from "langchain/chat_models/openai";
import { initializeAgentExecutorWithOptions } from "langchain/agents";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We deprecated this method in favor of createOpenAIFunctionsAgent:

https://js.langchain.com/docs/modules/agents/agent_types/openai_functions_agent

Do you mind also putting this in the examples/ folder and importing it in a code block so that it gets linted?

or put them in the environment.

```typescript
import { AuthFlowREST } from "@langchain/community/tools/outlook";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So someone needs to run this script beforehand?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, if he doesn't have the tokens.

@jacoblee93
Copy link
Collaborator

My take is that this is all just far too complicated to set up but I suppose there's no other way to authenticate? No concept of just an API key?

@oscarchen178
Copy link

My take is that this is all just far too complicated to set up but I suppose there's no other way to authenticate? No concept of just an API key?

I also think it is very complicated to set up. I think the "api key" you want is the accessToken, but it is hard to get (can't just copy from the web like the openai key). So I implemented the authFlowREST class to the get the key, but then another problem is the token expires quickly (1 hour). That's why I implemented authFlowRefresh to auto refresh the token. From my understanding of the Microsoft docs, there's no other way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:enhancement A large net-new component, integration, or chain. Use sparingly. The largest features close PRs that need one or two touch-ups to be ready question Further information is requested size:XXL This PR changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants