-
-
Notifications
You must be signed in to change notification settings - Fork 11
Closed
Labels
Description
ππ» Automating gr2m/helpdesk: Twitch Events
π
Thursday, October 21, 2021
π 10:00am Pacific Time
ποΈ no guests
π https://www.twitch.tv/gregorcodes
π·οΈ automation
Subscribe to this issues to get a notification before the show begins and a summary after the show concludes.
Automating gr2m/helpdesk: π 10/21 @ 10:00am PT - Automating gr2m/helpdesk: Twitch Events
Instead of using a schedule-based trigger for when a show starts, I'll start using webhooks sent from Twitch itself, whenever I start a stream.
Outline
- Create a new repository
handle-twitch-events-using-github-actions
with a Netlify Function that responds to/.netlify/functions/ping
- Setup continuous deployment of the repository using Netlify's GitHub App
- Add a script to list, create, and delete Twitch subscriptions
- Add a Netlify Function that will handle Twitch EventSub requests at
POST /.netlify/functions/twitch
and create repository dispatch events - Add a GitHub Action that gets triggered by the repository dispatch events
Bonus
- In the
gr2m/helpdesk
repository, rreplace the current schedule trigger for the Handle show start workflow with the custom trigger when the webhook is received - Replace the current
issues.closed
trigger for the Handle show done workflow with the custom trigger when the webhook is received. Close the show issue
TODOs
Before the show
I already setup the Netlify function and the twitch subscription in the gr2m/helpdesk
. I'll prepare the pieces so we can create a new repository from scratch step-by-step.
- 30 minute announcement tweet
(https://twitter.com/gr2m/status/1451227071120818183) - 30 minute announcement comment
(π 10/21 @ 10:00am PT - Automating gr2m/helpdesk: Twitch EventsΒ #52 (comment))
When show begins
- start of show tweet
(https://twitter.com/gr2m/status/1451233334537895937) - comment on issue
(π 10/21 @ 10:00am PT - Automating gr2m/helpdesk: Twitch EventsΒ #52 (comment)) - Set twitter profile url
(https://twitter.com/gr2m)
After the show
- Reset twitter profile after the show
(https://twitter.com/gr2m) - recording available tweet
Recording
Shownotes
- Demo repository I created during the show: https://github.com/gr2m/handle-twitch-events-using-github-actions
- Netlify CLI: https://docs.netlify.com/cli/get-started/
I usednetlify dev
to start a local server,netlify dev --live
to start a local server with an http tunnel, so it's reachable by others, andnetlify init
to setup continuous deployment for the demo repository using Netlify - Twitch CLI: https://github.com/twitchdev/twitch-cli#readme
- Send request to test subscription verification.
-F
is the URL the simulated webhook request should be sent to.twitch event verify-subscription subscribe -F http://localhost:8888/.netlify/functions/twitch
- Get user account ID by login. You'll need your Twitch User Account ID to set the condition when creating the Twitch event subscription
twitch api get users -q login=gregorcodes
- Trigger a "stream.online" event.
-s
is the secret you defined when you created the subscription.-t
is your account ID.twitch event trigger streamup -F http://localhost:8888/.netlify/functions/twitch -s secret -t 581268875
- Trigger a "stream.offline" event
twitch event trigger streamdown -F http://localhost:8888/.netlify/functions/twitch -s secret -t 581268875
- Send request to test subscription verification.
- To create/list/delete Twitch subscriptions, check out the script I added to the test repository at https://github.com/gr2m/handle-twitch-events-using-github-actions/blob/main/scripts/twitch-subscriptions.js