# Send a message in chat quickly after clicking a button

**URL:** <https://staging-discuss.dev.twitch.com/t/send-a-message-in-chat-quickly-after-clicking-a-button/40555>\
**Category:** API\
**Created:** [September 12, 2022, 12:22pm UTC](https://staging-discuss.dev.twitch.com/t/send-a-message-in-chat-quickly-after-clicking-a-button/40555 "2022-09-12T12:22:09Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![hipaude](https://avatars.discourse-cdn.com/v4/letter/h/87869e/32.png) [@hipaude](https://staging-discuss.dev.twitch.com/u/hipaude)\
**Post date:** [September 12, 2022, 12:22pm UTC](https://staging-discuss.dev.twitch.com/t/send-a-message-in-chat-quickly-after-clicking-a-button/40555/1 "2022-09-12T12:22:09Z")

</div>

Hello guys !

I have a basic extension that contains a button. When a user clicks on the button, I want “Hello word” to be written in the chat, as if it were the user who had written in the chat, automatically and quickly.

Should I use IRC? But going through a bot to do this seems complicated and useless.

Is there a POST method in the api to send a message as a user? (I did not find)

How could I do otherwise?

---

<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:** [September 12, 2022, 12:24pm UTC](https://staging-discuss.dev.twitch.com/t/send-a-message-in-chat-quickly-after-clicking-a-button/40555/2 "2022-09-12T12:24:26Z")

</div>

This is resonably impractical as it’s resonably impractical to get oAuth tokens for a viewer using an extension.

An Extension would first need to get permission from the user via an external window to send messages to chat.

> [@hipaude](#):
>
> Is there a POST method in the api to send a message as a user? (I did not find)

There isn’t one

> [@hipaude](#):
>
> I have a basic extension that contains a button. When a user clicks on the button, I want “Hello word” to be written in the chat, as if it were the user who had written in the chat, automatically and quickly.

TLDR: it’s not practical to do this.

Why build an Twitch extension to send chat messages. When a user can just chat instead of click a button?

Whats the use case?

---

<div class="post-metadata">

**Author:** ![hipaude](https://avatars.discourse-cdn.com/v4/letter/h/87869e/32.png) [@hipaude](https://staging-discuss.dev.twitch.com/u/hipaude)\
**Post date:** [September 12, 2022, 12:33pm UTC](https://staging-discuss.dev.twitch.com/t/send-a-message-in-chat-quickly-after-clicking-a-button/40555/3 "2022-09-12T12:33:16Z")

</div>

Thank you for the answer.

Here is my use case:

I have a game, in which viewers can write in chat “1”, “2” or “3”. My game receives messages and performs actions in functions (for example: viewer XXX throws a bomb).

I would like to create an extension so that the viewer no longer needs to write in the chat but just click on a button to perform these actions.

Here is the flow I thought of:

click on the button 1 =\> automatically writes the message “1” in the chat =\> my game receives the message “1” =\> it does the action

---

<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:** [September 12, 2022, 12:35pm UTC](https://staging-discuss.dev.twitch.com/t/send-a-message-in-chat-quickly-after-clicking-a-button/40555/4 "2022-09-12T12:35:22Z")

</div>

In that case

- Button press
- sends data to the EBS
- Game connects to the EBS
- Game recieves votes/button clicks from EBS.

So the game connects to your extension backend service instead of TwitchChat.

Then you take out all the chat spam and keep chat tidy instead.

Basically the Extension _replaces_ Chat.

---

<div class="post-metadata">

**Author:** ![hipaude](https://avatars.discourse-cdn.com/v4/letter/h/87869e/32.png) [@hipaude](https://staging-discuss.dev.twitch.com/u/hipaude)\
**Post date:** [September 12, 2022, 12:58pm UTC](https://staging-discuss.dev.twitch.com/t/send-a-message-in-chat-quickly-after-clicking-a-button/40555/5 "2022-09-12T12:58:37Z")

</div>

Ok but I’m afraid that going through my backend is slower than writing in the chat.

Receiving via chat is very fast since it’s twitch servers.  
If I go through my EBS won’t it cause performance problems?

---

<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:** [September 12, 2022, 1:01pm UTC](https://staging-discuss.dev.twitch.com/t/send-a-message-in-chat-quickly-after-clicking-a-button/40555/6 "2022-09-12T13:01:21Z")

</div>

> [@hipaude](#):
>
> Ok but I’m afraid that going through my backend is slower than writing in the chat.

it should be the same amount of speed or quicker.

Extension Button → send to chat → round trip chat server → game recieve  
Extension Button → send to your server → game recieve

Your server should be quicker.

> [@hipaude](#):
>
> If I go through my EBS won’t it cause performance problems?

Shouldn’t do no, it should perform better.

As the “bot”/script won’t have to filter chat to remove messages it’s not interested in.

An can use a preferred socket over a noisy chat socket.

---

<div class="post-metadata">

**Author:** ![system](https://d2spem0quai2ol.cloudfront.net/original/2X/0/05909729875cce3b53e59d5561c4d23bb14948fc.png) [@system](https://staging-discuss.dev.twitch.com/u/system)\
**Post date:** [October 12, 2022, 1:01pm UTC](https://staging-discuss.dev.twitch.com/t/send-a-message-in-chat-quickly-after-clicking-a-button/40555/7 "2022-10-12T13:01:41Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
