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

Implementing the Gmail Application Handler #5889

Merged
merged 18 commits into from May 16, 2023

Conversation

ra-jeev
Copy link
Contributor

@ra-jeev ra-jeev commented Apr 29, 2023

Description

Please include a summary of the change and the issue it solves.

Fixes #5364

Type of change

  • ⚡ New feature (non-breaking change which adds functionality)
  • 📄 This change requires a documentation update

What is the solution?

Implemented the Gmail Application Handler using the Gmail API with the help of google-api-python-client and google-auth-oauthlib libraries. The integration supports pulling emails from the OAuth authenticated user's Gmail mailbox using the filter queries supported by Gmail. It then extracts the text and other relevant details from the individual emails and add it to the database. It also supports sending text emails to the destination email address by using the Insert command. It also supports creating threads in case of replying to emails.

Checklist:

  • My code follows the style guidelines(PEP 8) of MindsDB.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation, or created issues to update them.
  • I fixed|updated|added unit tests and integration tests for each feature (if applicable).
  • I have shared a short loom video or screenshots demonstrating any new functionality.

@ra-jeev
Copy link
Contributor Author

ra-jeev commented Apr 29, 2023

I have read the CLA Document and I hereby sign the CLA

-- rajeev

Copy link
Contributor

@tmichaeldb tmichaeldb left a comment

Choose a reason for hiding this comment

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

Thanks for the Pull Request! Main changes I'd like to see before merging:

  • Add basic tests
  • Add example for SELECT row in docs

mindsdb/integrations/handlers/gmail_handler/__about__.py Outdated Show resolved Hide resolved
@ra-jeev
Copy link
Contributor Author

ra-jeev commented May 6, 2023

Thanks a lot @tmichaeldb for reviewing the PR. I'll mostly be making the requested changes today.

Should I change the column name "from" to something else (say sender) to avoid clashes with SQL reserved keywords?

Thanks,
Rajeev

@Cyber-Machine Cyber-Machine mentioned this pull request May 6, 2023
4 tasks
@ra-jeev
Copy link
Contributor Author

ra-jeev commented May 7, 2023

The Checks are failing because of torch. What should be done here?

ERROR: Could not find a version that satisfies the requirement torch<2.1,>=2.0.0 (from lightwood) (from versions: 1.0.0, 1.0.1, 1.0.1.post2, 1.1.0, 1.2.0, 1.3.0, 1.3.1, 1.4.0, 1.5.0, 1.5.1, 1.6.0, 1.7.0, 1.7.1, 1.8.0, 1.8.1, 1.9.0, 1.9.1, 1.10.0, 1.10.1, 1.10.2, 1.11.0, 1.12.0, 1.12.1, 1.13.0, 1.13.1)
ERROR: No matching distribution found for torch<2.1,>=2.0.0

@ZoranPandovski ZoranPandovski mentioned this pull request May 8, 2023
4 tasks
Copy link
Contributor

@tmichaeldb tmichaeldb left a comment

Choose a reason for hiding this comment

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

LGTM. Please don't merge yet though due to figuring out how to combine this PR with #5890 .

@ZoranPandovski
Copy link
Member

Amazing, @ra-jeev , @maarioos1308 is this ready?

@ra-jeev
Copy link
Contributor Author

ra-jeev commented May 11, 2023

Amazing, @ra-jeev , @maarioos1308 is this ready?

Hey @ZoranPandovski, I think it should be ready by tomorrow. (@maarioos1308 added attachments parsing today).

Also,
In our testing we found that the text extracted from 'text/html' is almost the same which Gmail returns in the 'text/plain' part (Gmail automatically creates a text version of the HTML). So, does it make sense to have a separate column for storing the text extracted from html?

IMO, it was duplicate content so I had not added it in my PR, but @maarioos1308 had it.

@ra-jeev
Copy link
Contributor Author

ra-jeev commented May 12, 2023

Hey @ZoranPandovski & @tmichaeldb,
This PR is complete for initial merge from our end. Main changes compared to the approved PR

  1. Support for taking credentials file from S3 (the default) with a fallback to the local file
  2. A couple of new columns and support for storing attachments details
  3. Corresponding changes in the README file + more examples

Things to note

  1. We haven't added HTML parsing as the text extracted from HTML is almost the same as what we get from 'plain/text' (which Gmail automatically generates)
  2. For attachments, we're just storing their meta details in a column and not downloading + extracting texts from them.

Both of these can be added if you think we need to have it. But for downloads I've a concern for the attachments size.

Once this PR is merged we can close #5890. Then I can do one more change related to creating email drafts which is not supported yet.

Thanks,
Rajeev & Marios(@maarioos1308)

@ZoranPandovski
Copy link
Member

Excellent, thanks, team, and congratulations on winning the first prize :trophy: . Please feel free to open an issue for all of the new features :raised_hands:

@ZoranPandovski ZoranPandovski merged commit a3348b3 into mindsdb:staging May 16, 2023
6 checks passed
@ra-jeev
Copy link
Contributor Author

ra-jeev commented May 16, 2023

Thanks a lot @ZoranPandovski :-)

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.

None yet

4 participants