Touch Portal already comes with the information specified by the Twitch API that indicates whether a user has chatted for the first time ever on your channel. But this means not per live sessions or chat session. It is important to make this distinction as you might want to act differently.
This guide will be focussing on how to check if a user is chatting the first not ever but just during this session.
We start with creating an Event in the Events tab that will listen to all messages from all users. Keep everything default. This will catch all incoming chat messages.
In our event we need to check if this user has chatted for the first time but to know this we need to keep track of all chatters. This Value will hold all the chatters and we will use that to check if somebody has chatted already.
Moving back to our event we will now check if the user of this event has already chatted. We intent to keep the chatters in the Value Twitch Chatters we created in step 2 so we need to check this Value in an IF statement.
Be sure to note that we are using the local State for the chat event. We do this because chat messages can follow up each other in a very fast pace and if we were to use the global states it would mean that the old events could be using the information from the newer chatter messing up the logic. With using local states we ensure that we only use the information that actually triggered that instance of the event.
Be sure to note that we wrapped the username of the chat message in pipe '|' characters. We do this because this is the only way to ensure later on that we have precisely only that specific user.
In the previous step we checked the Value if it contains the current chatter. When the chatter chatted for the first time it will not be contained in the Value and it will go into the flow of actions within the IF statement. So the first thing we need to do is update our Value to also contain this new chatter to not trigger this event the next time anymore for that specific user.
Be sure to note that we wrapped the username of the chat message again in pipe '|' characters. Lets say you have a user called 'EpicNiceUser01'. If we would not use the pipes it means the Value contains 'EpicNiceUser01'. Now lets see when we get a new chatter that has the name 'NiceUser'. As we do not wrap it with pipe characters it will check and it will already exist in the Value so for that user the event will not continue. As this is not something we want we wrap the names in pipe characters. In that case the Value contains '|EpicNiceUser01|' and with that new user the check would be for '|NiceUser|' which the value does not contain and thus the new chatter will be seen as a new chatter as it should.
At this point we have the structure set up to know whether or not the user of the new chat message is actually chatting for the first time this session. We will now update the text of an OBS source. There are multiple ways of doing this but for now the easiest is to connect a text file to the text source in OBS and update that text file using Touch Portal.
Using the Write to File action we set the text of the OBS to 'Welcome username!'. As this event is triggered for each user for which it has not yet triggered it will update the source text each time a new chatter sends a message.
So how do we now ensure it works for each live session? Well you just need to clear the Value 'Twitch Chatters' each time you go Live. Best place is to add that just before you use the Go-Live action of your choice. Clearing the Value will make Touch Portal forget which users have already chatted and the system starts all over.
You can use this as the basis for more elaborate connectivity with your viewers of course and do lots of nice things like showing specific sources to welcome your users for example.