Automate your Fantasy Premier League updates into a Discord channel using an Azure Automation PowerShell runbook, secure variables, and a scheduled trigger.
Why I Built This
Every Fantasy Premier League (FPL) season, my friends and I ask the same thing: “When’s the next deadline?” or “Is this a double gameweek?” To stop the guesswork, I built an Azure Automation Runbook that posts gameweek reminders and updates directly to our Discord channel. It runs completely serverless, costs virtually nothing, and doesn’t require any external hosting.
This post breaks down how I built it from scratch using PowerShell — from setting up the Automation Account to posting updates through a Discord Webhook.
What the Bot Does
The PowerShell runbook runs on a schedule and:
- Queries the Fantasy Premier League API for current and upcoming gameweek data.
- Parses and formats the key information (gameweek number, deadline, double/blank weeks, etc.).
- Posts the update message to Discord via a Webhook.
High-level flow:
[Azure Automation Schedule] → [PowerShell Runbook] → [FPL API]
→ [Discord Webhook]
Step 1 — Create the Discord Webhook
- Go to your Discord server settings → Integrations → Webhooks → New Webhook.
- Select the target channel (e.g.,
#fpl-updates). - Copy the Webhook URL and store it securely — anyone with this URL can post messages to that channel.
We’ll store it in Azure as an encrypted variable so it’s hidden from logs.
Step 2 — Create the Azure Automation Account
- In the Azure Portal, create a new Automation Account.
- Name:
fpl-discord-automation - Region: closest to you (I use East US)
- Name:
- Once created, navigate to Variables → Add a variable.
- Name:
DISCORD_WEBHOOK_URL - Type: String
- Value: your Discord Webhook URL
- Encrypted: ✅ On
- Name:
This ensures the webhook can’t be exposed even in job output.
Step 3 — The PowerShell Runbook Script
Next, create a new PowerShell Runbook named FplDiscordNotifier and paste in the following code:
param()
# Fetch the webhook URL from the encrypted Automation variable
$webhookUrl = Get-AutomationVariable -Name 'DISCORD_WEBHOOK_URL'
# Define the FPL API endpoint
$fplApiUrl = 'https://fantasy.premierleague.com/api/bootstrap-static/'
# Fetch FPL data
try {
$response = Invoke-RestMethod -Uri $fplApiUrl -Method Get
} catch {
Write-Error "Failed to fetch data from FPL API: $_"
exit 1
}
# Extract current and next gameweek info
$currentEvent = $response.events | Where-Object { $_.is_current -eq $true }
$nextEvent = $response.events | Where-Object { $_.is_next -eq $true }
if (-not $currentEvent -and -not $nextEvent) {
Write-Output 'Could not determine current or next Gameweek.'
exit 0
}
$targetEvent = if ($nextEvent) { $nextEvent } else { $currentEvent }
$title = "GW$($targetEvent.id) — $(if ($targetEvent.is_next) { 'Next' } elseif ($targetEvent.is_current) { 'Live' } else { 'Upcoming' })"
$deadline = [datetime]::Parse($targetEvent.deadline_time)
$utcNow = [datetime]::UtcNow
$minutesUntilDeadline = [math]::Round(($deadline - $utcNow).TotalMinutes)
$hours = [math]::Floor($minutesUntilDeadline / 60)
$mins = $minutesUntilDeadline % 60
# Build message lines
$messageLines = @()
$messageLines += "Deadline (UTC): $($deadline.ToString('yyyy-MM-dd HH:mm')) (+$hours h $mins m)"
if ($targetEvent.is_double) { $messageLines += '**Double Gameweek Alert**' }
if ($targetEvent.is_blank) { $messageLines += '**Blank Gameweek Alert**' }
# Combine into final content
$content = "**$title**`n" + ($messageLines -join "`n")
# Post to Discord
try {
Invoke-RestMethod -Uri $webhookUrl -Method Post -Body (@{ content = $content } | ConvertTo-Json) -ContentType 'application/json'
Write-Output "Posted FPL update to Discord successfully."
} catch {
Write-Error "Failed to post to Discord: $_"
}
This script runs entirely in Azure, pulling public data and formatting a clean Discord message like this:
**GW10 — Next**
Deadline (UTC): 2025-10-26 10:30 (+144 h 0 m)
**Double Gameweek Alert**
Step 4 — Test and Publish
- Save the runbook and click Test Pane.
- Run it once manually — you should see a message appear in your Discord channel almost instantly.
- Once confirmed, click Publish.
Check the job logs for Posted FPL update to Discord successfully.
Step 5 — Schedule the Runbook
Now automate it:
- In the runbook page, go to Schedules → Add a schedule.
- Create a new schedule, for example:
- Name:
Daily FPL Reminder - Recurrence: Daily
- Time zone: Atlantic/Bermuda (or your own)
- Start time: 08:00
- Name:
- Link the schedule to the
FplDiscordNotifierrunbook.
You can add multiple schedules — for instance, one on Fridays and another 2 hours before deadlines.
Optional Enhancements
- Use Discord embeds for a more polished message.
- Add Key Vault integration using a Managed Identity if you prefer centralised secret management.
- Include your league standings using
https://fantasy.premierleague.com/api/leagues-classic/{league_id}/standings/. - Add error notifications by posting to a second webhook (e.g., your private admin channel).
Troubleshooting
| Issue | Fix |
|---|---|
Invoke-RestMethod fails | Ensure the API endpoint isn’t blocked and try again. |
| No message in Discord | Check webhook URL or channel permissions. |
| Variable not found | Confirm the variable name matches and is marked as Encrypted. |
| Deadline time off | Remember, FPL times are UTC. Adjust if you prefer local time. |
Wrap-Up
This PowerShell-based FPL → Discord bot has been rock-solid and completely maintenance-free. The Automation Account handles everything — fetching FPL data, formatting it neatly, and posting updates automatically. It’s a lightweight, serverless way to keep everyone in the loop each gameweek without lifting a finger.
If you’re into Azure Automation, you can easily adapt this to other data sources or notification types — anything that can be reached via REST can be automated just like this.

