Andy
June 20, 2023, 4:27pm
1
Hello i try to send a chat message but i get a 404 error with this code
function chatMessage() {
var url = "https://api.twitch.tv/extensions/" + clientId + "/0.0.1/channels/" + channelID + "/chat";
console.log(url);
var jwt = token;
var id = clientId;
var message = "test";
fetch({
method: 'POST',
url: url,
headers: {
'Content-Type': "application/json",
'Client-ID': id,
'Authorization': "Bearer " + jwt,
},
body: { text: message }
}).catch ((err) => {
console.log(err);
});
}
You have tried to use the old URL for this API
Please see the updated documentation
For the URL and payload changes
Or an example: https://github.com/BarryCarlyon/twitch_misc/tree/main/extensions/chat
Andy
June 20, 2023, 4:37pm
3
I still get 404 with the following code
function chatMessage() {
var url = "https://api.twitch.tv/helix/extensions/chat?broadcaster_id=" + channelID;
console.log(url);
var jwt = token;
var id = clientId;
var message = "test";
fetch({
method: 'POST',
url: url,
headers: {
'Content-Type': "application/json",
'Client-ID': id,
'Authorization': "Bearer " + jwt,
},
body: { text: message }
}).catch ((err) => {
console.log(err);
});
}
i changed only the url
is the extension installed and active on the text channel?
If you check the body of the response it will help describe the issue
Andy
June 20, 2023, 4:42pm
5
its right now in local testing. But its installed and the option for chat support in the dev console is set to yes
Uninstall the extension from the channel
And install it and activate it into a slot again, in case the permission isn’t enabled right
Then under manage permissions in the dashboard check the chat toggle is enabled
Then if it doesn’t work
Check the HTTP Body of the response, not just the HTTP Code
Andy:
fetch({
method: 'POST',
url: url,
headers: {
'Content-Type': "application/json",
'Client-ID': id,
'Authorization': "Bearer " + jwt,
},
body: { text: message }
}).catch ((err) => {
Also jsut realised your body is incomplete.
For Example:
fetch(
"https://api.twitch.tv/helix/extensions/chat",
{
method: "POST",
headers: {
"Client-ID": config.client_id,
"Authorization": "Bearer " + sigChat,
"Content-Type": 'application/json'
},
body: JSON.stringify({
broadcaster_id: config.channel_id,
text: "This is a Test Message Kappa",
extension_id: config.client_id,
extension_version: config.extension_version
})
}
)
1 Like
Andy
June 20, 2023, 4:54pm
8
Thanks its working right now! I think this was my last question for now
Andy
June 22, 2023, 10:15am
9
I was looking in the documentation but i wasnt able to find something. Is it possible to highlite the message my extension is sending?
There are no options all you get is
For example
Andy
June 23, 2023, 10:45pm
12
ok something wired happend. I used the code from yesterday and the extension will send the chat message when i use the extension with the Brodcaster account. But if i log on a other account i get this error
POST https://api.twitch.tv/helix/extensions/chat 401
Dist
June 23, 2023, 10:48pm
13
Only the Broadcaster, or your EBS using a JWT you create/sign, can send Extension chat messages. Otherwise there would be nothing stopping any user from attempting to send malicious chat messages as your Extension.
Andy
June 23, 2023, 10:51pm
14
ah ok so i need to send the message from something like a chatbot right ?
Either your EBS using the Send Chat endpoint
Or a chatbot
Which is basically the same thing in this scenario
Since you’ll need to get the event from the extension to your backend.
Then your backend can send it out on whatever your preference is
Andy
June 23, 2023, 10:58pm
16
hmm is there any irc libary which i can use to send the chat message ? for the other soulution you mean this end point [Preformatted text](https://api.twitch.tv/helix/extensions/chat)
right?
many
Yes the endpoint you were using throughout this post
I don’t use libraries for IRC, so no. since I don’t use any.
Andy
June 23, 2023, 11:56pm
20
ok i got it now via the irc. But is there also a way to get the oauth token for my chat bot account automaticly ? right now i just was creating one manual