Sample Call Processing Script for PIN

Introduction

This script implements an IVR which asks the caller for a DTMF number which can then be used as a PIN or be verified against a database.

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 dtmf.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. One simple change can be the following:

The below screenshot explains how to add a new DTMF pin pattern of "2024" which routes to extension 250. To do this, simply add a new line { "2024", "250" },  

// Mapping of PIN codes to destinations

private readonly Dictionary<string, string> UserInputMap = new Dictionary<string, string>

{

{ "2024", "250" },

{ "1234", "100" },

{ "2345", "101" },

{ "3456", "102" },

{ "", "103" } // No input

};

  1. Press Save to compile. If compilation is successful, you will see “Compilation Succeeded!” in the Script output as displayed above. Now when a user dials DTMF "2024", the call will be routed to extension "250".

How it Works

  1. When a *357 is dialed, the script “ivrlauncher” is triggered.
  2. An IVR plays and asks you to enter an input
  3. User enters DTMF “2024” and the script will transfer the call to the destination declared in the C# Code. In this example the call will be routed to extension “250”

See also

Last Updated

This document was last updated on 15 October 2024

https://www.3cx.com/docs/call-processing-script-dtmf/