Skip to content

Added LINE hook for integration#71

Open
chr-nguyen wants to merge 5 commits intokyoto-tech:mainfrom
chr-nguyen:main
Open

Added LINE hook for integration#71
chr-nguyen wants to merge 5 commits intokyoto-tech:mainfrom
chr-nguyen:main

Conversation

@chr-nguyen
Copy link
Copy Markdown

Justin's notifier runs on a schedule, checks the member RSS feeds, and when it finds a new post it sends a POST request to whatever URL is set in COMMUNITY_FEED_GENERIC_WEBHOOK_URL — which we'll point at our LINE hook. The body it sends looks like this:

  {                                                                                                                  
    "event": "community_feed_item",
    "item": { ... },
    "message": "New community post from Ash Ryan Arnwine\nSome Blog Post Title\nhttps://example.com/post"
  }  

The message field is the plain text string built by buildMessage() — author name, post title, and link joined by newlines.


Our LINE hook receives that request and does three things:

  1. Checks the secret — if the x-webhook-secret header doesn't match, it rejects the request immediately
  2. Pulls out body.message — ignores everything else in the payload, just takes that plain text string
  3. Forwards it to LINE — POSTs to the LINE Messaging API with the message as a plain text message, delivered to whatever group or user LINE_TARGET_ID points to

So the LINE message your members will see is just:

New community post from Ash Ryan Arnwine
Some Blog Post Title
https://example.com/post

What changed

3 files modified, 2 files created:

  • astro.config.mjs — switched to hybrid output mode and added the Cloudflare adapter so the site can serve server-side routes alongside its static pages
  • src/pages/api/line-hook.ts (new) — the webhook endpoint that authenticates incoming requests and forwards the message payload to LINE's Messaging API
  • scripts/community-feed-notifier.mjs — added x-webhook-secret header to Justin's generic webhook sender so it can authenticate against the LINE hook
  • .github/workflows/community-feed-notifier.yml — passes the new COMMUNITY_FEED_GENERIC_WEBHOOK_SECRET secret into the notifier job
  • .env.example (new) — documents all required env vars for both sides of the integration

Next steps

  1. Get your LINE credentials — create a Messaging API channel at developers.line.biz, issue a channel access token and grab the target group/user ID
  2. Set secrets in Cloudflare Pages — WEBHOOK_SECRET, LINE_CHANNEL_TOKEN, LINE_TARGET_ID
  3. Set secrets in GitHub Actions — COMMUNITY_FEED_GENERIC_WEBHOOK_URL (pointing to https://kyototechmeetup.com/api/line-hook) and COMMUNITY_FEED_GENERIC_WEBHOOK_SECRET (same value as WEBHOOK_SECRET)
  4. Test end-to-end — trigger the notifier manually via workflow_dispatch with dry_run: false and verify a message lands in LINE

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