this reply was written BEFORE coffee so I totally answered the wrong question with an answer
Only the broadcasters JWT will be able to do this. ← Ignore I can’t read before coffee
Note: it doesn’t send a Whisper whisper, it just sends a Extension PubSub message to the extension front end that the user is using (and it eats the channel rate since it’s send to channel+user combo)
This should work, again, only with the Broadcasters JWT in a “front end only” scenario.
Generally I only/always do all my Extension PubSub traffic via the EBS. And sign an external JWT.
(Not tested just written off the top of my head)
fetch(
'https://api.twitch.tv/helix/extensions/pubsub',
{
method: 'POST',
headers: {
'Client-ID': the_extension_client_id,
'Authorization': 'Bearer ' + window.Twitch.ext.viewer.sessionToken
},
body: JSON.stringify({
target: ['whisper-USERSOPAQUEID'],
broadcaster_id: window.Twitch.ext.viewer.id,
is_global_broadcast: false,
message: JSON.stringify(YOUR MESSAGE PAYLOAD)
})
}
)
.then(resp => {
console.log(resp);
})
.catch(err => {
console.log(err);
});
Note: you will need the target users OPAQUEID in order to broadcast to them.
You might find it easier to send the messages over the channel or global feeds and include the “true” user_id in the messages so your frontend knows to parse it for that user.