How do you send Pubsub Whisper from EBS?

Looking at the docs Extensions > Reference > JavaScript Helper > listen

“Once the extension is listening, the EBS or broadcaster can send an individualized message to the channel.”

I understand that the broadcaster could use send() through the extensions JavaScript Helper to send a whisper. I need to know how to send a whisper from the EBS to a listening clientId.

Extensions > Reference > Send Extension PubSub Message only covers global & channel broadcast messages (which I have working fine). I need to be able to send whisper messages from the EBS.

Any help pointing me in the right direction would be appreciated.

I don’t think I remember seeing that in the docs anywhere. Have you tried sending to the channel "whisper-<userId>" (from the listen docs)?

I think, it’s a feature that’s being removed due to lack of use by anyone.

I forget when I saw that though. Not sure you ever could do it from the EBS.

THe hello world example initiates from the Client Side. But the payload format for from EBS should be identical to that

It is still active, I am doing it on one of my extensions.
Based on the docs
You have to give an array of users, you can have only one user. You have to use the opaque ID from the jwt of the user for that. Not the twitch user id.

"targets": [
      "whisper-OPAQUE_ID_OF_USER"
    ]

Thanks, The API is accepting the Post with status code 204 (undefined). But the listening client user’s aren’t getting a message.

I’m using these for my JWT:
(edit: userId below is decodedToken.opaque_user_id)
(edit 2: find working code below)

{
   ...
    "role": "external",
    "channel_id": "whisper-" + userId,
    "pubsub_perms": { "send":[ "whisper-*" ] } 
};

And in the body:

{
    ....
    "targets": [ "whisper-" + userId]
}

Posting to:

 'https://api.twitch.tv/extensions/message/whisper-'+ userId

And the client listening like this:

window.Twitch.ext.onAuthorized(function(auth) {
    ...
    window.Twitch.ext.listen("whisper-" + auth.userId, function(target, contentType, message){
        console.log("Hello World");
    });
});

Any help getting this to work would be appreciated.

On the frontend the opaque user id is the property userId , from the on Authorized method
On the EBS the opaque user id is opaque_user_id , from the decoded token

Right now you are sending to the twitch user id, not his opaque user id.

Good catch, I am now broadcasting to whisper-<opaque_user_id>.

The client listener still doesn’t receive the message.

I have continued trying to debug the issue & sadly might be moving on to implement another solution where I have full control of the connections.

After further testing I realized that I should be posting to the channel ID rather than the whisper channel.
Thanks @Breci for your help pointing me in the right direction.

Here is the working code:

{
   ...
    "role": "external",
    "channel_id": decodedToken.channel_id,
    "pubsub_perms": { "send":[ "whisper-*" ] } 
};

And in the body:

{
    ....
    "targets": [  "whisper-" + decodedToken.opaque_user_id ]
}

Posting to:

 'https://api.twitch.tv/extensions/message/' + decodedToken.channel_id
1 Like

Apologies for reviving the thread, but did you use the developer rig for this? Just wondering, since when using the rig, the message endpoint seems to be sending broadcasts instead of whispers.

Well this issue pertains to sending a whisper from a EBS not from the front end. Where the front end would be loaded from inside the dev rig.

You can look at the hello world/blue button example for a working whisper example.

My intent was to send a targeted message to a specific user from the EBS using the user’s opaque user id, using the same approach as outlined in safacon’s previous post.

The issue that I’m running into is that even when I specify the target as “whisper-${opaqueId}” when posting to the “extensions/message/${channelId}” endpoint, all of the front ends receive the message in their broadcast listeners.

So I’m wondering if the rig doesn’t handle whispers as the target.

You mentioned you changed the target, but did you also change the pubsub_perms from { send: ['*'] } to { "send":[ "whisper-*" ] } as safacon showed in his working code?

I had it set to pubsub_perms: { send: ['*', 'whisper-*'] }, but setting to pubsub_perms: { send: ['whisper-*'] } had the same result.

I just got the whisper pubsub working on my new extension, I hope you’re wrong about it going out the window @BarryCarlyon because I only just discovered its a thing and it’s useful. Maybe it’s not used as it’s not really mentioned as a feature or is but not really discoverable.

I’m now using it for items specifically for the broadcaster dashboard, like “have external auth’d” or “this person submitted an answer for you, but i haven’t told everyone else”

It’s easier than using websockets on your EBS

To answer your earlier question: I don’t use the dev rig in my development workflow. I use https:// to serve the files over then net and hard refresh after uploading changes. But I imagine that the dev rig is meant to work the same as a live test…

If you upload the files to do a “Hosted Test” and still get the same results then it is a code problem. If using “Hosted Test” allows whispers to be sent properly then it sounds like a bug with the dev rig & should be reported.

Hi friend,

Which scope do you used to get bearer token? I’m trying to “whispers:edit” but response is “JWT could not be verified”

Extensions pubsub uses JWT auth, not oAuth

ahh ok! thank you

A post was split to a new topic: Sending a PubSub Whisper from EBS