Help Needed: Preventing Duplicate Chats in FlutterFlow

Actions & Logic

I’m using the default chat flow in FlutterFlow for my app's chat feature. The setup works well, but I’m facing an issue with duplicate chat creation.

Problem: When a user initiates a chat with another user, a new chat document is created in the database. If the same user tries to start another chat with the same person later, a new chat document is created again instead of navigating to the existing chat.

Question: How can I modify the chat flow to:

  1. Check if a chat already exists between the current user and the selected user.

  2. Navigate to the existing chat if found, or create a new chat if none exists.

Any guidance, code snippets, or documentation references would be greatly appreciated!

Thanks in advance for your help!

@flutterflow team — Great work on the default chat flow! Is there a reason why this logic isn’t included?




The image below shows the action setup from the button to create a new chat.



What have you tried so far?

I've tried to add a custom function (with the help of GPT), but I wasn't successful; I'm only two months old in FF land.

Did you check FlutterFlow's Documentation for this topic?
Yes
4 replies