Skip to main content

Fluent Messaging bug affecting FluentCommunity, FluentCRM, and 3rd party developers

ChatHelper::sendMessage() Bug Report

File: fluent-messaging/app/Services/ChatHelper.php
Method: sendMessage($messageBody, $recipientId, $senderId)
Version: FluentCommunity 2.3.0

The Bug

Messages sent programmatically through ChatHelper.php results in sender / recipient gets swapped, so it looks like the recipient initiated the message.

The method signature says parameter 2 is $recipientId and parameter 3 is $senderId. But internally, the
variable assignments are swapped:

// Line 401-402 of ChatHelper.php
$recipient = User::find($senderId); // ← uses senderId to find "recipient"
$sender = User::find($recipientId); // ← uses recipientId to find "sender"

Then message.user_id is set to $sender->ID β€” which is actually the recipient's ID because of the swap.
The message appears to come FROM the person it was sent TO.

How to reproduce

// Intent: Admin (user 1) sends "hello" to Member (user 160)
ChatHelper::sendMessage("hello", 160, 1);

// Expected: Message appears FROM Admin TO Member
// Actual: Message appears FROM Member TO Admin

FluentCRM's own action is also affected

CrmSendMessageAction.php line 101 calls:
ChatHelper::sendMessage($messageBody, $recipient->ID, $sender->ID);

This follows the method signature correctly, but hits the same internal swap β€” so FluentCRM's native
"Send Message" automation action also shows messages from the wrong sender. This isn't just a
third-party issue; it affects FluentCRM's messages integration.

Fix

Swap the variable assignments at lines 401-402 of ChatHelper.php:

// Current (broken)
$recipient = User::find($senderId);
$sender = User::find($recipientId);

// Fix
$recipient = User::find($recipientId);
$sender = User::find($senderId);

Will look into this, thank you for reporting.

LaConya Murray

Tawsif Ahmed RiyadΒ hello. What's the status of this?

LaConya Murray, fixed in dev environment.

LaConya Murray

Tawsif Ahmed RiyadΒ does that mean my automations will work properly now?

LaConya Murray, after the official release. For immediate fix, use the solution (at the bottom) of this post.

Swap the variable assignments at lines 401-402 of ChatHelper.php:

// Current (broken)
$recipient = User::find($senderId);
$sender = User::find($recipientId);

// Fix
$recipient = User::find($recipientId);
$sender = User::find($senderId);

Dakota Snow

Thank you Jeff MapesΒ for the fix and hope they patch this soon