# Send Chat message

**URL:** <https://staging-discuss.dev.twitch.com/t/send-chat-message/46185>\
**Category:** Extensions\
**Created:** [June 20, 2023, 4:27pm UTC](https://staging-discuss.dev.twitch.com/t/send-chat-message/46185 "2023-06-20T16:27:22Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andy](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/andy/32/25168_2.png) [@Andy](https://staging-discuss.dev.twitch.com/u/Andy)\
**Post date:** [June 20, 2023, 4:27pm UTC](https://staging-discuss.dev.twitch.com/t/send-chat-message/46185/1 "2023-06-20T16:27:22Z")

</div>

Hello 🙂 i try to send a chat message but i get a 404 error with this code

```auto
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);
    });
}

```

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://staging-discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [June 20, 2023, 4:28pm UTC](https://staging-discuss.dev.twitch.com/t/send-chat-message/46185/2 "2023-06-20T16:28:30Z")

</div>

You have tried to use the _old_ URL for this API

Please see the updated documentation

> **[Reference](https://dev.twitch.tv/docs/api/reference/#send-extension-chat-message)**
>
> Twitch Developer tools and services to integrate Twitch into your development or create interactive experience on twitch.tv.

For the URL and payload changes

Or an example: [https://github.com/BarryCarlyon/twitch\_misc/tree/main/extensions/chat](https://github.com/BarryCarlyon/twitch_misc/tree/main/extensions/chat)

---

<div class="post-metadata">

**Author:** ![Andy](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/andy/32/25168_2.png) [@Andy](https://staging-discuss.dev.twitch.com/u/Andy)\
**Post date:** [June 20, 2023, 4:37pm UTC](https://staging-discuss.dev.twitch.com/t/send-chat-message/46185/3 "2023-06-20T16:37:56Z")

</div>

I still get 404 with the following code

```auto
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

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://staging-discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [June 20, 2023, 4:38pm UTC](https://staging-discuss.dev.twitch.com/t/send-chat-message/46185/4 "2023-06-20T16:38:51Z")

</div>

is the extension installed and active on the text channel?

If you check the _body_ of the response it will help describe the issue

---

<div class="post-metadata">

**Author:** ![Andy](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/andy/32/25168_2.png) [@Andy](https://staging-discuss.dev.twitch.com/u/Andy)\
**Post date:** [June 20, 2023, 4:42pm UTC](https://staging-discuss.dev.twitch.com/t/send-chat-message/46185/5 "2023-06-20T16:42:20Z")

</div>

its right now in local testing. But its installed and the option for chat support in the dev console is set to yes

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://staging-discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [June 20, 2023, 4:43pm UTC](https://staging-discuss.dev.twitch.com/t/send-chat-message/46185/6 "2023-06-20T16:43:47Z")

</div>

Uninstall the extension from the channel  
And install it and activate it into a slot again, in case the permission isn’t enabled right

![image](https://d2spem0quai2ol.cloudfront.net/original/3X/2/8/28d4d6b1e5b3e8282dc482a852068177593e8f90.png)

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

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://staging-discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [June 20, 2023, 4:48pm UTC](https://staging-discuss.dev.twitch.com/t/send-chat-message/46185/7 "2023-06-20T16:48:41Z")

</div>

> [@Andy](#):
>
> ```auto
> 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:

```js
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
        })
    }
)

```

---

<div class="post-metadata">

**Author:** ![Andy](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/andy/32/25168_2.png) [@Andy](https://staging-discuss.dev.twitch.com/u/Andy)\
**Post date:** [June 20, 2023, 4:54pm UTC](https://staging-discuss.dev.twitch.com/t/send-chat-message/46185/8 "2023-06-20T16:54:42Z")

</div>

Thanks its working right now! 🙂 I think this was my last question for now

---

<div class="post-metadata">

**Author:** ![Andy](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/andy/32/25168_2.png) [@Andy](https://staging-discuss.dev.twitch.com/u/Andy)\
**Post date:** [June 22, 2023, 10:15am UTC](https://staging-discuss.dev.twitch.com/t/send-chat-message/46185/9 "2023-06-22T10:15:52Z")

</div>

I was looking in the documentation but i wasnt able to find something. Is it possible to highlite the message my extension is sending?

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://staging-discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [June 22, 2023, 10:18am UTC](https://staging-discuss.dev.twitch.com/t/send-chat-message/46185/10 "2023-06-22T10:18:18Z")

</div>

> [@Andy](#):
>
> Is it possible to highlite the message my extension is sending?

There are no options all you get is

![image](https://d2spem0quai2ol.cloudfront.net/original/3X/b/4/b46ec526a49023eeea692b884ab8fd039c4483bf.png)

For example

---

<div class="post-metadata">

**Author:** ![Andy](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/andy/32/25168_2.png) [@Andy](https://staging-discuss.dev.twitch.com/u/Andy)\
**Post date:** [June 22, 2023, 10:33am UTC](https://staging-discuss.dev.twitch.com/t/send-chat-message/46185/11 "2023-06-22T10:33:11Z")

</div>

oh ok 🙂 thanks

---

<div class="post-metadata">

**Author:** ![Andy](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/andy/32/25168_2.png) [@Andy](https://staging-discuss.dev.twitch.com/u/Andy)\
**Post date:** [June 23, 2023, 10:45pm UTC](https://staging-discuss.dev.twitch.com/t/send-chat-message/46185/12 "2023-06-23T22:45:31Z")

</div>

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](https://api.twitch.tv/helix/extensions/chat) 401

---

<div class="post-metadata">

**Author:** ![Dist](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/dist/32/7192_2.png) [@Dist](https://staging-discuss.dev.twitch.com/u/Dist)\
**Post date:** [June 23, 2023, 10:48pm UTC](https://staging-discuss.dev.twitch.com/t/send-chat-message/46185/13 "2023-06-23T22:48:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Andy](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/andy/32/25168_2.png) [@Andy](https://staging-discuss.dev.twitch.com/u/Andy)\
**Post date:** [June 23, 2023, 10:51pm UTC](https://staging-discuss.dev.twitch.com/t/send-chat-message/46185/14 "2023-06-23T22:51:00Z")

</div>

ah ok 🙂 so i need to send the message from something like a chatbot right ?

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://staging-discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [June 23, 2023, 10:52pm UTC](https://staging-discuss.dev.twitch.com/t/send-chat-message/46185/15 "2023-06-23T22:52:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Andy](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/andy/32/25168_2.png) [@Andy](https://staging-discuss.dev.twitch.com/u/Andy)\
**Post date:** [June 23, 2023, 10:58pm UTC](https://staging-discuss.dev.twitch.com/t/send-chat-message/46185/16 "2023-06-23T22:58:27Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://staging-discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [June 23, 2023, 10:59pm UTC](https://staging-discuss.dev.twitch.com/t/send-chat-message/46185/17 "2023-06-23T22:59:29Z")

</div>

> [@Andy](#):
>
> hmm is there any irc libary which i can use to send the chat message ?

many

> [@Andy](#):
>
> for the other soulution you mean this end point `[Preformatted text](https://api.twitch.tv/helix/extensions/chat)` right?

Yes the endpoint you were using throughout this post

---

<div class="post-metadata">

**Author:** ![Andy](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/andy/32/25168_2.png) [@Andy](https://staging-discuss.dev.twitch.com/u/Andy)\
**Post date:** [June 23, 2023, 11:07pm UTC](https://staging-discuss.dev.twitch.com/t/send-chat-message/46185/18 "2023-06-23T23:07:04Z")

</div>

> [@BarryCarlyon](#):
>
> many

can you recommend one?

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://staging-discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [June 23, 2023, 11:08pm UTC](https://staging-discuss.dev.twitch.com/t/send-chat-message/46185/19 "2023-06-23T23:08:01Z")

</div>

I don’t use libraries for IRC, so no. since I don’t use any.

---

<div class="post-metadata">

**Author:** ![Andy](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/andy/32/25168_2.png) [@Andy](https://staging-discuss.dev.twitch.com/u/Andy)\
**Post date:** [June 23, 2023, 11:56pm UTC](https://staging-discuss.dev.twitch.com/t/send-chat-message/46185/20 "2023-06-23T23:56:56Z")

</div>

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

[Next page](https://staging-discuss.dev.twitch.com/t/send-chat-message/46185.md?page=2)
