# Farcastle :: Notification Scratch ## Assumptions 1. webhook to watch events 2. some db to save user/pref 4. events in app to add to message queue 5. process to watch this queue and cycle through messaging ## message types **new campaign blasts** trigger in app on success can get all active users to blast job does - get range or all from redis? - can we trigger to multiple fids/tokens? - https://miniapps.farcaster.xyz/docs/guides/notifications#send-a-notification **new yeet** takes fid of user yeeting get all users and find if they follow fid job does - fid is tken from queue - use neynar to get all followers for fid - https://docs.neynar.com/reference/fetch-user-followers - look in redis for each fid - trigger notification to multiple fids **annoucement blasts** manual trigger can get all active users to blast ## app auto trigger asking user to add frame if not added ## log **5/21** - [x] deploy test - [x] does it capture adds - [x] trigger notify (protected api) - [x] trigger notify from deployment? - [ ] backfill **5/22** - [ ] job to use queue and blast - [ ] trigger blast from launch - [ ] queue to stage - [ ] add to queue from app - [x] ui trigger to suggest adding - [x] test blasts - [ ] [deploy qstash workflow](https://upstash.com/docs/workflow/quickstarts/vercel-nextjs#step-5%3A-deploying-to-production) https://upstash.com/docs/workflow/quickstarts/vercel-nextjs backfill notification records try: - in the framesdk provider - check the user/context object and add if needed? https://docs.neynar.com/reference/fetch-notification-tokens - doesnt work ## Resources [docs](https://miniapps.farcaster.xyz/docs/guides/notifications) [builders-garden/miniapp-next-template](https://github.com/builders-garden/miniapp-next-template/blob/main/app/api/webhook/route.ts) [upstash](https://upstash.com/docs/qstash/quickstarts/vercel-nextjs) **minitkit** webhook/route.tsx - handles the events and adding users to redis cache lib/notification.ts - routes uses this to interact with redis sendFrameNotification hook - post to notification url takeaway - good for single sends - could maybe do more in redis to classify, it basically tracks by fid now - pulling bulk by fids? - sendFrameNotification for multiple fids? **buildersG** more robust user model in redis https://github.com/builders-garden/frames-v2-starter/blob/main/lib/db/index.ts **upstash** https://upstash.com/docs/redis/sdks/ts/getstarted - some other types of dtaa structures for setting and fetchuing pricing https://upstash.com/pricing workflow for queue/job workers https://upstash.com/docs/qstash/overall/getstarted builders qstash https://github.com/builders-garden/frames-v2-starter/blob/main/lib/qstash.ts try to get multiple entries at once https://upstash.com/docs/redis/sdks/ts/commands/string/mget - build keys based on followers fids upstash sdk https://github.com/upstash/redis-js #### add mini app action 1. detect if added https://miniapps.farcaster.xyz/docs/sdk/context 2. call the add https://miniapps.farcaster.xyz/docs/sdk/actions/add-frame