Campaign Scripts
  • 26 May 2025
  • 6 Minutes to read
  • Dark
    Light

Campaign Scripts

  • Dark
    Light

Article summary

Introduction

This document describes the implementation and use of a JSON-based scripting framework for outbound campaign calls in contact centers. These campaign scripts are designed to improve the execution of a campaign by enabling requests that are both internal and external to be called at any step during the call.

The JSON scripting system makes it possible to design workflows which are event driven and modular, with the ability to perform real-time data exchange, API calls, and powerful computation during a call.

This document help users to understand structure, syntax, and functionality of the JSON scripts. Developers, system architects, and support staff who maintain or enhance the outbound call campaign system are the intended audience of this document.

Campaign scripts based on following structure,

eventType: is a string in JSON array format that identifies execution trigger and it’s details. The value can be beforeAttempt, afterAttempt, beforeConnect, afterAttemptComplete. All the trigger type details are explained below. JSON array must be in a structure defined below.

request: is an optional string in JSON format that defines the request details with serviceClientType, url, method, requestHeaders, etc. Request object details are explained below.

condition: is an optional string in JSON format that identifies any condition to be checked and validated before executing request. If condition fails (returns false) execution will not continue. Condition is identified via operator string and parameters  JSON array. All list of conditions can be accessed via link https://docs.tegsoft.com/docs/tegsoft-ivr-system document in functional IVR section.

conditions: is an optional string in JSON array format that checks multiple conditions bind together with AND operator. If condition fails the execution will not continue.

actions: is an optional string in JSON array format that defines list of actions to be executed after the request. Each action is defined by type and parameters details. All the list of action types and details can be accessed via link https://docs.tegsoft.com/docs/tegsoft-ivr-system document in functional IVR section.

condition: is an optional string in JSON format that works same as condition definition under request topic.

conditions: is an optional string in JSON array format that works same as conditions definition under request topic.

Event Types

beforeAttempt

This execution takes place just before creating the attempt (Voice call, WhatsApp / SMS or Email attempts are processed). During this execution there is no channel or session yet. So the conditions and actions need to be selected accordingly.

afterAttempt

After attempt executes just after the attempt. Still there is no call or a session but attempt status can be checked. There will be no more action if attempt is invalid, forbidden.

beforeConnect

This event type will trigger only for unattended voice campaign (the IVR campaign) or attended voice campaign in progressive or predictive mode. When the dialed number answers just before connecting to IVR or an agent the system will trigger actions for this event type.

afterAttemptComplete

This event type will trigger only for successful attempt execution. The invalid, failed attempts will not trigger this after attempt complete actions.

Parameters

Parameters are strings in the script that will be replaced by the real value during execution.

Following parameters can be used,

{TODAY}: will be replaced with current server date in yyyy-MM-dd-HH-mm-ss format with 00:00:00 time.

{NOW}: will be replaced with current server date time in yyyy-MM-dd-HH-mm-ss format with.

response{KEY}: This represents the execution result of the request action. KEY can be,

responseCode: integer that will be replaced with HTTP Response code. Like 200 for OK, 404 for not found.

requestResult: is the execution result of the request action. It will be always OK if execution completed successfully, TIMEOUT for timeout or EXCEPTION for any error case.

responseResult: Same as requestResult but kept for backward capability please use requestResult.

json path: like customer.type will be replaced with the customer type from the response JSON object or response{token} will be replaced with the token value of the response JSON object.

rowTBLCCCAMPAIGN{COLUMN_NAME}: will be replaced with the real value of the table related row. Like rowTBLCCCAMPAIGN{NAME} will be replaced as campaign name.

rowTBLCCCAMPCONT{COLUMN_NAME}: will be replaced with the real value of the table related row. Like rowTBLCCCAMPCONT{CONTID} will be replaced as related contact id.

rowTBLCRMCONTACTS{COLUMN_NAME}: will be replaced with the real value of the table related row. Like rowTBLCRMCONTACTS{FIRSTNAME} will be replaced as related contact firstname.

rowTBLCCCAMPCALLD{COLUMN_NAME}: will be replaced with the real value of the table related row. Like rowTBLCCCAMPCALLD{DIALRESULT} will be replaced with the dial result.

TBLCCCAMPCONTDET{KEY}: will be replaced with the values of campaign keywords. TBLCCCAMPCONTDET{customerType} will be replaced with customerType data value.

TBLCCCAMPCALLD{KEY}: represents the list of attempts, for example TBLCCCAMPCALLD{attemptCount} will be replaced with number of attempts.

C{KEY}: will be replaced with possible key - value matching. Like C{CONTID} will be replaced with the current CONTID value.

Example

Here is a simplified but covering all features example of JSON script,

{
  "beforeAttempt": [
    {
      "request": {
        "serviceClientType": "JSONServiceClient",
        "method": "POST",
        "url": "https://myserver.mydomain.com/callInitiated",
        "requestHeaders": [
          {
            "accept": "json"
          }
        ],
        "requestBody": {
          "contactName": "rowTBLCRMCONTACTS{FIRSTNAME} rowTBLCRMCONTACTS{LASTNAME}",
          "contactId": "rowTBLCRMCONTACTS{CONTID}", 
          "date": "{TODAY}"
        }
      }
    }
  ],
  "afterAttempt": [
    {
      "request": {
        "serviceClientType": "JSONServiceClient",
        "method": "POST",
        "url": "https://myserver.mydomain.com/get_login_token",
        "requestHeaders": [
          {
            "accept": "json"
          }
        ],
        "requestBody": {
          "username": "MY_USER",
          "password": "MY_PASS"
        }
      },
      "actions": [
        {
          "type": "SETVARS",
          "parameters": ["token:response{token}"]
        }
      ]
    },
    {
      "request": {
        "serviceClientType": "JSONServiceClient",
        "method": "POST",
        "url": "https://myserver.mydomain.com/use_login_token",
        "requestHeaders": [
          {
            "accept": "json",
            "Authorization": "Bearer C{token}"
          }
        ],
        "requestBody": {
          "appointmentId": "C{appointmentId}",
          "Campaign_Name": "rowTBLCCCAMPAIGN{NAME}",
          "Customer_NAME": "rowTBLCRMCONTACTS{FIRSTNAME} rowTBLCRMCONTACTS{LASTNAME}",
          "Customer_PHONE": "C{PHONE}",
          "Call_Date": "rowTBLCCCAMPCALLD{CALLDATE}",
          "Dial_Result": "rowTBLCCCAMPCALLD{DIALRESULT}"
        }
      }
    }
  ],
  "beforeConnect": [
    {
      "request": {
        "serviceClientType": "JSONServiceClient",
        "method": "POST",
        "url": "https://myserver.mydomain.com/beforeConnect",
        "requestHeaders": [
          {
            "accept": "json"
          }
        ],
        "requestBody": {
          "myId": "1500000"
        }
      }
    }
  ],
  "afterAttemptComplete": [
    {
      "request": {
        "serviceClientType": "JSONServiceClient",
        "method": "POST",
        "url": "https://myserver.mydomain.com/afterAttemptComplete",
        "requestHeaders": [
          {
            "accept": "json",
            "Authorization": "Bearer C{token}"
          }
        ],
        "requestBody": {
          "myOtherId": "1500000"
        }
      }
    }
  ]
}


Was this article helpful?

What's Next
Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.