Commit Graph

123 Commits

Author SHA1 Message Date
Shivam Mishra
75c57ad039 feat: use captain endpoint config in legacy OpenAI base service (#12060)
This PR migrates the legacy OpenAI integration (where users provide
their own API keys) from using hardcoded `https://api.openai.com`
endpoints to use the configurable `CAPTAIN_OPEN_AI_ENDPOINT` from the
captain configuration. This ensures consistency across all OpenAI
integrations in the platform.

## Changes

- Updated `lib/integrations/openai_base_service.rb` to use captain
endpoint config
- Updated `enterprise/app/models/enterprise/concerns/article.rb` to use
captain endpoint config
- Removed unused `enterprise/lib/chat_gpt.rb` class
- Added tests for endpoint configuration behavior
2025-07-30 08:58:27 +04:00
Muhsin Keloth
99ec18c95b feat: Add support for multiple attachments in Slack (#11958) 2025-07-17 09:38:46 +05:30
Muhsin Keloth
01acbe3cda feat: Add user attribution to Linear integration with actor authorization (#11774)
- Add `actor=app` parameter to Linear OAuth authorization URL for
consistent app-level authorization
https://linear.app/developers/oauth-actor-authorization
- Implement user attribution for Linear issue creation and linking using
`createAsUser` and `displayIconUrl` parameters
- Enhance Linear integration to properly attribute actions to specific
Chatwoot agents

**Note**
- The displayIconUrl parameter is being sent correctly to Linear's
GraphQL API (verified through testing), but there is an issues with icon
is not attaching properly.
- We might need to disconnect the integration connect again.
2025-07-01 16:49:26 +05:30
Muhsin Keloth
5487d4c615 fix: Include private channels in Slack integration pagination (#11751)
Fixes
https://linear.app/chatwoot/issue/CW-4507/slack-integration-not-showing-private-channels
  ## Problem

When the Slack workspace has many channels (requiring multiple API
requests to fetch all of them), our system was only looking for private
channels in the first batch of results. All subsequent batches were
missing the instruction to include private channels, so they only
returned public channels.

  ## Root Cause
- Initial API call correctly specified `types:
'public_channel,private_channel'`
- Pagination loop only passed `cursor` parameter, omitting `types` and
`exclude_archived`
  - Subsequent pages defaulted to public channels only

  ## Changes
- Fixed parameter formatting in `types` (removed space:
`'public_channel, private_channel'` →
`'public_channel,private_channel'`)
- Added missing `types` and `exclude_archived` parameters to paginated
`conversations_list` calls

---------

Co-authored-by: Sojan Jose <sojan@pepalo.com>
2025-06-17 16:44:56 -07:00
Muhsin Keloth
f4381e3b5d feat: Add activity messages for linear actions (#11654) 2025-06-13 11:57:11 +05:30
Sojan Jose
10363e77ad chore: Add region option to Dialogflow integration (#11510)
## Summary
- support region option when configuring Dialogflow integration
- connect to region endpoint when set
- use session identification based on the region

Fixes: https://github.com/chatwoot/chatwoot/issues/4129
2025-06-05 20:01:17 -05:00
Sojan Jose
c2d8e2ad77 feat: move Slack config to installation settings (#11548)
- enable Slack Configuration via InstallationConfig
- list Slack integration in super admin settings
2025-05-23 01:07:35 -07:00
Pranav
cbdac45824 feat: Improve Captain interactions, activity messages (#11493)
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>
2025-05-16 19:27:57 -07:00
Sojan Jose
630826baed feat: Implement UI for Agent Bots in settings and remove CSML support (#11276)
- Add agent bots management UI in settings with avatar upload
- Enable agent bot configuration for all inbox types
- Implement proper CRUD operations with webhook URL support
- Fix agent bots menu item visibility in settings sidebar
- Remove all CSML-related code and features
- Add migration to convert existing CSML bots to webhook bots
- Simplify agent bot model and services to focus on webhook bots
- Improve UI to differentiate between system bots and account bots

## Video 





https://github.com/user-attachments/assets/3f4edbb7-b758-468c-8dd6-a9537b983f7d

---------

Co-authored-by: iamsivin <iamsivin@gmail.com>
Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com>
Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
Co-authored-by: Pranav <pranav@chatwoot.com>
2025-04-16 18:02:49 +05:30
Sivin Varghese
72509f9e38 chore: Improve translation service with HTML and plain text support (#11305)
# Pull Request Template

## Description

This PR changes to translation to properly handle different content
types during translation.

### Changes

1. **Email translation with HTML support**
   - Properly detects and preserves HTML content from emails
   - Sets `mime_type` to 'text/html' when HTML content is present

2. **Email translation with plain text support**
   - Falls back to email text content when HTML is not available
- Sets `mime_type` to 'text/plain' when HTML is not available and
content type includes 'text/plain'

3. **Plain message with plain text support (Non email channels)**
   - Sets `mime_type` to 'text/plain' for non-email channels
- Fixes an issue where Markdown formatting was being lost due to
incorrect `mime_type`
   
**Note**: Translation for very long emails is not currently supported.

Fixes
https://linear.app/chatwoot/issue/CW-4244/translate-button-doesnt-work-in-email-channels

## Type of change

- [x] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)

## How Has This Been Tested?

**Loom video**

https://www.loom.com/share/8f8428ed2cfe415ea5cb6c547c070f00?sid=eab9fa11-05f8-4838-9181-334bee1023c4


## 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
2025-04-16 17:59:06 +05:30
Muhsin Keloth
a0cf25ccde chore: Rescue slack link unfurling errors. (#11033)
Fixes
https://linear.app/chatwoot/issue/CW-4122/slackwebapierrorsmissingscope-missing-scope

This PR adds the ability to handle errors when scopes are missing during
link unfurling. Since link unfurling is just a nice-to-have feature that
doesn't affect core functionality, we will silently ignore these errors.

---------

Co-authored-by: Sojan <sojan@pepalo.com>
2025-03-06 15:57:16 -08:00
Muhsin Keloth
12134f9391 feat: Linear OAuth 2.0 (#10851)
Fixes https://linear.app/chatwoot/issue/CW-3417/oauth-20-authentication
We are planning to publish the Chatwoot app in the Linear [integration
list](https://linear.app/docs/integration-directory). While we currently
use token-based authentication, Linear recommends OAuth2 authentication.
This PR implements OAuth2 support.

---------

Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com>
Co-authored-by: Shivam Mishra <scm.mymail@gmail.com>
2025-02-27 18:15:53 +05:30
Tarush Nagpal
11a7414dc0 feat: Upgrade Dyte apis to v2 (#10706)
# Pull Request Template

## Description

Dyte V1 API's are soon going to be deprecated, hence making sure we
update Chatwoot before that happens

Fixes #10704

## Type of change

Please delete options that are not relevant.

- [x] New feature (non-breaking change which adds functionality)

## How Has This Been Tested?

1. Open a new or existing conversation from the inbox
2. Press the video call icon on the message composer
3. Verify that the message dialog shows up with the join video call
button
4. Verify that clicking on join call does join the call

## Checklist:

- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my code
- [x] My changes generate no new warnings
- [ ] New and existing unit tests pass locally with my changes (Unable
to run this locally)

---------

Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
2025-02-19 14:47:48 -08:00
Muhsin Keloth
031199f15a chore: Slack file upload changes (#10903)
The Slack `files.upload` API endpoint is deprecated and will stop
functioning on March 11, 2025. In this PR, we have implemented the
changes for the [new file
upload](https://api.slack.com/messaging/files#uploading_files) method.
2025-02-18 22:44:30 -08:00
Sojan Jose
12a82b6459 fix: avoid Slack file upload API for fallback messages (#10461)
Skip calling the Slack file upload API for message types such as
fallback (e.g., Facebook and location messages) that lack actual file
data in attachments. This prevents unnecessary API calls and resolves a
Sentry error currently occurring in production.

fixes: https://github.com/chatwoot/chatwoot/issues/10460
2024-11-26 12:56:40 +08:00
Sojan Jose
ab86f62fcc chore: Update GPT Model (#10111)
Update the open AI model, as 3.5 is being deprecated. Provide as option to swap out models via environment variables.
2024-09-16 09:41:20 +05:30
Shivam Mishra
abc511d00f fix: inconsistent OpenAI cache interface (#10009)
Signed-off-by: Shivam Mishra <scm.mymail@gmail.com>
Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
2024-08-22 23:04:14 +05:30
Muhsin Keloth
429d281501 fix: Handle OpenAI API errors (#9560) 2024-08-22 10:24:13 +05:30
Sojan Jose
829bb842fd feat: Generate SSO URL in Chatwoot, move Captain to primary tab (#9871)
- Generate SSO URL in Chatwoot, move Captain to the primary tab

Co-authored-by: Pranav <pranavrajs@gmail.com>
2024-08-01 19:22:34 -07:00
Sojan Jose
0331815cc5 feat: Integration with Captain (alpha) (#9834)
- Integration with captain (alpha)

Co-authored-by: Pranav <pranavrajs@gmail.com>
2024-07-25 14:24:04 -07:00
Muhsin Keloth
023b3ad507 feat: Add APIs for linear integration (#9346) 2024-05-22 13:37:58 +05:30
Shivam Mishra
64283b35a5 refactor: Use processed message content for slack (#9349) 2024-05-06 16:31:20 +05:30
Sojan Jose
5c9acfb4e9 chore: Handle duplicate Webhooks from slack (#9187)
* chore: Handle duplicate Webhooks from slack

* chore: fixes

---------

Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
2024-04-04 17:00:45 +05:30
Sojan Jose
81060a72a4 feat: Improve reply suggestions using help center articles (#9026) 2024-03-03 20:25:19 -08:00
Shivam Mishra
c031cb19d2 fix: downcase email before finding (#8921)
* fix: downcase email when finding

* feat: add `from_email` class

* refactor: use `from_email`

* feat: add rule to disallow find_by email directly

* chore:  remove redundant test

Since the previous imlpmentation didn't do a case-insentive search, a new user would be created, and the error would be raised at the DB layer. With the new changes, this test case is redundant

* refactor: use from_email
2024-02-21 18:51:00 +05:30
Sojan Jose
84f6cadae7 chore: Remove unused builders for widget (#8876)
- These builders are not used in our code base, hence removing them
2024-02-08 21:12:55 +04:00
Sojan Jose
7776b74126 chore: Apply fixes for items in rubocop_todo [CW-1806] (#8864)
This PR addresses several items listed in our rubocop_todo by implementing the necessary corrections and enhancements. As a result, we are now able to remove the rubocop_todo file entirely, streamlining our codebase and ensuring adherence to our coding standards.

fixes: https://linear.app/chatwoot/issue/CW-1806/chore-rubocop-audit
2024-02-07 13:36:04 +04:00
Muhsin Keloth
64138ef220 chore: Rescue Slack::Web::Api::Errors::NotInChannel error (#8670)
The primary cause of this issue is when Chatwoot sends a message to a channel that has either been deleted or is unauthorized. So, we will prompt reauthorization when this error occurs.

Fixes https://linear.app/chatwoot/issue/CW-2930/slackwebapierrorsnotinchannel-not-in-channel
2024-01-09 14:30:17 -08:00
Muhsin Keloth
6c8dacfa0d feat: Facebook delivery reports (#8136) 2023-11-20 12:22:45 +05:30
Muhsin Keloth
5f503b1a57 feat: Change slack bot and activity message appearance (#8349) 2023-11-16 12:59:52 +05:30
Pranav Raj S
653e0335c0 fix: Handle PermissionDeniedError for Dialogflow processor (#8252) 2023-10-30 13:24:03 -07:00
Muhsin Keloth
7438f3b157 fix: Rescue slack ChannelNotFound error (#8196) 2023-10-25 13:53:30 +05:30
Shivam Mishra
62d8ec7edb feat: support reply to for incoming messages on facebook (#8076)
Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
2023-10-13 16:33:50 +05:30
Muhsin Keloth
26e8877cd9 feat: Support link unfurling for all the channels within the same connected channel account. (#8033) 2023-10-08 17:55:03 +05:30
Muhsin Keloth
24fe3805d8 feat: Slack link unfurling (#7940)
Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
2023-09-29 19:35:56 +05:30
Muhsin Keloth
cbbe939662 fix: Set avatar for users(agent/contact) in slack channels (#7960) 2023-09-26 09:38:14 +05:30
Muhsin Keloth
0dd5104acb chore: Move slack message concern to the helper (#7912) 2023-09-19 11:09:23 +05:30
Muhsin Keloth
4fa299ff15 chore: Disable archived channels from the slack integration (#7904) 2023-09-12 22:21:50 +05:30
Muhsin Keloth
ce4cfee8bd fix: Attachment sent from slack doesn't reach to chatwoot (#7852) 2023-09-05 17:23:58 +05:30
Pranav Raj S
3dd3b7b3aa fix: Rescue InvalidAuth and mark integration as inactive (#7797) 2023-08-24 17:02:24 +05:30
Sojan Jose
178bc80b25 fix: Update email alerts for Slack integration (#7739)
Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
2023-08-17 11:46:37 -07:00
Muhsin Keloth
cfe86d9c06 fix: Create new slack thread if the thread identifier changes (#7702)
Co-authored-by: Shivam Mishra <scm.mymail@gmail.com>
2023-08-11 14:19:49 +05:30
Shivam Mishra
84240e197a fix: Summary prompt test (#7709) 2023-08-11 13:42:27 +05:30
Pranav Raj S
04287a0924 fix: Rename channel_list to channels to avoid "no implicit conversion of nil" exception (#7700) 2023-08-09 16:11:51 -07:00
Muhsin Keloth
c1c3a62412 fix: Improve reply prompt (#7588)
Co-authored-by: Sojan Jose <sojan@chatwoot.com>
2023-08-09 10:25:37 +05:30
Sojan Jose
4c75bb68f4 chore: Fix OpenAI sentry errors (#7687)
- add check for nil condition
- add logs for openAI
2023-08-07 14:08:26 -07:00
Pranav Raj S
9ddd428935 feat: Update the slack integration-flow to allow users to select the channel (#7637) 2023-07-28 14:50:30 -07:00
Shivam Mishra
39f14bebbd fix: undefined method first for nil:NilClass (#7567)
Co-authored-by: Sojan Jose <sojan@pepalo.com>
2023-07-25 13:00:21 +03:00
Muhsin Keloth
91c1061214 feat: Add more AI options (#7502)
Co-authored-by: Shivam Mishra <scm.mymail@gmail.com>
Co-authored-by: Nithin David Thomas <1277421+nithindavid@users.noreply.github.com>
Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
2023-07-16 12:25:16 -07:00
Muhsin Keloth
19ff738211 feat: Add more options for AI reply suggestions (#7493) 2023-07-13 10:26:25 +05:30