# Unable to subscribe my bot to chat via EventSub with Godot

**URL:** <https://discuss.dev.twitch.com/t/unable-to-subscribe-my-bot-to-chat-via-eventsub-with-godot/62898>\
**Category:** API\
**Created:** [March 12, 2025, 10:16pm UTC](https://discuss.dev.twitch.com/t/unable-to-subscribe-my-bot-to-chat-via-eventsub-with-godot/62898 "2025-03-12T22:16:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gurkgamer](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/gurkgamer/32/30510_2.png) [@gurkgamer](https://discuss.dev.twitch.com/u/gurkgamer)\
**Post date:** [March 12, 2025, 10:16pm UTC](https://discuss.dev.twitch.com/t/unable-to-subscribe-my-bot-to-chat-via-eventsub-with-godot/62898/1 "2025-03-12T22:16:15Z")

</div>

Hello everyone,

I’ve been working with Godot to connect to chat, I would like to use the EventSub but I’m hitting a wall in the last step (if that’s where the issue is). I would like to list the things I’ve done:

I have a bot account where I registered a new Private app to get the **client\_id** and the **client\_secret**.

With that I proceed to Godot with the following steps.

1. First I ask for the Oauth token for the bot account with the scopes: user:read:chat and user:bot

This is the Body I’m creating

```auto
	var body = "client_id=%s&client_secret=%s&grant_type=%s&scope=%s" % \
	[
		bot_client_id,
		bot_client_secret,
		"client_credentials",
		"user:read:chat user:bot"
	]

```

Thanks to this I get the Oauth Token. At this point, I have the **Client\_Id** , the **Client\_secret** and an **Oauth Token** for my bot account with the scopes to be able to read chat.

1. After this, I need the broadcast\_id of my channel. So I use the oauth token and client\_id I have to get it.

Everything looks OK and I am able to get the Id.

Now I have also my channel’s **broadcaster\_user\_id.**

1. Now I establish the connection with the EventSub. For this I don’t use any parameter I have up to now, I just connect and I receive the **session\_welcome** message. I keep the session\_id from this response.

Now I also got the **session\_id**.

1. Finally comes the subscription step. I use this values to make a POST to the subscription endpoint: “[https://api.twitch.tv/helix/eventsub/subscriptions](https://api.twitch.tv/helix/eventsub/subscriptions)”

At the headers I set the authorization with my bot’s Oauth Token, the client with the bot’s Client\_id.  
At the body I set the scope to channel.chat.message, the broadcaster\_user\_id and the session\_id

```auto
	var url = "https://api.twitch.tv/helix/eventsub/subscriptions"
	var headers = [
		"Authorization: Bearer " + bot_oauth_token,
		"Client-Id: " + bot_client_id,
		"Content-Type: application/json"
	]
		
	var body = JSON.stringify({
	"type": "channel.chat.message",
	"version": "1",
	"condition": {
		"broadcaster_user_id": broadcaster_id
	},
	"transport": {
		"method": "websocket",
		"session_id": event_bus_session_id
	}
	})

```

And after all this I receive a 400 error.

I also tried adding the “user\_id” at the condition part with the bot’s broadcast\_id, that way I get a 403.  
`{"error":"Forbidden","status":403,"message":"subscription missing proper authorization"}.`

I just don’t know what I did wrong. Did I make a wrong turn in one of the steps?  
I tried to validate the Oauth token and it says that it’s ok and the scopes appear correctly.  
If it helps, the bot account is a moderator in my channel.

---

<div class="post-metadata">

**Author:** ![Dist](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/dist/32/7192_2.png) [@Dist](https://discuss.dev.twitch.com/u/Dist)\
**Post date:** [March 12, 2025, 10:24pm UTC](https://discuss.dev.twitch.com/t/unable-to-subscribe-my-bot-to-chat-via-eventsub-with-godot/62898/2 "2025-03-12T22:24:22Z")

</div>

> [@gurkgamer](#):
>
> Thanks to this I get the Oauth Token. At this point, I have the **Client\_Id** , the **Client\_secret** and an **Oauth Token** for my bot account with the scopes to be able to read chat.

That gives you an App Token, it’s not in any way related to your bot account.

As the documentation states for `channel.chat.message`

> Requires `user:read:chat` scope from the chatting user. If app access token used, then additionally requires `user:bot` scope from chatting user, and either `channel:bot` scope from broadcaster or moderator status.

So you have the App access token, but you need the user you wish to connect to chat as (your bot) to go through one of the User OAuth flows and grant the `user:bot` scope, and your need the broadcaster to mod the bot, or go through the OAuth flow and grant the `channel:bot` scope.

---

<div class="post-metadata">

**Author:** ![gurkgamer](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/gurkgamer/32/30510_2.png) [@gurkgamer](https://discuss.dev.twitch.com/u/gurkgamer)\
**Post date:** [March 12, 2025, 10:37pm UTC](https://discuss.dev.twitch.com/t/unable-to-subscribe-my-bot-to-chat-via-eventsub-with-godot/62898/3 "2025-03-12T22:37:44Z")

</div>

I think I understand. I have to change my App Access Token process to be a User Access Token.

This process will make that my game won’t be able to subscribe to the events without user interaction, isn’t it?

There is then no option to make it automatic to get this kind of connection?

Thank you very much!

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [March 12, 2025, 11:03pm UTC](https://discuss.dev.twitch.com/t/unable-to-subscribe-my-bot-to-chat-via-eventsub-with-godot/62898/4 "2025-03-12T23:03:54Z")

</div>

> [@gurkgamer](#):
>
> There is then no option to make it automatic to get this kind of connection?

for a game you would want to be subscribing to data relating to the broadcaster, so broadcasters _expect_ to authorize themself.

Especially if you want to utilize things such as channel points. (not just chat) so without an external service to run a bot, if you want the game to talk directly to chat/not vaa a relay/external service, then you need to get the broadcaster to auth.

This would likely be via DCF/Device Code Flow - [Getting OAuth Access Tokens | Twitch Developers](https://dev.twitch.tv/docs/authentication/getting-tokens-oauth/#device-code-grant-flow)

---

<div class="post-metadata">

**Author:** ![system](https://d2opxh93rbxzdn.cloudfront.net/original/2X/0/05909729875cce3b53e59d5561c4d23bb14948fc.png) [@system](https://discuss.dev.twitch.com/u/system)\
**Post date:** [April 11, 2025, 11:03pm UTC](https://discuss.dev.twitch.com/t/unable-to-subscribe-my-bot-to-chat-via-eventsub-with-godot/62898/5 "2025-04-11T23:03:56Z")

</div>

Closed on April 11, 2025, 11:03pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
