Making better chat apps with the "Any Component" blocks

Thanks to @eoinparkinson who suggested this as an idea for a tutorial

User Interface.

The UI for this app is very simple. The OutputColumn is initially empty, with vertical alignment set to flex end. This is eventually where all the chat bubble will go.

Under that is the inputRow which is used to place the test input and the send button side-by-side.

Finally, outside all of this, are two labels; RightLabel and LeftLabel. Although I’ve shown them in the screenshot below, their visibility is set to false. It’s this fact that allows new messages to “appear” in the chat as it progresses.

Who’s taking?

Because this is a demo with just a single user, we’ll use a variable called isMe to mimic who is talking and when.


To expand this example and share it with others would would need to manually keep track of who is talking.

If I’m talking…

The first condition we what to handle is if we are talking. Using the if block we check if the isMe variable is true. If it is true then we can clone the right label, using the clone block. Using the as last in option will add the new message to the bottom of the chat, which is how most messengers work.

If it’s not me talking …

If we’re not the person talking then it must be someone else. Click on the blue gear icon (the mutator) to add an else condition to the bottom of our block.

Doing the opposite.

Finally, if someone else is talking then we display the left label instead.

Flipping the isMe variable and clearing out the TextInput tidies things up for the next message.

Remix this app

If you want to remix this project for yourself, please do by clicking on this link:



Let’s make real-time chat

Ok, now that we’ve got a proof of concept, let’s make a version where it’s not just you talking to yourself! :joy:

Create a cloud variable

To do this all we need is a cloud variable. You can call it anything your like, but since we’re using to to store the text of each message this gets sent, I’ve opted for messageText in this example.

When the message changes

When you create your first cloud variable in your app a new event handler, when cloud variable initializes or changes is added to the variables blocks drawer

This event handler actually handles two events. First off, we check if the cloud variable is “undefined” (which is the case only when we initialise it for the very first time). If this is the case we do nothing, since we don’t want everyone seeing the text “undefined” mysteriously on every screen.

Next we check if the cloud variable matched the text that we’ve just typed. If this is the case then we use the RightLabel and we we didn’t type the most recent message then we use the LeftLabel


Here’s the remix link if you want to have a closer look:


That’s my most favorite! Oh my god! 5 star rating. !


Great job! :100:


Thunkable just got way more powerful with this update. Great tutorial, definitely going to remix this :stuck_out_tongue:


Thunkable just got even cooler with these cloud variables, thanks a lot for the info! Great job :heart:


This is lovely! However, I’m running into an issue.

When I make the starter labels invisible, and then clone them, clone is also invisible (naturally?). How does this example get around this?

1 Like

I you are using this approach then you will also need to set the label’s visible property when a new message is received. In my original posts the visibility is first set to true and then the text is assigned.


Worked! Thanks mate :slight_smile:

1 Like

I’m trying to figure out how to scroll down to a newest label when added (always scroll to the bottom). Think typical messaging UI. Any thoughts on how to do this?

Good question @Arun_Nijhawan - I had a quick look there and couldn’t get it working.

I think in the component settings of you go to Advanced > Positioning there’ll be some combination that will do this. I’ll keep trying but just wanted to update you in case you get if figured out yourself first.

1 Like

I don’t have the best overall understanding of flex positioning. I’ve tried a few different combinations but can’t get it to work yet.

Appreciate the help! Let me know if something works for you

1 Like

Is it possible to save all message?

@Arun_Nijhawan :

I’m also trying to solve this auto-scrolling problem, but I see no way to work around it.

Hi @Domhnall, have you had any idea about automating scroll down?

By the way, thanks for the tutorial, I wish I had found it before :sweat_smile:. My only doubt is about the cloud variable. If we imagine several users using the app simultaneously, wouldnt it be a problem? I stored messages in my ChatApp through RealTime DB and Local Storage. Not easy to find the right route, tho.

@Arun_Nijhawan Maybe this link could help you with better understanding over flex positioning (i found it on another post, but cant remember where. If I find I will reference it later.):

1 Like