Intercept Call and Route to Destination

Introduction

3CX includes the ability to trigger custom scripts for incoming calls on SIP trunks. This guide demonstrates how to create a script that intercepts a call and routes to a pre-configured destination.

Create a Call Processing Script in 3CX

  1. Login to your Admin Console, go to Integrations > Call Scripts.
  2. Click Add from Store.

  1. Select one of the scripts available from the 3CX Call Processing Script Store. In this example we will select timebasecallscript.cs. 
  2. Enter a name for the Call script (should contain lowercase characters only with no spaces).
  3. Select how you want this script to be launched via the "Run this script" option.
  4. Depending on the previous selection, enter a dial code, select desired SIP trunk or assign a DID.
  5. Assign the script to a department.

  1. Click OK to proceed. This will redirect you to the code editor page which will automatically compile the script.

  1. You can now make C# changes to the code. Press Save to compile. If compilation is successful, you will see “Compilation Succeeded!” in the Script output as displayed above. Optionally add any audio files in the “Audio files” section if your code supports this.

How it Works

  1. When a call comes in on the assigned SIP trunk, the script is triggered.
  2. The script checks if the current day and time matches those defined in new Schedule(RuleHoursType.SpecificHours)
  3. If the current time matches the predefined schedule, the script attempts to redirect the call to the DestinationDN - in the example “DestinationDN” is set to 801.
  4. Else, the routing is sent to obey what is configured inside 3CX Call handling destinations

See Also

Last Updated

This document was last updated on 10 September 2026

https://www.3cx.com/docs/intercept-call-example/