Creating a phone support portal with 3CX VAD – Part 3


In the articles Creating a phone support portal with the VAD – Part 1 and Part 2, we have shown how to create an application to validate whether a customer has a support contract, and then transfer the call to the appropriate department.

In the first part we have shown how to create the application callflow, while in the second part we have shown how to validate the information using a web service.

In this article we will show how to perform the validation using the information available in text files:

  • XML File
  • CSV Text File

Performing the validation using an XML File from inside a DLL

While it is possible to perform this type of validation using the “File Management” component to read the contents of a text file, the subsequent analysis of its content would have to be done within a DLL or JavaScript function, so it makes no sense to split the operation in that way.

It is better to create a DLL, read the file and analyze its content in one place. Also, it could be possible to implement the DLL in such a way that the file is read only once, and then accessed many times, improving performance.

To do this, open Visual Studio and create a new Class Library project (File > New > Project > Visual C# > Windows > Class Library). In this example we’ll make the coding in C# language, but it’s possible to use any other .NET framework language. Let’s name the project “TextFileValidator”.

Once the project has been created, rename the main class from “Class1” to “Validator”, and write the following code:

using System.Xml;

namespace TextFileValidator
  public class Validator
    public bool ValidateXML(string id, string pin)
      XmlDocument xmlDocument = new XmlDocument();

      XmlNodeList customerElementList = xmlDocument.GetElementsByTagName("customer");
      foreach (XmlNode xmlNode in customerElementList)
        string customerID = xmlNode.Attributes["id"].Value;
        string customerPIN = xmlNode.Attributes["pin"].Value;

        if (id == customerID && pin == customerPIN) 
          return true;

      return false;


The code above supposes that the XML file has the following format:


  <customer id="1" pin="1111"/>

  <customer id="2" pin="2222"/>

  <customer id="3" pin="3333"/>

  <customer id="4" pin="4444"/>

  <customer id="5" pin="5555"/>


Build the project and copy the generated DLL into the “Libraries” folder located into the VAD project folder. This DLL will be invoked from an “External Code Execution” component. To do that, add a new “External Code Execution” component to the design surface and configure it as follows:


Then we need to assign the execution result to the output property “ValidationResult”. To do that we’ll use a “Variable Assignment” component to assign the value “validateTextFile.ReturnValue” to the variable “callflow$.ValidationResult”. The diagram will look like the following:


Performing the validation using a CSV Text File from inside a DLL

Other possible file format to use is CSV (Comma Separated Values). Let’s suppose that the file has the format “ID,PIN”, for example:






We can extend the previous project by adding a method “ValidateCSV”. The code for this new method could be:

public bool ValidateCSV(string id, string pin)
      string[] textLines = File.ReadAllLines("Customers.csv");
      foreach (string line in textLines)
        string[] lineParts = line.Split(',');
        if (lineParts.Length == 2)
          string customerID = lineParts[0];
          string customerPIN = lineParts[1];

          if (id == customerID && pin == customerPIN)
            return true;

      return false;


Then we invoke this new method using an “External Code Execution” component, in the same way we did for XML File.


In this article we have shown how to validate the data entered by the customer using an XML File and a CSV Text File, through a DLL created with Visual Studio. The next article in the series will show how to perform this validation through the following external data sources:

  • Microsoft Excel Spreadsheet
  • SQL Server Database
  • Microsoft Access Database File
  • Another database via ODBC

The fourth and final  part of the series Creating a phone support portal with 3CX VAD – Part 4  shows how to perform the validation using the information available in databases and Microsoft Excel files.

Liked this article?

Get notified of new articles
or share
You might also be interested in: