Skip to content

A Twitch EventSub server to proxy events to any webhook. Initially written for home assistant and node red.

License

Notifications You must be signed in to change notification settings

reecube/node-twitch-eventsub-webhook-proxy

Repository files navigation

Home Assistant Twitch Server

Home Assistant Twitch Server written on node.

This server forwards Twitch events to the home assistant server to trigger custom actions.

Features

  • Support for Twitch oauth and api tokens.
  • Support for self signed certificates on your home assistant server.
  • Proxy Twitch events from EventSub to your home assistant server.

Prerequisites

Optional: Our implementation

We are working with the following environment for best support:

Installation

First you need to checkout the git project.

For a production deployment we highly recommend to work with git tags only.

Then you need to install the project dependencies with yarn:

yarn install

Now you have to setup the .env file on root with your configuration:

SECRET=

HOME_ASSISTANT_WEBHOOK_URL=

TWITCH_CLIENT_ID=
TWITCH_CLIENT_SECRET=
TWITCH_CLIENT_LOGIN=

LT_SUBDOMAIN=

PROXY_PORT=
PROXY_URL=http://localhost:

As an alternative to the file you could just use environment variables.

Usage

To start the proxy server call this command:

yarn dev

We recommend to use pm2 (https://pm2.keymetrics.io/) for server deployments:

yarn start

With the following command you can restart the instance after updating the code:

yarn restart

With the following command you can stop the instance from pm:

yarn stop

With the following command you can delete the instance from pm:

yarn delete

And to make your server running persistently, use following command:

pm2 startup

and to store the current configuration you can use:

pm2 save

Roadmap

  • Enforce env local tunnel id
  • Implement redemption support: https://dev.twitch.tv/docs/api/reference#update-redemption-status
  • Alive-webhook ping to ensure this server is still running
  • Auto-fetch tokens
  • Implement scope verification
  • Implement config to remove unknown webhooks
  • Complete readme file
  • Implement health check
  • Implement status page
  • Implement doctor command to support with the setup process
  • Use vendor logger
  • Clean up files and file structure
  • Improve architecture
  • Implement JSDoc or TypeScript
  • Notification spam protection against outside
  • Graceful start and stop support: https://pm2.keymetrics.io/docs/usage/signals-clean-restart/
  • Verify security

Credits

Initial code was based on: https://github.com/twitchdev/eventsub-webhooks-node-sample

Also thanks a lot to all the developers of node, yarn, home assistant and node-red!

About

A Twitch EventSub server to proxy events to any webhook. Initially written for home assistant and node red.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published