Before beginning the installation make sure that your system requirements as indicated have been met.

Important Info From v2.4

  • Ensure that you are using php v8.2
  • Ensure that you have enabled imagick extension in your server (If not you might experience error 500).
  • Ensure that you are running either MYSQL > 5.7.7 or MariaDB > 10.2.2 (Alternatively, you may enable the innodb_large_prefix option for your database)

After purchasing Swiftchats, you will get a zipped folder. After unzipping the folder, you will get three folders, the source code folder, update folder and the documentation folder.

Documentation
Source-code
Update

Database setup

  1. Create a new MySQL database.
  2. Create a new MySQL username and password.
  3. Assign full privileges to your database username.

Uploading code

Before starting to upload the files, please make sure your file explorer has the option to view hidden files turned on. On some operating systems, the dotfiles are hidden by default.

  • Upload the source-code folder to your server public_html or domain root directory where Swiftchats will be installed.
  • Create a new MySQL database and DB user from your server and assign that user to the database

Installer setup

Once you have configured the steps above, go to your domain or subdomain which should redirect you to the installation page. Go through each installation step and grant folder permissions where necessary.

Laravel jobs and queues

To ensure successful delivery of WhatsApp campaigns, it’s essential to set up a cron job or queue system that runs at scheduled intervals to dispatch campaigns efficiently. There are multiple ways to configure this, and in this documentation, we’ll outline the recommended approaches.

Generally there are 3 ways for running cron jobs:

  1. Supervisor for queue management - Best suited for VPS or dedicated hosting (Highly recommended)
  2. Server cron jobs - Preferred for shared hosting environments.
  3. cronjob.org - An alternative for shared hosting when direct server cron jobs are unavailable.

Supervisor can only be setup in a VPS and not shared hosting. If using shared hosting go to the cron jobs section below.

If you decide to use laravel queues go to your .env file and change the following:

QUEUE_CONNECTION=database
QUEUE_MEMORY=128
QUEUE_TIMEOUT=300
QUEUE_DRIVER=database

Step 1: Install Supervisor

First, install Supervisor on your VPS. The installation command depends on your operating system:

For Ubuntu/Debian:

sudo apt update && sudo apt install supervisor -y

For CentOS/Rocky Linux:

sudo yum install supervisor -y

After installation, start Supervisor and enable it to run on boot:

sudo systemctl enable --now supervisor

Step 2: Create a Supervisor Configuration File for Laravel Queues

Create a new configuration file inside /etc/supervisor/conf.d/ (for Ubuntu) or /etc/supervisord.d/ (for CentOS).

sudo nano /etc/supervisor/conf.d/laravel-queue.conf

Add the following content:

[program:laravel-queue] 
process_name=%(program_name)s_%(process_num)02d 
command=php /path-to-your-project/artisan queue:work --queue=campaign-messages,campaign-logs --tries=3 --timeout=3600 autostart=true 
autorestart=true 
numprocs=1 
redirect_stderr=true 
stdout_logfile=/var/log/laravel-queue.log

Replace /path-to-your-project/ with your actual Laravel project path.

Step 3: Apply Supervisor Changes

After creating the configuration file, run the following commands to update and start Supervisor:

sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl start laravel-queue

To check if Supervisor is running correctly, use:

sudo supervisorctl status

Step 4: Monitoring and Logs

You can check the logs if anything goes wrong:

tail -f /var/log/laravel-queue.log

If the queue worker stops unexpectedly, restart Supervisor:

sudo supervisorctl restart laravel-queue

Step 5: Ensure Supervisor Starts on Boot

To prevent queue workers from stopping after a reboot, enable Supervisor:

sudo systemctl enable supervisor

2. Server Cron Jobs

Cpanel

  1. Access your cPanel account using your credentials.
  2. Look for the Cron Jobs or Cron Tasks icon within the cPanel dashboard. It’s usually found under the Advanced or Metrics section.
  3. Click on the Cron Jobs icon to proceed.
  4. Under the Add New Cron Job section, you’ll see fields to specify the timing and command for the cron job.
  5. Set Timing: We suggest to run the cron job every 3-5 minutes.
  6. In the command field, enter the appropriate command to fetch the URL. For example:
wget -O /dev/null https://yoururl.com/campaign-send

OR

curl -sS https://yoururl.com/campaign-send >/dev/null 2>&1
  1. Save Cron Job

Linux/VPS

  1. Open your crontab for editing. You can do this by running the following command in your terminal: crontab -e

  2. Add the following line to your crontab to execute the URL every 3 minutes:

    */3 * * * * /usr/bin/curl -sS "https://yoururl.com/campaign-send"
    

    Here’s a breakdown of the cron schedule:

    • */3 means every 3 minutes.
    • * in the other fields means “every hour,” “every day,” “every month,” and “every day of the week.”
  3. Save and exit your crontab editor.

3. Cronjob.org

  1. Create an account on https://console.cron-job.org/
  2. Click on create cronjob on the dashboard
  3. Enter the URL of the cron job i.e. https://yoururl.com/campaign-send and set execution schedule between 3 - 5 minutes.
  4. Click create to save the cronjob

Trouble-shooting your installation

If you are facing issues with the installer, you can try the steps below

  • Grant access to your .env file by running the following code in the terminal.
chown -R www-data:www-data .env
  • Go to storage folder and delete installed file
  • Retry installing the script again