Chat functionality - Do a Search for multiple conditions

Hi there,

I am building my first chat functionality and followed pretty much this blogpost with the suggested database structure
Data type: Message
Data fields:

  • Message content - Text
  • Messages chat - Chat (Not sure what this is even needed for)

Data type: Chat
Data fields:

  • Chat Users - List of Users
  • Chat Messages - List of Messages

This is the logic for creating new chats:

It works fine to create new chats and the according messages, but I only want to have one active chat between any two participants, i.e. when pushing the icon/the entry on a list, instead of creating a new chat between the current user & the parent’s group user and pushing this data to the next page, is there a way to create a workflow to 1) check if there is an existing chat between the current and the parent group’s users and, if the answer is yes, 2) send the data of the existing chat to the next page?

I have tried to work with Do a Search and multiple conditions to filter for this case, but that did not work, because both conditions are checked for separately.

Not sure what to do here.

Thanks,
Leopold

The following condition checks if the number of chats containing the 2 users is different from 0 (that is, there is a chat with the 2 users)

And the following action sends the found chat to the next page

That was quick. Thanks a lot!