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

feat: Gmail #407

Closed
wants to merge 16 commits into from
Closed

feat: Gmail #407

wants to merge 16 commits into from

Conversation

cachho
Copy link
Contributor

@cachho cachho commented Aug 8, 2023

Description

  • gmail loader
  • sanitized text
  • metadata
  • documentation to get the credentials
  • new dependency pip install embedchain[community]

Sample Output that's embedded:

email from 'YouTube <[email protected]>' to '[email protected]'
subject: Introducing: YouTube Handles
date: Wed, 19 Oct 2022 04:39:26 -0700
preview: YouTube Creator YouTube is introducing handles to make it easier for people to find and connect with each other. Hi John Doe, We&#39;re writing to let you know that over the coming weeks YouTube will
content: fYouTube is introducing handles Hi user, We're writing to let you know that over the coming weeks YouTube will be introducing handles to make it easier for members of the community to find and connect with each other. Your handle will be unique to your channel and will be how people mention you in comments, community posts, and more. Here’s what you need to know: We're gradually rolling out the ability to choose a handle for all channels over the coming weeks, and you will receive another email and a notification in YouTube Studio when you’re able to choose yours. In most cases, if you already have a personalized URL for your channel, we’ve reserved this for you as your handle. If you want a different handle from the one we’ve reserved, you can change it. If you don’t already have a personalized URL today, you’ll also be able to choose a handle for your channel. Starting on November 14, 2022, if you haven’t yet selected a handle for your channel, YouTube will automatically assign you a handle, which you can change in YouTube Studio if you'd like. In the meantime, learn more about handles and all the things you’ll be able to do with them: LEARN MORE Sincerely,The YouTube team You received this mandatory email service announcement to update you about important changes to your YouTube channel or account. © 2022 Google LLC d/b/a YouTube, 901 Cherry Ave, San Bruno, CA 94066 -0000000000002b48c505eb61a912-

logs

2023-08-09 00:04:00,525 [root] [INFO] Gmail Loader: 1 mails found
2023-08-09 00:04:00,536 [root] [INFO] [menu-main-menu] Cleaned page size: 1425 characters, down from 26942 (shrunk: 25517 chars, 94.71%)

Sample metadata

{'url': '183f00a8dfa04424', 'date': 'Wed, 19 Oct 2022 04:39:26 -0700', 'subject': 'Introducing: YouTube Handles', 'from': 'YouTube <[email protected]>', 'to': '[email protected]', 'search_query': 'In the meantime, learn more about handles and all the things'}

Potential to-dos:

  • further sanitize the text, it still has a few imperfections
  • save date metadata as epoch
  • add tests

Fixes #338

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • Documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

Please delete options that are not relevant.

  • Unit Test
  • Test Script (please provide)
from embedchain import App
from embedchain.config import AppConfig

config = AppConfig(log_level="DEBUG")
app = App(config=config)

app.add("gmail", "In the meantime, learn more about handles and all the things")

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

Maintainer Checklist

  • closes #xxxx (Replace xxxx with the GitHub issue number)
  • Made sure Checks passed

docs/advanced/data_types.mdx Outdated Show resolved Hide resolved
docs/advanced/data_types.mdx Outdated Show resolved Hide resolved
docs/advanced/data_types.mdx Outdated Show resolved Hide resolved
Eg:

```python
app.add("gmail", "*")
Copy link
Member

Choose a reason for hiding this comment

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

This signature will change once we merge PR #380

Copy link
Member

Choose a reason for hiding this comment

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

I followed the instruction, but I am getting following error from gmail.

Access blocked: This app’s request is invalid

You can’t sign in because this app sent an invalid request. You can try again later, or contact the developer about this issue. [Learn more about this error](https://developers.google.com/identity/protocols/oauth2/web-server#authorization-errors-redirect-uri-mismatch)
If you are a developer of this app, see [error details](https://accounts.google.com/).
Error 400: redirect_uri_mismatch

I entered the redirect uri as localhost:8080, but I think we will need to run the server. Right now the server is not running.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No I never had to run a server specifically, I guess it starts a server for authentication.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So when I run the code, it opens the browser with https://accounts.google.com/o/oauth2/auth/oauthchooseaccount

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Choosing an account there redirects to port localhost:8080, which displays: The authentication flow has completed. You may close this window.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

and then the script runs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can try with again with another account if you want.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@taranjeet
Copy link
Member

@cachho : you should try again. I had to run the server.

@cachho
Copy link
Contributor Author

cachho commented Aug 17, 2023

@cachho : you should try again. I had to run the server.

I tried it 3 times and never had to. Do you want me to add something to the docs?

@taranjeet
Copy link
Member

thanks for the contribution on this one. we have added support for gmail as per new data loader style.

@taranjeet taranjeet closed this Dec 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add support for email request
2 participants