Fermin Perdomo

Senior Full Stack Engineer | PHP | JavaScript

Trigger Outbound Calls from Laravel Using VICIdial API Wrapper

Fermin Perdomo
July 20, 2025

VICIdial is one of the most powerful open-source contact center solutions in the world, but integrating it with modern web applications like Laravel can be a challenge—especially if you're trying to initiate outbound calls programmatically.

In this post, you'll learn how to trigger outbound calls from Laravel using the masterfermin02/vicidial-api-wrapper package and VICIdial’s external_dial Non-Agent API function.

What You Need

  • A Laravel 9+ project
  • PHP 8.0+
  • Composer
  • Access to a VICIdial server
  • An API user with proper privileges
  • An agent logged into VICIdial (with session ID ready)

Step 1: Install the VICIdial API Wrapper

Install the wrapper package via Composer:

composer require masterfermin02/vicidial-api-wrapper

Step 2: Set Up Your Environment Variables

In your .env file, add the following:

VICIDIAL_API_URL=http://your-vicidial-server
VICIDIAL_API_USER=your_api_user
VICIDIAL_API_PASSWORD=your_api_password
VICIDIAL_API_SOURCE=laravel


Step 3: Use the dial Function

Here's a simple controller method to initiate a call:

use MasterFermin\Vicidial\Vicidial;

class VicidialController extends Controller
{
    public function dial()
    {
        $agentApi = VicidialApi::create(
            getenv('YOUR_VICIDIAL_IP'),
            getenv('YOUR_VICIDIAL_USER'),
            getenv('YOUR_VICIDIAL_PASSWORD')
        )->agent();
        $agentUser = '1010';

        $response = $agentApi->dial($agentUser, [
            'phone_number'     => '1234567890',
            'phone_code'       => '1', // Country code
            'campaign'         => 'TESTCAMP',
            'search'           => 'NO',
            'preview'          => 'NO',
            'vendor_lead_code' => '',
            'alt_dial'         => 'NONE',
            'lead_id'          => '', // optional
            'phone_login'      => '9001',
            'session_id'       => '1234567890123456',
            'server_ip'        => '192.168.1.10',
        ]);

        return response()->json(['vicidial_response' => $response]);
    }
}

Sample Success Response

{
  "vicidial_response": "SUCCESS: CALL PLACED"
}

Common Errors

ErrorReasonagent not logged in | Agent is not in READY state
session_id is invalid | Use the correct, active session ID
server_ip not found | The IP must match the server where the agent is logged in


Final Notes

  • This integration is ideal for click-to-call apps, CRM dialers, or appointment reminders.
  • You can combine this with Laravel Jobs or Queues to trigger calls based on events (like form submissions or overdue reminders).
  • Always secure your API credentials and whitelist access to the VICIdial server.

Need Help?

If you want to:

  • Auto-fetch the agent’s session ID
  • Build a full click-to-call feature with Vue or Livewire
  • Connect Laravel + VICIdial + Twilio/SMS

Feel free to reach out or comment below.


Reactions

Loading reactions...
Log in to react to this post.

Comments

Please login to leave a comment.

Great Tools for Developers

Git tower

Git tower

A powerful Git client for Mac and Windows that simplifies version control.

Get Started - It's Free
Visit Tool
Mailcoach's

Mailcoach's

Self-hosted email marketing platform for sending newsletters and automated emails.

Start free
Visit Tool
Uptimia

Uptimia

Website monitoring and performance testing tool to ensure your site is always up and running.

Start free
Visit Tool

Newsletter