https://github.com/algo7/day-planner-gpt-data-portal
Data integration solution designed to seamlessly connect data sources such as emails, news feeds, and calendar information to plan your day using OpenAI's GPTs
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (11.5%) to scientific vocabulary
Keywords
Repository
Data integration solution designed to seamlessly connect data sources such as emails, news feeds, and calendar information to plan your day using OpenAI's GPTs
Basic Info
- Host: GitHub
- Owner: algo7
- License: gpl-3.0
- Language: Go
- Default Branch: main
- Homepage: https://github.com/algo7/day-planner-gpt-data-portal
- Size: 457 KB
Statistics
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 7
- Releases: 0
Topics
Metadata Files
README.md
day-planner-gpt-data-portal
Data integration solution designed to seamlessly connect data sources such as emails, news feeds, and calendar information to plan your day by using OpenAI's GPTs, which are custom versions of ChatGPT (read more here: https://openai.com/blog/introducing-gpts).
At this moment, the application only supports Google and Outlook integration. The API fetches the latest unread emails (past 2 days) from the user's inbox and returns the emails in JSON format that can be used in the custom "Actions" of the GPTs.
Table of Contents
TODO
- [ ] Add validation to
google_credentials.jsonandoutlook_credentials.jsonfiles - [x] Declutter and version the API endpoints
- [ ] Implement OAuth Device Flow
- [ ] Add calendar integration
- [ ] Add news feed integration
- [ ] Write tests
- [ ] Kubernetes manifest
Requirements
- Go 1.21.4+
- A running Redis instance
- An API client of your choice (Postman, Insomnia, Thunder Client etc.)
- A browser
- Docker (optional)
- Make (optional)
How to run it
It is important that you follow the prerequisites here before running the application; otherwise, the application will not work.
1. Create a Google Cloud Project and Enable the Gmail API
- Follow the instructions here: https://developers.google.com/gmail/api/quickstart/go all the way to the Authorize credentials for a desktop application section
- Save the downloaded JSON file as google_credentials.json in the credentials folder
- You can find the example of the file in the credentials folder as google_credentials.example.json
- Register an app with the Microsoft Identity Platform
- Follow the instructions here: https://docs.microsoft.com/en-us/graph/auth-register-app-v2
- Configure the correct redirect URL in the
Authenticationsection of the app registration - Create a client secret in the
Certificates & secretssection of the app registration - Copy the client secret and ID then save them in the
outlook_credentials.jsonfile in thecredentialsfolder - You can find the example of the file in the
credentialsfolder asoutlook_credentials.example.json
Locally
- Make sure the
credentialsfolder exists in the root directory and contains the following files:google_credentials.json- Google OAuth2 Configurationoutlook_credentials.json- Outlook OAuth2 Configuration
- Make sure you have an Redis instance running
- If your Redis instance is not running on
localhost:6379, you need to pass in theREDIS_HOST(with port) andREDIS_PASSenvironment variables
- If your Redis instance is not running on
- Run
go run main.go
Docker
- Make sure the
credentialsfolder exists in the root directory and contains the following files:google_credentials.json- Google OAuth2 Configurationoutlook_credentials.json- Outlook OAuth2 Configuration
- Run
docker compose build - Run
docker compose up. Redis will be automatically started as a dependency
Makefile
If you have make installed, you can simply run make start to build + run the application locally, or make docker to build + run the application in Docker.
Documentation
You can find the Swagger documentation on http://localhost:3000/docs
Note on the API Key
The /v1/email/outlook and the /v1/email/google routes are protected by the API key, which needs to be sent in the header as X-API-KEY. To obtain the initial API key, you need to first visit the /v1/auth/internal/apikey endpoint in the browser and enter the initial password in the form to obtain the API key. The initial password can be found in the startup logs of the application. The initial password is randomly generated on each startup, if and only if it has not been set. The initial password will get set to an empty string the moment you obtain the API key. Subsequent visit to the /v1/auth/internal/apikey endpoint will redirect you to the / or the homepage of the application. To call the protected endpoints listed above, you will need something like Postman to send the API key in the header.
Revoking the API Key
The API key is stored in Redis and the TTL will get extended by 7 days everytime you call an protected endpoint. It will expire after 7 days of inactivity. If you want to revoke your active API key, you will have to manually delete it from Redis.
Obtaining a new API Key after Expiration or Revocation
Since the initial password has been set to an empty string the 1st time you generated the API Key, to obtain a new one, you have 2 options:
1. Delete the initial_password key in Redis, restart the application (a new initial password will be generated), then go to the /v1/auth/internal/apikey endpoint in the browser to obtain a new API key
2. Set the initial_password key in Redis to a non-empty string and then go to the /v1/auth/internal/apikey endpoint in the browser to obtain a new API key using the new password
How to Interact with the API
- Start the application
- Check the startup logs for the initial password
- Visit the
/v1/auth/internal/apikeyendpoint in the browser and enter the initial password to obtain the API key - Call the
/v1/auth/oauthendpoint using an API client using the query parameterproviderwith the valuegoogleoroutlook- The endpoint will present you with a link to the OAuth2 provider to complete the authentication flow
- Complete the authentication flow
- Both Outlook and Google access tokens are valid for 1 hour
- Call the
/v1/email/outlookusing using an API client and send the API key in the header asX-API-KEYto get the latest unread emails from Outlook - Call the
/v1/email/googleusing using an API client and send the API key in the header asX-API-KEYto get the latest unread emails from Gmail - Call the
/v1/auth/oauth/refreshusing an API client using the query parameter with the valuegoogleoroutlookto refresh the token.- The endpoint will replace the token object in Redis with the new token object
- The endpoint effectively revokes the old token and replaces it with a new one
Limitations
The application will most likely not work with work or school accounts unless 2 requirements are met: 1. For Microsoft: Become a verified publisher - https://learn.microsoft.com/en-us/entra/identity-platform/publisher-verification-overview 2. For Google: Get your OAuth App verified - https://support.google.com/cloud/answer/13463073?hl=en
Owner
- Name: algo7
- Login: algo7
- Kind: user
- Location: Taiwan Nantou | Switzerland Zurich | Switzerland Lausanne
- Company: ECHO
- Repositories: 2
- Profile: https://github.com/algo7
GitHub Events
Total
- Watch event: 1
- Delete event: 54
- Issue comment event: 39
- Push event: 29
- Pull request event: 126
- Pull request review event: 15
- Create event: 63
Last Year
- Watch event: 1
- Delete event: 54
- Issue comment event: 39
- Push event: 29
- Pull request event: 126
- Pull request review event: 15
- Create event: 63
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 1
- Total pull requests: 169
- Average time to close issues: about 13 hours
- Average time to close pull requests: 7 days
- Total issue authors: 1
- Total pull request authors: 1
- Average comments per issue: 0.0
- Average comments per pull request: 0.3
- Merged pull requests: 67
- Bot issues: 1
- Bot pull requests: 169
Past Year
- Issues: 1
- Pull requests: 82
- Average time to close issues: about 13 hours
- Average time to close pull requests: 12 days
- Issue authors: 1
- Pull request authors: 1
- Average comments per issue: 0.0
- Average comments per pull request: 0.48
- Merged pull requests: 14
- Bot issues: 1
- Bot pull requests: 82
Top Authors
Issue Authors
- dependabot[bot] (1)
Pull Request Authors
- dependabot[bot] (169)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
- Total downloads: unknown
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 0
proxy.golang.org: github.com/algo7/day-planner-gpt-data-portal
- Homepage: https://github.com/algo7/day-planner-gpt-data-portal
- Documentation: https://pkg.go.dev/github.com/algo7/day-planner-gpt-data-portal#section-documentation
- License: GPL-3.0