mirror of
https://github.com/GoogleChrome/chrome-extensions-samples.git
synced 2026-03-26 13:19:49 +07:00
* Migrate to latest version of the language model * Update readme to better describe the sample. * More readme updates * Consistent API naming and format lists
1.8 KiB
1.8 KiB
Calendar Mate: On-device AI with Gemini Nano
This sample demonstrates how to use Chrome's built-in Prompt API in an extension to extract calendar event details from natural language text. To learn more about the API, see Prompt API on developer.chrome.com.
Overview
Calendar Mate allows users to quickly create Google Calendar events from any selected text on a webpage. Simply highlight text describing an event (e.g., "Team meeting on Friday at 3pm in Conference Room A"), right-click, and select "Create Calendar Event". The extension uses Gemini Nano to intelligently extract:
- Event title
- Start and end date/time
- Location
- Description
- Timezone
The extracted details are used to pre-populate a new Google Calendar event.
Running this extension
- Clone this repository.
- Run
npm installin the project directory. - Run
npm run buildto build the extension. - Load the
distdirectory in Chrome as an unpacked extension. - Select any text on a webpage that describes an event.
- Right-click and choose "Create Calendar Event" from the context menu.
How it works
- Context Menu: The extension adds a "Create Calendar Event" option to Chrome's right-click context menu when text is selected.
- AI Extraction: When triggered, the selected text is sent to Gemini Nano with a prompt to extract event details as structured JSON.
- Date Parsing: The extracted date/time strings are parsed using the any-date-parser library.
- Calendar Integration: A Google Calendar URL is generated with the extracted details and opened in a new tab.