Community · n8n

Automatically Assign a Discord Role to Every New Twitch Follower

When someone follows your Twitch channel, this workflow instantly assigns them a designated role in your Discord server. Keep your community organized and reward followers without any manual work.

difficulty Intermediatesetup 45 minresult Every new Twitch follower who is also in your Discord server automatically receives a custom role, such as 'Twitch Follower', without you lifting a finger.
  1. 1

    Schedule a Twitch follower check every 5 minutes

    Add a Schedule Trigger node and set the interval to every 5 minutes. This is the heartbeat of the workflow, regularly checking for new followers on your channel. No credentials are needed here.

  2. 2

    Fetch your latest Twitch followers

    Add an HTTP Request node. Set the Method to GET and the URL to https://api.twitch.tv/helix/channels/followers?broadcaster_id=YOUR_BROADCASTER_ID&first=5. In the Headers section add Client-Id with your Twitch app client ID and Authorization with Bearer YOUR_ACCESS_TOKEN. Store these securely in n8n credentials. This returns the most recent followers.

  3. 3

    Extract the latest follower's username

    Add a Set node to pull out the follower data you need. Create a new field called followerName and set its value to the expression {{ $json.data[0].user_name }}. This isolates the most recent follower's username for the next step.

  4. 4

    Look up the Discord member by username

    Add another HTTP Request node. Set Method to GET and URL to https://discord.com/api/v10/guilds/YOUR_GUILD_ID/members/search?query={{ $json.followerName }}&limit=1. Add a Authorization header with value Bot YOUR_BOT_TOKEN. This searches your Discord server for a member whose username matches the Twitch follower. Store the bot token in n8n credentials.

  5. 5

    Assign the Discord role to the matched member

    Add a final HTTP Request node. Set Method to PUT and URL to https://discord.com/api/v10/guilds/YOUR_GUILD_ID/members/{{ $json[0].user.id }}/roles/YOUR_ROLE_ID. Add the Authorization header with Bot YOUR_BOT_TOKEN and set Body Content Type to JSON with an empty body {}. This grants the Twitch Follower role to the matched Discord member instantly.

Frequently asked questions

What if the Twitch follower doesn't have the same name on Discord?

The workflow matches by username, so if usernames differ the role won't be assigned automatically. You can add a manual mapping sheet or ask followers to link their accounts via a bot command as an additional step outside this workflow.

How do I get a Twitch broadcaster ID?

Go to https://www.streamweasels.com/tools/convert-twitch-username-to-user-id/ and enter your Twitch username. Alternatively call the Twitch API endpoint GET /helix/users?login=YOUR_USERNAME with your credentials and copy the `id` field from the response.

What Discord bot permissions does the bot need?

Your Discord bot must have the `Manage Roles` permission enabled in your server. Also ensure the bot's role is positioned higher in the role hierarchy than the role it is trying to assign, otherwise Discord's API will return a 403 error.

About this recipe. Recipes on FlowRecipesHub are written for business owners, not developers, and are tested before publishing — how recipes get made. Some ingredient links are affiliate links that cost you nothing — full disclosure.