* fix: update contact creation in messages.update event spec and remove redundant content update test
* fix: enhance message type detection for document messages and improve content retrieval
* fix: add support for edited messages and improve document message handling
* chore: enhance message filtering logic to ignore specific message types
* test: add support for messages with captions in document messages
* test: add handling for edited messages to prevent contact and message creation
* fix: improve message handling by ignoring specific message types
* fix: add support to ignore context messages to prevent contact and message creation
* refactor: organize incoming baileys specs
* feat: add store in additional_attributes to conversation model
* feat: set default mark_as_read to true in additional_attributes for conversation params
* fix: remove mark_as_read from additional_attributes in conversation
* refactor: move message read logic to mark_messages_as_read method in ConversationsController
* feat: add 'Mark messages as read' option to WhatsApp channel settings
* feat: add 'mark_as_read' option in factorie for WhatsApp channel
* feat: integrate Checkbox component for 'mark as read' option in WhatsApp settings
* fix: ensure 'mark_as_read' option is included in channel creation payload
* feat: add 'Mark as read' settings for WhatsApp inbox, including UI and state management
* chore: remove redundant content update test from IncomingMessageBaileysService spec
* feat: update 'Mark as read' label to 'Read receipts' and replace Checkbox with Switch component in WhatsApp settings
* fix: handle potential nil value for 'mark_as_read' in provider config
* feat: refactor provider config to streamline channel creation with 'mark_as_read' option
* feat: add test for MESSAGE_READ event dispatch in update_last_seen action
* fix: update subheader for 'Mark as read' setting to read receipt behavior in WhatsApp
* feat: update mark_messages_as_read behavior to handle false value in provider config
* chore: update label for 'Mark as read' option
* feat: update update_last_seen to send WhatsApp read receipt for WhatsApp channels
* test: remove MESSAGE_READ event dispatch tests in wrong file
* feat: enhance update_last_seen behavior for WhatsApp channel to conditionally dispatch messages.read event
* feat: update update_last_seen to dispatch messages.read event
* test: refactor update_last_seen tests
* chore: refactor to ensure provider_service responds to read_messages before ensure the mark_as_read provider config
* test: enhance #read_messages with provider config mark_as_read expected behaviors
* chore: clarify test names and remove useless expect
---------
Co-authored-by: gabrieljablonski <contact@gabrieljablonski.com>
…on (#11584)"
This reverts commit b5ebc47637.
# Pull Request Template
## Description
Please include a summary of the change and issue(s) fixed. Also, mention
relevant motivation, context, and any dependencies that this change
requires.
Fixes # (issue)
## Type of change
Please delete options that are not relevant.
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality not to work as expected)
- [ ] This change requires a documentation update
## How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce. Please also list any relevant details
for your test configuration.
## Checklist:
- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my code
- [ ] I have commented on my code, particularly in hard-to-understand
areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream
modules
- Extended CsatSurveyResponsePolicy to support report_manage permission
- Added enterprise extension module following existing pattern
- Users with report_manage custom role can now access CSAT index,
metrics, and download
- Added comprehensive tests for both base and enterprise policy behavior
* feat: implement connection update handling for Baileys
* feat: add message update handling for Baileys integration
* feat: implement message processing and handling for Baileys integration
* fix: clear message source ID from Redis when contact is not found
* fix: raise error when attachment file is not found during media handling
* refactor: reorganize includes in incoming_message_baileys_service
* feat: add helper methods for message handling in Baileys integration
* feat: include IncomingMessageServiceHelpers in MessagesUpdate module
* refactor: replace IncomingMessageServiceHelpers with BaileysHandlers::Helpers in connection_update, messages_update, and messages_upsert modules
* fix: mark message as unsupported when attachment file is not found
* refactor: remove unnecessary namespace for includes in IncomingMessageBaileysService
* refactor: add private visibility to methods in connection_update, helpers, messages_update, and messages_upsert modules
* refactor: preserve original message in handle_edited_content method
* fix: attachment error handling
* feat: implement conversation creation logic in set_conversation method
* refactor: remove unused error handling for attachment not found in messages update and upsert
* feat: update last seen timestamps in conversation on message status update
* feat: log warning for unsupported message update status in Baileys service
* chore: merge
---------
Co-authored-by: gabrieljablonski <contact@gabrieljablonski.com>
* feat: update message status and last seen timestamps
* test: enhance message status and content update handling in Baileys service tests
* feat: update last seen timestamps in conversation on message update
* chore: simplify status update condition for incoming messages
* feat: optimize last seen timestamp updates in conversation
* chore: improve last seen spec
* feat: update message content handling in content update scenario
Fixes https://github.com/chatwoot/chatwoot/issues/11569
## Problem
On platforms like WhatsApp and Facebook Messenger, customers cannot
reply to messages after 24 hours (or other channel-specific messaging
windows). Despite this limitation, the system continued sending CSAT
surveys to customers outside their messaging window, making it
impossible for them to respond.
## Solution
Added a check for `conversation.can_reply?` in the
`should_send_csat_survey?` method. This leverages the existing
`MessageWindowService` which already handles all channel-specific
messaging window logic.
- Enable jobs by default when a copilot thread or a message is created.
- Rename thread_id to copilot_thread_id to keep it consistent with the
model name
- Add a spec for search_linear_issues service
* fix: correct structure of lastMessages in message content
* fix: update send_message to store external_created_at timestamp with result from request
* fix: filter incoming messages for unread conversation logic
* fix: improve extraction of message timestamp in send_message method
* feat: enhance message timestamp extraction and update logic in send_message method
* refactor: send_message to improve error handling and update external_created_at timestamp
* chore: move message timestamp extraction to helper
* fix: use message timestamp extract on incoming
* fix: update unread_conversation to handle last message correctly for Baileys provider
---------
Co-authored-by: gabrieljablonski <contact@gabrieljablonski.com>
- Automate the deletion of accounts that have requested deletion via
account settings.
- Add a Sidekiq job that runs daily to find accounts that have requested
deletion and have passed the 7-day window.
- This job deletes the account and then soft-deletes users if they do
not belong to any other account.
- This job also sends an email to the Chatwoot instance admin for
compliance purposes.
- The Chatwoot instance admin's email is configurable via the
`CHATWOOT_INSTANCE_ADMIN_EMAIL` global config.
---------
Co-authored-by: Sojan Jose <sojan@pepalo.com>
- Add API support for creating a thread
- Add API support for creating a message
- Remove uuid from thread (no longer required, we will use existing
websocket connection to send messages)
- Update message_type to a column (user, assistant, assistant_thinking)
A while back, we added a UX enhancement that disabled sending the OOO
message when an agent had replied to the conversation in the last 5
minutes.
https://github.com/chatwoot/chatwoot/pull/11073
This would not send a "we will be back" message even if that reply was a
private note. This would break for bots that posted private notes, and
even for agents who need to just add a note and not actually reply to
the email.
* feat: add MESSAGES_UNREAD event and implement unread action in ConversationsController
* feat: rename MESSAGES_UNREAD event to CONVERSATION_UNREAD and update unread action in ConversationsController
* feat: implement send_unread_conversation method and update conversation_unread event handling
* feat: add test for dispatching conversation.unread event in ConversationsController
* feat: add conversation_unread event handling in ChannelListener
* feat: add send_unread_conversation method and corresponding tests in Whatsapp channel
* feat: add logging for nil last_message in send_unread_conversation method
* feat: add send_unread_conversation to error handling methods
* feat: implement send_unread_conversation method with logging for nil last_message
* fix: add nil check and logging for last_message in send_unread_conversation method
* fix: update conversation_unread method to call unread_conversation instead of send_unread_conversation
* refactor: rename send_unread_conversation to unread_conversation and update method implementation
* refactor: rename send_unread_conversation to send_unread_messages and update implementation to handle multiple messages
* refactor: rename send_read_messages to read_messages and send_unread_messages to unread_message for clarity
* refactor: rename send_read_messages to read_messages and send_unread_messages to unread_message for clarity
* refactor: rename send_read_messages to read_messages for consistency
* feat: add get_media method to retrieve media from provider service
* feat: implement media attachment handling and add media_url method
* feat: add includeMedia option to webhook request in WhatsappBaileysService
* feat: add get_media method to error handling in WhatsappBaileysService
* feat: add includeMedia option to webhook request in WhatsappBaileysService spec
* feat: add media_url method to retrieve media URL in WhatsappBaileysService spec
* refactor: remove get_media method from WhatsappBaileysService and Channel::Whatsapp
* refactor: streamline message handling in IncomingMessageBaileysService spec
* chore: add todo comment about includeMedia
* refactor: simplify media download stubbing in IncomingMessageBaileysService spec
* refactor: simplify media download stubbing in IncomingMessageBaileysService spec
* fix: add missing end statements missed in rebase
---------
Co-authored-by: gabrieljablonski <contact@gabrieljablonski.com>
- Refactor email validation logic to be a service
- Use the service for both email/pass signup and Google SSO
- fix account email validation during signup
- Use `blocked_domain` setting for both email/pass signup and Google
Sign In [`BLOCKED_DOMAIN` via GlobalConfig]
- add specs for `account_builder`
- add specs for the new service
---------
Co-authored-by: Sojan Jose <sojan@pepalo.com>
Earlier, we were manually checking if a user was an agent and filtering
their conversations based on inboxes. This logic should have been part
of the conversation permissions service.
This PR moves the check to the right place and updates the logic
accordingly.
Other updates:
- Add support for search_conversations service for copilot.
- Use PermissionFilterService in contacts/conversations, conversations,
copilot search_conversations.
---------
Co-authored-by: Sojan <sojan@pepalo.com>
Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com>
Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
We made so many improvements for CSAT via https://github.com/chatwoot/chatwoot/pull/11485. However, we missed showing message content in the dashboard for CSAT URLs created in non-widget inboxes. This PR fixes the issue by ensuring that CSAT-configured messages are passed along with CSAT responses, otherwise defaulting to the translation.
This PR adds a tool to search Linear issues. If the integration is
enabled for the account, the tool will return results as expected. Also
introduces support for an `active?` method, which allows third-party
Copilot tools to be conditionally enabled based on the status of the
integration on the account.
This PR introduces the concept of a tool registry. The implementation is
straightforward: you can define a tool by creating a class with a
function name. The function name gets registered in the registry and can
be referenced during LLM calls. When the LLM invokes a tool using the
registered name, the registry locates and executes the appropriate tool.
If the LLM calls an unregistered tool, the registry returns an error
indicating that the tool is not defined.
Show captain messages under the name of the assistant which generated
the message.
- Add support for `Captain::Assistant` sender type
- Add push_event_data for captain_assistants
- Add activity message handler for captain_assistants
- Update UI to show captain messages under the name of the assistant
- Fix the issue where openAI errors when image is sent
- Add support for custom name of the assistant
---------
Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com>
* feat: enhance message_content_attributes to handle reaction messages
* fix: update external_created_at to use raw message timestamp directly
* fix: update readableTime to use externalCreatedAt if available
* feat: enhance timestamp formatting with localization support for pt-BR
* feat: add note to message_content_attributes about external_created_at timestamp
* fix: add missing newline at end of conversation.json files
* test: add additional cases for messageTimestamp formatting
* chore: remove outdated note about external_created_at in message_content_attributes
* refactor: remove out of scope task changes
* feat: add test for setting external_created_at in content_attributes on new message
* fix: use last_seen_at message query conditions only if present
* test: add SQL execution tests for messages_read with last_seen_at conditions
* fix: ensure SQL notifications are unsubscribed after message read events
* refactor: streamline message query in messages_read method
* test: update messages_read specs to test expected behavior
* refactor: simplify readableTime computation by removing unnecessary externalCreatedAt check
* fix: update readableTime computation to use externalCreatedAt if available
* test: enhance messages_read specs to use a consistent event object
* test: refactor spec for creating message with external_created_at in messages.upsert event
* Refactor incoming message specs for clarity and consistency
- Consolidated raw_message and params definitions using let blocks for better readability.
- Updated tests to directly manipulate raw_message and params within individual examples.
- Ensured consistent naming and structure across different message types.
- Improved assertions to reflect changes in message attributes and expectations.
* refactor: streamline messages.update event handling and improve test clarity
* test: refactor messages.upsert event specs to use a consistent timestamp
* test: enhance reaction message handling in incoming_message_baileys_service_spec
# Pull Request Template
## Description
This PR introduces basic customization options for the CSAT survey:
* **Display Type**: Option to use star ratings instead of emojis.
* **Message Text**: Customize the survey message (up to 200 characters).
* **Survey Rules**: Send surveys based on labels — trigger when a
conversation has or doesn't have a specific label.
Fixes
https://linear.app/chatwoot/document/improve-csat-responses-a61cf30e054e
## Type of change
- [x] New feature (non-breaking change which adds functionality)
## How Has This Been Tested?
### Loom videos
**Website Channel (Widget)**
https://www.loom.com/share/7f47836cde7940ae9d17b7997d060a18?sid=aad2ad0a-140a-4a09-8829-e01fa2e102c5
**Email Channel (Survey link)**
https://www.loom.com/share/e92f4c4c0f73417ba300a25885e093ce?sid=4bb006f0-1c2a-4352-a232-8bf684e3d757
## Checklist:
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my code
- [x] I have commented on my code, particularly in hard-to-understand
areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream
modules
---------
Co-authored-by: Pranav <pranavrajs@gmail.com>
This PR introduces support for optionally exposing more data during LLM
function calls. This will be useful as we expand Copilot’s capabilities.
Changes included:
- Add support for ArticleLlmFormatter
- Add missing specs for ContactLLMFormatter and ArticleLLMFormatter
- Add additional spec for ConversationLLMFormatter based on config