Extension PubSub Question

I now fully unsterstand how the Front End, Back End and Game parts all communicate.
Lastnight I finally got my EBS Send something to the Front End via PubSub YAY

I understand the following:

  • That “broadcast” is for all viewers on the channel with the extension.
  • That “global” is for everyone that has the extension no matter what channel they are in.
  • That “whisper” is for an individual user.

I am still not able to get “whisper” to work even though I set it and the permissions in the message sent from my EBS and that I am setting teh Front End to listen to “whisper-*” I receive nothing, so I must be missing setting something.

Also the “message” is used to send your message, I get that, but I am not able to send anything but a string value, when I try to have “message” as a JSON String it fails with the following error:

{"error":"Bad Request","status":400,"message":"Missing required parameter \"message\""}

This is what I am sending:

   "message": {
      "event": "some_event_name", 
      "message": "Hello World" 
   "broadcaster_id": "%my_ID%", 
   "target": [

It says for “message” the following:

The message to send. The message can be a plain-text string or a string-encoded JSON object. The message is limited to a maximum of 5 KB.

So what am I doing wrong ?



It’s for an individual user on a given channel.
So it uses the broadcast/channel rate limit pool

A payload of

            target: [ 'whisper-opaqueUserId' ],
            broadcaster_id: '123123',
            is_global_broadcast: false,
            message: 'foobar'

should suffice to send a whisper, swap opaqueUserId for the opaque user ID

Make sure to build your Send JWT with the whisper-opaqueUserId permission, having swapped the opaqueUserId to the opaqueUserId of the user

Something along the lines of twitch_extension_tools/app/modules/extensions.js at main · BarryCarlyon/twitch_extension_tools · GitHub

It should be whisper-OPAQUEID not a *

Yeah I understand that the “whisper” will only be when the individual user need to interact / choose something, so that “should” be a small amount of messages.

Also it seems the EBS is working fine, just that the Front End is not.
Seems that “window.Twitch.ext.viewer.opaqueId” is null I will look at your code to see if I am missing something before setting up those “listen” hooks.

Also back to the actual “message” contents, can I set that to actual JSON instead of like “foobar” due to that would limit the amount of different types of messages or is it a dumb message where you just send the whole html element block in there?



Is yoru call inside onAuthorized as onAuthorized is basically “twitch is ready for you to do stuff like listen” now.

Of course foobar is just an example

probably shouldn’t be sending HTML blocks around tbh

I will check the Front End code in a sec.

This is the error I get for the Whisper Listen that is set after the Broadcast one which is working fine.

Object { category: "PubsubClient", context: {…}, message: "got error response from socket", package: "@twitch/chat-pubsub-client" }
​category: "PubsubClient"
context: Object { error: "ERR_BADAUTH" }
error: "ERR_BADAUTH"
<prototype>: Object { … }
message: "got error response from socket"
package: "@twitch/chat-pubsub-client"

But to answer your questiojn, erm NOPE LOL
But if that was the case, why is the “broadcast” one working.

You cannot/shouldn’t listen to Twitch Extension Pubsub outside of a Twitch Extension

Which is what you seem to be doing.

The list of supported (external) PubSub topics can be found here - PubSub | Twitch Developers

The only supported way to listen to extension pubsub is the Extension Helper JS function (window.Twitch.ext.listen) Extensions Reference | Twitch Developers

Yep that was the issue, I know I did have it in there at one point, so I must of removed it when I was testing stuff.
Now back within the onAuthorized block of code.

So now I have the Back End sending Pubsub Messages, can you give me an example message where there is a basic JSON msg within the “message” field please.
I have tried many ways to try and it returns:

{"error":"Bad Request","status":400,"message":"Missing required parameter \"message\""}

Thanks for teh help so far its helped a lot.


Thanks, will take a look and try something like that.

Yep, that worked, seems I tried everything apart from stringify it.
So I now have Broadcast, Whisper and actual JSON based Messages.

One last question before I go, the actual content that gets displayed on say the video_overlay (like in the Cult of the Lamb game), do I send that atcual html content, or is that already in the Front End along with all the fonts & images and the PubSub Messages just trigger what one is enabled / visible and I just trigger that and send the data to populate that content.

Thanks so much for the help.


How an extension works varies by developer

I like to keep my payloads small.
So I send the data needed to construct dom elements.

there are rules about what you can/should send in the guidelines which you should refer to

Ok thanks, I will go and see what can be sent and then create some basic layouts and work out whats the best route to take.

Once again thanks for all teh help.