Have you ever assumed how hard it seems to be to create a web chat app?
With OutSystems Reactive Apps building a chat, it’s fast and easy!
For our app, we need an entity called Message, containing the data about who sent a message, who’s the receiver, the message itself, and the date and time.
First, drag-and-drop a list widget. Assign it to the aggregate’s list.
Then, drag-and-drop the “Chat Message” pattern inside the list.
That pattern has placeholders for the data. Drag the user’s name and the text message inside those placeholders.
The time of the message is set on the widget’s properties. Set the time to the correspondent attribute.
One of the properties allows us to align the messages on the right if sent by the logged user. Set that property to “Get user id” equals “sent by” attribute value.
Let’s do something similar to the status, which can be “sent” or “received.” But in this case, let’s use the “if built-in function”: if the user sending the message is the same as the logged user, the message was sent. Otherwise, it was received. Thus, changing the icon below the message.
With a simple input form that saves messages on the “Message Entity,” the user can now send messages.