63 Commits

Author SHA1 Message Date
Sojan Jose
38f16ba677 feat: Secure external credentials with database encryption (#12648)
## Changelog

- Added conditional Active Record encryption to every external
credential we store (SMTP/IMAP passwords, Twilio tokens,
Slack/OpenAI hook tokens, Facebook/Instagram tokens, LINE/Telegram keys,
Twitter secrets) so new writes are encrypted
whenever Chatwoot.encryption_configured? is true; legacy installs still
receive plaintext until their secrets are
    updated.
- Tuned encryption settings in config/application.rb to allow legacy
reads (support_unencrypted_data) and to extend
deterministic queries so lookups continue to match plaintext rows during
the rollout; added TODOs to retire the
    fallback once encryption becomes mandatory.
- Introduced an MFA-pipeline test suite
(spec/models/external_credentials_encryption_spec.rb) plus shared
examples to
verify each attribute encrypts at rest and that plaintext records
re-encrypt on update, with a dedicated Telegram case.
The existing MFA GitHub workflow now runs these tests using the
preconfigured encryption keys.

fixes:
https://linear.app/chatwoot/issue/CW-5453/encrypt-sensitive-credentials-stored-in-plain-text-in-database

## Testing Instructions

 1. Instance without encryption keys
- Unset ACTIVE_RECORD_ENCRYPTION_* vars (or run in an environment where
they’re absent).
      - Create at least one credentialed channel (e.g., Email SMTP).
- Confirm workflows still function (send/receive mail or a similar
sanity check).
- In the DB you should still see plaintext values—this confirms the
guard prevents encryption when keys are missing.
  2. Instance with encryption keys
      - Configure the three encryption env vars and restart.
- Pick a couple of representative integrations (e.g., Email SMTP +
Twilio SMS).
      - Legacy channel check:
- Use existing records created before enabling keys. Trigger their
workflow (send an email / SMS, or hit the
            webhook) to ensure they still authenticate.
- Inspect the raw column—value remains plaintext until changed.
      - Update legacy channel:
- Edit one legacy channel’s credential (e.g., change SMTP password).
- Verify the operation still works and the stored value is now encrypted
(raw column differs, accessor returns
            original).
      - New channel creation:
- Create a new channel of the same type; confirm functionality and that
the stored credential is encrypted from
            the start.

---------

Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
2025-10-13 18:05:12 +05:30
Tanmay Deep Sharma
239c4dcb91 feat: MFA (#12290)
## Linear:
- https://github.com/chatwoot/chatwoot/issues/486

## Description
This PR implements Multi-Factor Authentication (MFA) support for user
accounts, enhancing security by requiring a second form of verification
during login. The feature adds TOTP (Time-based One-Time Password)
authentication with QR code generation and backup codes for account
recovery.

## Type of change

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

## How Has This Been Tested?

- Added comprehensive RSpec tests for MFA controller functionality
- Tested MFA setup flow with QR code generation
- Verified OTP validation and backup code generation
- Tested login flow with MFA enabled/disabled

## 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

---------

Co-authored-by: Pranav <pranav@chatwoot.com>
Co-authored-by: Sojan Jose <sojan@pepalo.com>
Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
2025-09-18 20:19:24 +05:30
Muhsin Keloth
17500cc62d chore: Auto assign PR to author when PR opened (#11890)
- gh action to auto-assign PR to author when PR opened
2025-07-10 11:36:37 +05:30
Kitsios Konstantinos
3ea6429895 chore: Cancel redundant ci runs on consecutive pushes on the same PR (#11851)
Currently, if a PR is open and a push happens, the Run Size Limit Check
workflow will start running. If, shortly after a subsequent push on the
same PR happens, the workflow will start running again without
cancelling the previous (now obsolete) run. With these changes, the
first run would be cancelled, thus saving compute resources (see below
for quantity) without sacrificing functionality, since the second run
will contain the changes from the first push as well.
2025-07-02 15:25:30 +05:30
Sojan Jose
fdd35ff549 chore: Update Codespaces (#11621)
- Fix issues with the current Chatwoot development codespaces
- Switch from webpacket to vite 
- Add additional configs to make the development easier with codespaces
- toggles v4 feature true as default
2025-05-29 01:45:00 -06:00
Bruno Shiohei
4304e06748 fix: Updating the Ubuntu version to run the tests (#11260)
In my previous PR I got some errors that when checking it is possible to
conclude that the version of ubuntu 20.04 in the Github Actions images
to run the tests is no longer supported.

![image](https://github.com/user-attachments/assets/f637e8da-3d15-43a1-8800-6c2785faf70c)

Possible to check at this url:
https://github.com/actions/runner-images/issues/11101

## What's changed
Changing the Ubuntu version in the image to run the tests.
Old version: 20.04
New version: 22.04

## BEFORE:

![image](https://github.com/user-attachments/assets/bd2dfdcd-3913-425e-a57c-504c7604d70a)

## NOW:

![image](https://github.com/user-attachments/assets/437ef89b-89d0-4e58-8e3c-ee3073dad417)
2025-04-08 16:36:06 -07:00
Pranav
6757b025f4 chore: Update readme (#11154)
- changes to the readme
2025-03-21 18:14:51 -07:00
Pranav
950d9f50a5 chore: Update Readme (#11148)
Update readme.
2025-03-21 14:37:38 -07:00
Vishnu Narayanan
12d7be62d3 chore: fix nightly linux installer github action (#11009)
- chore: fix nightly linux installer github action
2025-03-03 17:45:57 +05:30
Vishnu Narayanan
1da0474ed1 chore: add gh action to test docker builds against PRs (#10892)
- Add GitHub action to test docker builds for internal/external PR's
- This PR builds the image on both amd64 and arm64 runners for every PR
- This also reduces the build time by 70% (50mins to 15mins)
2025-02-12 17:16:33 +05:30
Vishnu Narayanan
adff853086 feat: docker arm64 builds for ee edition (#10891)
- Publish arm64 docker images for chatwoot ee edition
- Switch to Github actions for `docker` build/publish from docker hub
due to lack of arm64 support


**Note: CE edition arm64 images are already available via
https://github.com/chatwoot/chatwoot/pull/10789**
2025-02-12 16:28:53 +05:30
Shivam Mishra
f2a7e1da6b fix: Corepack pnpm issue (#10840)
So, a while back Circle CI builds and Heroku builds started to fail. 

From all the threads I read, it seems like the [npm registry rotated
it's signing
keys](https://github.com/pnpm/pnpm/issues/9014#issuecomment-2616589753)
New pnpm versions were signed with the new key. Corepack, however,
bundles a static set of trusted keys (from Node’s release), so it
continued verifying signatures only against the old key. When it
encountered packages signed with the new key, Corepack’s integrity check
failed with “Cannot find matching keyid” errors.This mismatch caused
Corepack’s integrity check to fail with “Cannot find matching keyid”
errors.

Workarounds include the following

1. Updating Corepack (to 0.31.0), they [upgraded their
package](https://github.com/nodejs/corepack/releases/tag/v0.31.0) to
include the new integrity check keys. But we seldom control what's going
on with the CI, also, updating this across our scripts is going to be a
painful task. Besides Heroku has [made some
fixes](https://github.com/heroku/buildpacks-nodejs/pull/1010) around
this
2. Disabling integrity checks 🔥 #YOLO
3. Pinning `pnpm` to older versions, or pinning it to a newer version
with the checksum in place.

Doing the third one here, running `corepack use pnpm@9.15.5` fixes this,
[ref](https://github.com/pnpm/pnpm/issues/9014#issuecomment-2623761494)

We can get rid of this over time as CDN caches used by build systems are
refreshed. But the change in this PR is not disruptive in anyway, only
rigidly secure.

Fixes: https://github.com/chatwoot/chatwoot/issues/10832

---

Here are the threads to follow 

- https://github.com/pnpm/pnpm/issues/9014
- https://github.com/pnpm/pnpm/issues/9029
- https://github.com/nodejs/corepack/issues/612
- https://github.com/nodejs/corepack/issues/616
- https://github.com/heroku/buildpacks-nodejs/pull/1010

---------

Co-authored-by: Vishnu Narayanan <vishnu@chatwoot.com>
2025-02-05 10:12:29 -08:00
Vishnu Narayanan
55f1690d9e fix: docker github action for ce images (#10800)
- Fix the docker tag issue during push stage for ce image build
2025-01-30 15:52:01 +05:30
Vishnu Narayanan
f6d87d0e6e feat: switch to native arm64 runners for docker ce images (#10789)
Emulated docker arm64 builds are failing for community images. This PR

- Switches gh action to use native arm64 runners
- Merges amd64 and arm64 images to create a multi-arch docker image

Fixes https://github.com/chatwoot/chatwoot/issues/10790
2025-01-29 22:53:29 +05:30
Pranav
d070743383 feat(ee): Add Captain features (#10665)
Migration Guide: https://chwt.app/v4/migration

This PR imports all the work related to Captain into the EE codebase. Captain represents the AI-based features in Chatwoot and includes the following key components:

- Assistant: An assistant has a persona, the product it would be trained on. At the moment, the data at which it is trained is from websites. Future integrations on Notion documents, PDF etc. This PR enables connecting an assistant to an inbox. The assistant would run the conversation every time before transferring it to an agent.
- Copilot for Agents: When an agent is supporting a customer, we will be able to offer additional help to lookup some data or fetch information from integrations etc via copilot.
- Conversation FAQ generator: When a conversation is resolved, the Captain integration would identify questions which were not in the knowledge base.
- CRM memory: Learns from the conversations and identifies important information about the contact.

---------

Co-authored-by: Vishnu Narayanan <vishnu@chatwoot.com>
Co-authored-by: Sojan <sojan@pepalo.com>
Co-authored-by: iamsivin <iamsivin@gmail.com>
Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com>
2025-01-14 16:15:47 -08:00
Vishnu Narayanan
9410b3bcbb feat: add multiarch arm64 support in ce docker images (#10582) 2024-12-16 16:53:01 +05:30
Vishnu Narayanan
ee02923ace chore: fix circleci on vite build (#10214)
- Switch to pnpm based build
- Switch circleci from docker to machine to have more memory
- Fix frontend and backend tests

Fixes
https://linear.app/chatwoot/issue/CW-3610/fix-circle-ci-for-vite-build
---------

Co-authored-by: Shivam Mishra <scm.mymail@gmail.com>
Co-authored-by: Pranav <pranavrajs@gmail.com>
Co-authored-by: Pranav <pranav@chatwoot.com>
2024-10-07 15:27:41 +05:30
Vishnu Narayanan
fdc3e370ef fix: gh actions for vite build (#10212)
Fixes https://linear.app/chatwoot/issue/CW-3604/fix-gh-actions-for-vite-build

- [x] response bot spec
- [x] chatwoot ce spec
- [x] size limit check
2024-10-03 16:25:48 +05:30
Shivam Mishra
42f6621afb feat: Vite + vue 3 💚 (#10047)
Fixes https://github.com/chatwoot/chatwoot/issues/8436
Fixes https://github.com/chatwoot/chatwoot/issues/9767
Fixes https://github.com/chatwoot/chatwoot/issues/10156
Fixes https://github.com/chatwoot/chatwoot/issues/6031
Fixes https://github.com/chatwoot/chatwoot/issues/5696
Fixes https://github.com/chatwoot/chatwoot/issues/9250
Fixes https://github.com/chatwoot/chatwoot/issues/9762

---------

Co-authored-by: Pranav <pranavrajs@gmail.com>
Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com>
2024-10-02 00:36:30 -07:00
Vishnu Narayanan
bb947ca50d chore: Remove closing comment on issues/PRs (#9964) 2024-08-20 14:27:15 +05:30
Shivam Mishra
3b2b1b7b8c feat: remove CODEOWNERS for js & vue files (#9217)
feat: Remove CODEOWNERS for js & vue files
2024-04-10 16:37:38 +10:00
Sojan Jose
41e269e873 feat(ee): Add reporting events for bots (#9027)
Added a new event conversation_bot_resolved and added a job to auto resolve the bot conversations if there was no activity for the last 1 hour.
2024-02-27 14:53:28 -08:00
Vishnu Narayanan
8f6ff4bc41 chore: refactor deploy check gh action (#9018)
* chore: refactor deploy check action

    Refactor deployment check gh action to account for the initial setup time required for heroku review apps
    Process /api response via jq only if http.status_code is 200
2024-02-26 16:14:01 +05:30
Vishnu Narayanan
1de3ff1a6d chore(infra): Add GH action to ensure deployment success for every PR (#8990) 2024-02-22 15:28:28 -08:00
Vishnu Narayanan
0d1b474e60 chore: upgrade to latest versions of gh helper actions (#8896)
https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/

Fixes: https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/
2024-02-09 10:56:36 +04:00
Sojan Jose
372e740c38 chore: Add CODEOWNERS (#8889) 2024-02-08 07:44:08 -08:00
Liam
4958b3e7b6 chore: Fix codespaces not booting up (#8264)
Fixed an issue where the codespace was not correctly booting up.
Fixes #7609

Co-authored-by: Liam Ashdown <liam.ashdown@debbiesvillas.co.uk>
Co-authored-by: Sojan <sojan@pepalo.com>
2024-01-16 14:34:23 +04:00
Sojan Jose
647161121e chore: pass to agent if there is error parsing json (#7990)
- GPT bot should pass the conversation to the agent if AI returns invalid json or any other error
2023-09-26 21:05:21 -07:00
Shivam Mishra
e2a6dc3e04 chore: Upgrade Node.js to v20 (#7759)
Co-authored-by: Vishnu Narayanan <vishnu@chatwoot.com>
Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
2023-08-28 19:20:35 +05:30
Vishnu Narayanan
180befbd42 feat: add gh action to check logging percentage (#7688) 2023-08-08 15:51:46 +05:30
Sojan Jose
480f34803b feat: Response Bot using GPT and Webpage Sources (#7518)
This commit introduces the ability to associate response sources to an inbox, allowing external webpages to be parsed by Chatwoot. The parsed data is converted into embeddings for use with GPT models when managing customer queries.

The implementation relies on the `pgvector` extension for PostgreSQL. Database migrations related to this feature are handled separately by `Features::ResponseBotService`. A future update will integrate these migrations into the default rails migrations, once compatibility with Postgres extensions across all self-hosted installation options is confirmed.

Additionally, a new GitHub action has been added to the CI pipeline to ensure the execution of specs related to this feature.
2023-07-21 18:11:51 +03:00
Sojan Jose
5c5381c0a9 chore(ci): Ensure PR titles are in semantic format (#7346) 2023-06-19 16:48:45 +05:30
Shivam Mishra
9f3d155822 feat: Add size limit action (#7253)
* chore: update browserlist

* feat: add size limit action

* feat: set limits

* feat: add size limit in CI

* chore: remove railsenv

* chore: update limits
2023-06-05 18:56:15 +05:30
Shivam Mishra
32f7342cd6 chore: Add issue forms for GitHub (#6982) 2023-04-26 11:25:02 -07:00
Vishnu Narayanan
42d9b6ffed chore: upload log artifact in nightly gh action (#6513) 2023-02-28 12:18:06 +05:30
Vishnu Narayanan
26f164d6a0 fix: foss_spec github action (#6495)
* fix: foss_spec gh action
* chore: upload log artifact in foss_spec gh action
* chore: ping foss_spec gh action runner os version to ubuntu-20.04
* fix: set nodeversion to 16
2023-02-20 23:37:41 +05:30
Shubham Kumar
51e0388779 feat: Skip gh thread lock gh action on forks (#6381) 2023-02-03 12:20:49 +05:30
Vishnu Narayanan
b1ec67d110 chore: upgrade ruby to 3.1.3 (#5555)
* chore: update to ruby 3.1.3

* chore: ping docker version to alpine3.16 for nodev16.x

Starting with Node 17, nodejs switched to OpenSSL3. The docker builds
are installing node18.xx with alpine-3.1.3.

From Node.js 17's announcement post:

    If you hit an ERR_OSSL_EVP_UNSUPPORTED error in your application
with Node.js 17, it’s likely that your application or a module you’re
using is attempting to use an algorithm or key size which is no longer
allowed by default with OpenSSL 3.0. A new command-line option,
--openssl-legacy-provider, has been added to revert to the legacy
provider as a temporary workaround for these tightened restrictions.

Looks like a webpack issue. This is fixed in webpacl 5+ and we are on
webpack4 at the moment.
Solutions

    Upgrade webpack.
    Pin nodejs version to be 16.x.x
    Use  --openssl-legacy-provider as a workaround.

Pin docker version to alpine3.16 branch to have node16.x by default

ref:
https://github.com/chatwoot/chatwoot/pull/5555#issuecomment-1379778532

* chore: update webmock

* chore: fix ruby gem path in dockerfile

* chore: switch to node16 in circleci

* chore: update ruby version in linux installer script

* chore: update ruby version in linux installer script

* chore: fix circleci

* chore: fix circleci

* feat: upgrade node version to 16.x in linux installer

* chore: update systemd files

Co-authored-by: Sojan Jose <sojan@chatwoot.com>
2023-01-24 23:55:07 +05:30
Shivam Mishra
845311a539 chore: add stale PR bot (#6289)
The PR only adds the stale label and puts a comment, does not close them (yet)
2023-01-19 18:53:21 +05:30
Vishnu Narayanan
bce0bb8acb chore: Improve pr and bug report templates (#5556)
Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
2022-10-19 13:45:32 -07:00
Vishnu Narayanan
8f4944fda0 chore: revert arm64 docker build in gh action (#5619)
ref: https://github.com/chatwoot/chatwoot/pull/5575

https://github.com/chatwoot/chatwoot/pull/5575#issuecomment-1277208625
2022-10-13 13:46:28 +05:30
Marcel Stör
7b1630b468 feat: Enable Docker Buildx multi-arch builds with arm64 support(#5545)
Fixes #2575

multi-arch images with arm64 support CE edition images

Co-authored-by: Vishnu Narayanan <vishnu@chatwoot.com>
2022-10-05 17:07:49 +05:30
Vishnu Narayanan
bc23c69605 chore: Fix gh nightly failure (#5442)
* chore: fix gh nightly failure
2022-09-15 23:16:45 +05:30
Vishnu Narayanan
3cb72242de feat: add gh action for linux nightly installer (#5191)
* feat: add gh action for nightly installer


Signed-off-by: Vishnu Narayanan <vishnu@chatwoot.com>
2022-08-16 11:04:09 +05:30
Sojan Jose
e26c6a2de5 chore: Lock closed threads automatically (#5222) 2022-08-08 21:12:28 +05:30
Vishnu Narayanan
568c30e93e chore: Update ruby and docker base image to 3.0.4 (#4693)
* chore: Update ruby version to 3.0.4

* chore: update ruby version in docker workflow

* chore: update ruby version to 3.1.2

* Upgrade vue-jest to remove deasync

* Revert to 3.0.4 to see if deasync issue is fixed

* fix: script failure if pg/redis not opted in

Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
2022-05-27 17:33:24 +05:30
Vishnu Narayanan
45099f40f1 fix: ce spec action for PRs from forks (#4587)
CE spec action was failing for PRs from external forks at the checkout stage. This PR modifies the checkout action to use the full repo name and branch.

#4586
2022-04-29 14:38:10 +05:30
Vishnu Narayanan
80e5d6d7a0 feat: add chatwoot_edition variable for CE docker images (#4462)
* chore: add chatwoot_edition variable for CE docker images

* fix cw_edition variable

* chore: update comment

* feat: include cw_edition data in payload to hub

* refactor cw_edition to edition
2022-04-14 17:15:57 +05:30
Vishnu Narayanan
75ce5345a9 feat: add gh action to build Chatwoot CE/foss docker image (#4406)
Github action to build and push chatwoot-ce(foss) edition images. This action will run on merges to master, develop and when tags are created. Corresponding docker tags are as follows.

GitHub branch/tag  -->	docker tag
----
master 	--> latest-ce
develop 	---> develop-ce
v2.3.2 	---> v2.3.2-ce
v* 	---> v*-ce

Fixes #4388
2022-04-06 21:14:04 +05:30
Vishnu Narayanan
76f53d9a11 feat: add gh action to run CE edition tests (#4342)
* feat: add gh action to run CE spec

* setup ruby
* add pg,redis services
* fix failing tests
2022-04-04 19:27:01 +05:30