Reading Live Chat Messages

Hello everyone,

I want to read the messages (chat) on a live stream. I could make it work with PHP and IRC. I’m trying to find another way, like an API, is there something available right now? ChatGPT offers some endpoints like:

$url = "https://api.twitch.tv/helix/chat/recent_messages?channel_id=CHANNEL_ID";

or

$url = "https://api.twitch.tv/helix/channels/events?broadcaster_id=$channel_id&type=chat_message&first=100";

But I cannot find the documentation.

Any advice or comments?

Thanks in advance.

Mauricio

chatGPT seems to have just made shit up here…

You want IRC or EventSub

EventSub gives you Webhooks or Websockets.
And well IRC is websockets anyway

Hi @BarryCarlyon, thanks for your answer!

I will take a look at the documentation but seems that the IRC integration already have is one of the suggested solutions.

May I ask, if you have something to share, right now I ave a PHP file with a “while” loop listening to the messages. I run fo testing in the command line and I get the messages on the console.

Is there any “architecture” or “solution” to handle this kind of process that needs to be running all the time in the background? Because I probably need to listen to different channels at the same time.

No sure how to google it.

Thanks again for you time.
Mauricio

back when I did my bots on PHP I use a library called smartIRC.

Your problem isn’t “how do I run a twitch chat bot on PHP” it’s “how do I run an IRC bot using PHP”

1 Like