I’m currently trying to get a program to work which extracts user messages from channel point redemption events in my chat.
The entire setup process works fine, I recieve my app access token, create the subscription and so on and when I test a redemption using the twitch-cli trigger it successfully and correctly identifies and extracts the information.
However when I redeem an actual reward in my chat no sign of any activity is shown across my webhook server. I feel like I’m missing an integral part where I tell the subscription to listen to my chat in particular but I can’t seem to find that spot.
Here’s my eventsub setup function
sync def setup_eventsub():
app_access_token = await get_app_access_token(twitch_client_id, twitch_client_secret)
if not app_access_token:
print("Failed to obtain app access token. Exiting...")
return
async with httpx.AsyncClient() as client:
headers = {
"Client-ID": twitch_client_id,
"Authorization": f"Bearer {app_access_token}",
"Content-Type": "application/json",
}
# Delete existing subscriptions (optional, but useful for testing)
response = await client.get("https://api.twitch.tv/helix/eventsub/subscriptions", headers=headers)
if response.status_code == 200:
existing_subscriptions = response.json()["data"]
for sub in existing_subscriptions:
await client.delete(f"https://api.twitch.tv/helix/eventsub/subscriptions?id={sub['id']}", headers=headers)
else:
print(f"Failed to get existing subscriptions: {response.status_code} - {response.text}")
return # Exit the function if there was an error
# Create a new subscription for channel points
payload = {
"type": "channel.channel_points_custom_reward_redemption.add",
"version": "1",
"condition": {
"broadcaster_user_id": twitch_channel_id,
},
"transport": {
"method": "webhook",
"callback": webhook_url,
"secret": "<My Secret>",
},
}
response = await client.post("https://api.twitch.tv/helix/eventsub/subscriptions", headers=headers, json=payload)
if response.status_code == 202:
print("EventSub subscription created successfully.")
else:
print(f"Failed to create EventSub subscription: {response.status_code} - {response.text}")
During setup it always returns 202 “EventSub subscription created successfully.”, so the setup itself seems to run fine.
There’s no other place in my code where I mention my channel ID except for this snippet. Am I missing another spot for that?
I’m also not quite sure if my twitch application that I created for this purpose needs any further investigation. Right now it’s only oauth redirection url is my ngrok webhook server address.
Appreciate any thoughts!