(New Programmer) Creating notifications (New followers, subs, etc) system for a chat bot


#1

Greetings!

Hopefully this hasn’t been asked before, but I wasn’t able to find any useful and relevant threads. Anyway, I am trying to build my own Chat Bot with a custom Kappamon-like stream pet in Java using the PircBot framework, but I am still really new to programming in general and the Twitch API. I have successfully completed the basic commands of the bot and a raffle system, but I am currently having trouble figuring how to properly set up the notification for new followers, subscribers, hosts, etc. I have read the documentation for WebHook but I couldn’t understand it. If any of you guys isn’t too busy, I wish you can walk me through the basic process of creating this notification system or possibly give me existing codes that help me understand the process and possibly modify it.

Thanks!
Thunderz


#2

Webhooks require a web accessabile server that you control. If you can’t go web accessable, you can use PubSub instead which has Subscribers from your list

  • You build a web page/program that can receive HTTP GET and HTTP POST requests.

  • You make a outbound API request to Twitch, stating which Webhook you want to subscribe to, and the webpage (aka Callback URL).

  • Twitch will call that webpage with some information and a challenge get GET request.
    If you are expecting this request, you then reply with the challenge, which completes the validation and creation of the webhook

  • When data occurs Twitch then sends a JSON encoded blob in the body of a POST request to your webpage, you process that data and do whatever you want with the response/pass it off to internal systems to relay to your Bot/etc

Webhooks only provide followers and subscribers, from your list

See topics available here: https://dev.twitch.tv/docs/api/webhooks-reference

Hosts you have to get from Twitch Chat

Depends what language you are working in


#3

Hello Barry,

Thank you for the response! Unfortunately I am still unsure how I should do it since I am still really new to this. I am currently working in Java and with the PircBot framework. If you can provide existing codes with detailed comments that I can try to understand and modify, I would really appreciate it!

Thank you!


#4

The bots running process is not normally exposed to the Web, so you wouldn’t build this into the bot itself but create a web visible service to capture the Webhook responses.

I’d do the same with PubSub myself, separate service.

Then both services receive the data and broadcast it internally to the bot if the bot needs that information.

You may want to grab a Twitch chat specific java library instead of PircBot to save you some time.

For the most part if you switch to long polling the API then you just need code that makes you make HTTP Get requests to the API and JSON stuff to parse the responses. I don’t write Java so I don’t have an existing codes with detailed comments


#5

Could you help me developing my commands? I need a command that executes a .batch file on my computer, and If you could with a cooldown, is it possible?


#6

Got it, I will try to look more into it myself. Thank you so much for the help, Barry!


#7

I think you should ping Barry for more information. I am still really new to programming and I am also trying to figure out a cooldown as well, not to mention my commands are just a bunch of if-elses right now haha. Sorry I couldn’t be of much help.


#8

You started your own thread. Please don’t cross post on others threads!