Skip to content

feat: Integrate Farcaster Frame notification system#1

Open
jc4p wants to merge 2 commits into
mainfrom
feat/farcaster-notifications
Open

feat: Integrate Farcaster Frame notification system#1
jc4p wants to merge 2 commits into
mainfrom
feat/farcaster-notifications

Conversation

@jc4p

@jc4p jc4p commented Jun 7, 2025

Copy link
Copy Markdown
Owner

I've implemented a comprehensive system for sending and managing Farcaster Frame notifications.

Key features:

  • Database Table: I added a farcaster_notification_subscriptions table to D1 to store user FIDs, Farcaster client-provided notification tokens, and URLs.
  • Webhook Listener: I introduced an API endpoint /api/farcaster/webhook that securely handles Farcaster client events (frame_added, notifications_enabled, frame_removed, notifications_disabled) to manage subscription statuses. It uses @farcaster/frame-node for signature verification.
  • Notification Utility: I provided a sendFrameNotification function (src/lib/notifications.ts) to send notifications to you. This function retrieves active subscription details and constructs/sends the payload as per Farcaster specifications.
  • Sample Trigger: I included a sample implementation (src/routes/api/offers/create.ts) demonstrating how to use sendFrameNotification when a new offer is made on an NFT.
  • Documentation: I updated docs/DATABASE_SETUP.md with the new table schema and docs/FRAME_NOTIFICATIONS.md with details on the webhook listener and the notification utility function, including usage examples.

This system allows the application to effectively engage you with relevant and timely notifications directly within your Farcaster clients.

I've implemented a comprehensive system for sending and managing Farcaster Frame notifications.

Key features:
-   **Database Table:** I added a `farcaster_notification_subscriptions` table to D1 to store user FIDs, Farcaster client-provided notification tokens, and URLs.
-   **Webhook Listener:** I introduced an API endpoint `/api/farcaster/webhook` that securely handles Farcaster client events (`frame_added`, `notifications_enabled`, `frame_removed`, `notifications_disabled`) to manage subscription statuses. It uses `@farcaster/frame-node` for signature verification.
-   **Notification Utility:** I provided a `sendFrameNotification` function (`src/lib/notifications.ts`) to send notifications to you. This function retrieves active subscription details and constructs/sends the payload as per Farcaster specifications.
-   **Sample Trigger:** I included a sample implementation (`src/routes/api/offers/create.ts`) demonstrating how to use `sendFrameNotification` when a new offer is made on an NFT.
-   **Documentation:** I updated `docs/DATABASE_SETUP.md` with the new table schema and `docs/FRAME_NOTIFICATIONS.md` with details on the webhook listener and the notification utility function, including usage examples.

This system allows the application to effectively engage you with relevant and timely notifications directly within your Farcaster clients.
… route

Converts the Farcaster Frame notification system from TypeScript to plain JavaScript.
This includes:
-   `src/routes/api/farcaster/webhook.ts` is now `webhook.js`.
-   `src/lib/notifications.ts` is now `notifications.js`.
-   All TypeScript type annotations and interfaces have been removed.

Additionally, the sample offer creation API route (`src/routes/api/offers/create.ts`) has been removed as per your feedback.

Documentation in `docs/FRAME_NOTIFICATIONS.md` has been updated to:
-   Reflect JavaScript function signatures and code examples.
-   Remove references to the deleted sample offer creation route, providing more generic guidance on triggering notifications.
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.

1 participant