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

Update links for notifications + webhook handling #355

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions docs/developers/frames/v2/notifications_webhooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ The steps to successfully send a notification are:
4. Send a notification by POSTing to the `url` using the `token`
5. Listen for webhooks that tell you when a user adds/removes the frame and enables/disables notifications

The Frames V2 Demo frame has all of the above, specifically take a look at:

- [Handling webhooks](https://github.com/farcasterxyz/frames-v2-demo/blob/main/src/app/api/webhook/route.ts)
- [Saving tokens to Redis](https://github.com/farcasterxyz/frames-v2-demo/blob/main/src/lib/kv.ts)
- [Sending notifications](https://github.com/farcasterxyz/frames-v2-demo/blob/main/src/lib/notifs.ts)

## Create a Farcaster Domain Manifest

A Farcaster domain manifest is required for a frame to be eligible to be added to Farcaster clients and send notifications. It looks like this:
Expand Down Expand Up @@ -64,6 +70,8 @@ When notifications are enabled, the Farcaster client generates a unique `token`

The `token` and `url` need to be saved to persistent storage.

[Example code to save the token to an Upstash Redis](https://github.com/farcasterxyz/frames-v2-demo/blob/main/src/lib/kv.ts)

## Prompt users to add your frame to their Farcaster client

You can use the `addFrame` action while a user is using your frame to prompt them to add it to their Farcaster client.
Expand Down Expand Up @@ -94,7 +102,7 @@ export type AddFrameResult =

Once you have a `url` and `token`, you can send notifications by POSTing to the `url`. Note that you have to do separate POSTs for each Farcaster client (= unique `url`).

[Example code to send a notification](https://github.com/farcasterxyz/frames-v2-demo/blob/7905a24b7cd254a77a7e1a541288379b444bc23e/src/app/api/send-notification/route.ts#L25-L65)
[Example code to send a notification](https://github.com/farcasterxyz/frames-v2-demo/blob/main/src/lib/notifs.ts#L32-L64)

Here are the types:

Expand Down Expand Up @@ -185,7 +193,7 @@ The `header` JSON has 3 properties:

The `payload` JSON differs per event, see below.

[Example code to process webhook events](https://github.com/farcasterxyz/frames-v2-demo/blob/7905a24b7cd254a77a7e1a541288379b444bc23e/src/app/api/webhook/route.ts)
[Example code to process webhook events, using Neynar to verify the app key](https://github.com/farcasterxyz/frames-v2-demo/blob/main/src/app/api/webhook/route.ts)

### `frame_added`: frame added to a client

Expand Down