3CX PBX in the Cloud
1 year FREE - no ties!
google cloud platform
3CX
Zero Admin
With the new Dashboard
3CX
Bulletproof Security
With SSL certs and NGINX
3CX
Install on $200 Appliance
Intel MiniPC architecture
3CX
New, Intuitive Windows Client
More themes, more UC
3CX
More CRM Integrations
Scripting Interface to add your own
3CX
Improved Integrated Web Conferencing
iOS and Android apps included
3CX
Run On-Premise or in the Cloud
Google, OVH, Windows & Linux
Fast & easy call management
With the 3CX Web Client

CFD Testing and Debugging

Testing & Debugging applications built with 3CX Call Flow Designer

On this topic

Testing & Debugging applications built with 3CX Call Flow Designer

Introduction

First step: fix build project errors

An error occurs when the CFD tries to create the .NET Core project

An error occurs compiling the project to a .NET Core DLL

Fixing errors in the expressions used when configuring components

Fixing errors caused by missing references

Adding the missing reference to the CompilerDependencies folder

Adding the missing reference and its dependencies to the Queue Manager service folder

Second step: analyze problems in runtime

See also

Introduction

The 3CX Call Flow Designer (formerly VAD) is a powerful tool for creating voice applications quickly and easily, without needing to have great programming or telephony skills. These applications are deployed to the server where 3CX Phone System is installed, and are implemented as voice apps inside Call Queues. Through the management interface it is possible to define the circumstances under which each of these applications is activated, eg for a specific PSTN line.

While creating these applications using the CFD is significantly easier than doing it programmatically, you can always make mistakes, and in these cases it is necessary to make a correct diagnosis of the problem in order to resolve it.

First step: fix build project errors

When your CFD project is ready, you need to build it. The build procedure consists in the following steps:

  1. The CFD creates a set of C# files that conform a .NET Core project.
  2. Then it compiles the project to a .NET Core DLL.
  3. Finally the CFD makes a ZIP including the DLL and the required WAV audio files, and encrypts it.

You might find errors in any of the steps above. Let’s see examples of each case.

An error occurs when the CFD tries to create the .NET Core project

This might happen for example if some component is not properly configured, a component property has not been set, etc. For example, if we use a Transfer component but we don’t set the Destination property, we’ll get an error.

When we build this project we’ll see the following error in the Error List window.

Double click on the error, and the designer will be shown with the component with problems selected.

An error occurs compiling the project to a .NET Core DLL

When all the components are configured, the CFD will be able to generate a C# .NET Core project, and then it will try to build this project to a DLL. The compilation procedure might fail because of different reasons, like errors in the expressions used when configuring components, or missing references.

Fixing errors in the expressions used when configuring components

One of the most common errors is using an invalid expression when configuring a component. For example, if you have a Transfer component and set the Destination to an invalid expression like this:

...you will get an error during build. The error will look like this:

As you can see, in this case the errors shown are the errors reported by the C# compiler. In the case that the compiler error description is not very clear to you, this is what you can do:

  1. Find the project sources created by the CFD. When the build fails, the sources created are not removed, so you can take a look in case of need. They’re located in the folder “OutputReleaseProjectNameSources” in your project folder. For example, in the case of this sample the project name is “Test01”, so the sources are here:

  1. In that folder you will find many files with extension “cs”, and a file named “project.csproj”. If you have Visual Studio installed, you can open this project, try to build it, and see the errors you get. You will see the same errors reported by the CFD, but Visual Studio will let you easily see the line in which the error is, so you can understand what you need to fix.
  2. If you don’t have Visual Studio or don’t want to use it, no problem. The problem is always in one of the following files, which you can open using a text editor:
  1. “Callflow.cs”: this is the file that defines the behavior of the callflow in your project. If the problem is in the callflow, then you need to check this file.
  2. “Dialer.cs”: this is the file that defines the behavior of the dialer in your project. If the problem is in the outbound dialer, then you need to check this file.
  3. “YourComponentName.cs”: this is the file that defines the behavior of your custom component. When you add a custom component with name “MyCustomComponent.comp” you will see a file with name “MyCustomComponent.cs” which contains this component behavior.
  1. In our case, the error was reported in line 133 (column 70). If we open the file “Callflow.cs” using a text editor and go to line 133, we’ll see the following.

  1. As you can see, the problem is that the Destination property is being set to InvalidExpression, which is not a valid string or variable name.

Fixing errors caused by missing references

When you use a Launch External Script component, you will provide your C# code to execute. This C# code might need external DLL references, not included by default in the 3CX CFD. In this case, when you build your CFD application you will see an error like “Error compiling source code to .NET library: (9,7): error CS0246: The type or namespace name 'XmlDocument' could not be found (are you missing a using directive or an assembly reference?)”:

In order to fix this, we need to:

  1. Add the missing reference to the CompilerDependencies folder, so compilation succeeds.
  2. Add the missing reference and its dependencies to the Queue Manager service folder, so it can be loaded in runtime.

Let’s cover these tasks in more detail. We’ll show the step by step procedure for the example missing reference “System.Xml.XmlDocument.dll”.

Adding the missing reference to the CompilerDependencies folder

When the CFD compiles the generated C# .NET Core project, it uses all the DLLs in the CompilerDependencies folder from your installation path, usually “C:Program Files3CX Call Flow DesignerCompilerDependencies”, as references. If you need additional references, just copy the DLLs to this folder and the CFD will consider them in the next build.

As you’re writing the C# code, you must know which DLLs you need to include. If you’re using Visual Studio to test your code before including it in the CFD project, when you add the reference, it will be automatically downloaded by Visual Studio from nuget, and placed in your local drive in folder “C:UsersUserName.nugetpackages”. You can also manually download the package from https://www.nuget.org, and unzip it to get the DLL from inside.

When you have the nuget package in your local drive, you need to get the right version of the DLL. The application generated by the CFD will run as a .NET Core application, so you can’t use the DLL for the .NET Framework for example. In the case of the “System.Xml.XmlDocument.dll” we need to take it from here:

C:UsersUserName.nugetpackagesSystem.Xml.XmlDocument4.0.1libnetstandard1.3System.Xml.XmlDocument.dll

Just copying that DLL to the CompilerDependencies folder will fix the compilation issue. But when you upload this app to 3CX, the DLL will not be found in the server, and we’ll experience a runtime error. So let’s tackle that issue as well.

Adding the missing reference and its dependencies to the Queue Manager service folder

The app generated with the 3CX CFD will be executed by the 3CX Queue Manager service. If your code is trying to use a missing DLL, the log file “3CXQueueManager.log” will give you that information:

17/05/24 13:00:45.186|100030| Err|10|0032|: PlugIn[TestApp - UserComponent 'validateDataXml' - MainFlow - CallID VICXIAXSCWGX] ERROR: Error executing last component: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Xml.XmlDocument, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. ---> System.IO.FileNotFoundException: Could not load file or assembly 'file:///C:Program Files3CX Phone SystemInstance1BinSystem.Xml.XmlDocument.dll' or one of its dependencies. The system cannot find the file specified.

In order to fix this, we need to copy the DLL, and all its dependencies, to the 3CX Queue Manager service folder, that is “C:Program Files3CX Phone SystemInstance1Bin” in Windows and “/usr/lib/3cxpbx” in Linux. In this case, just copying the file “System.Xml.XmlDocument.dll” is not enough, the same error will continue happening, because there are more dependant DLLs to add. In order to find out which are the dependencies, we need to go to the package specification, for example in our case to this page. As you can see, under the title “.NETStandard 1.3” we have the following dependencies:

  • System.Collections (>= 4.0.11)
  • System.Diagnostics.Debug (>= 4.0.11)
  • System.Globalization (>= 4.0.11)
  • System.IO (>= 4.1.0)
  • System.Resources.ResourceManager (>= 4.0.1)
  • System.Runtime (>= 4.1.0)
  • System.Runtime.Extensions (>= 4.1.0)
  • System.Text.Encoding (>= 4.0.11)
  • System.Threading (>= 4.0.11)
  • System.Xml.ReaderWriter (>= 4.0.11)

If you were using Visual Studio to test your C# code before including it in the CFD project, then all these packages should be already downloaded to your local drive. For each dependency, you need to get the nuget package, copy the DLL from the “lib” or “ref” folder to the 3CX Queue Manager service folder as you did in the previous step, and then check for additional dependencies for each dependency added. Please note that some dependency might be already present in the 3CX Queue Manager service folder, in that case keep the DLL provided by 3CX with the installation.

In our example, after iterating over all the dependencies and nested dependencies, we’ll need to copy the following DLLs to the 3CX Queue Manager service folder (file paths are relative to C:UsersUserName.nugetpackages):

  • System.Collections4.3.0refnetstandard1.3System.Collections.dll
  • System.Diagnostics.Debug4.3.0refnetstandard1.3System.Diagnostics.Debug.dll
  • System.Globalization4.3.0refnetstandard1.3System.Globalization.dll
  • System.IO4.3.0refnetstandard1.3System.IO.dll
  • System.Reflection4.3.0refnetstandard1.3System.Reflection.dll
  • System.Reflection.Primitives4.3.0refnetstandard1.0System.Reflection.Primitives.dll
  • System.Resources.ResourceManager4.3.0refnetstandard1.0System.Resources.ResourceManager.dll
  • System.Runtime4.3.0refnetstandard1.3System.Runtime.dll
  • System.Runtime.Extensions4.3.0refnetstandard1.3System.Runtime.Extensions.dll
  • System.Text.Encoding4.3.0refnetstandard1.3System.Text.Encoding.dll
  • System.Threading4.3.0libnetstandard1.3System.Threading.dll
  • System.Threading.Tasks4.3.0refnetstandard1.3System.Threading.Tasks.dll
  • System.Xml.ReaderWriter4.3.0libnetstandard1.3System.Xml.ReaderWriter.dll

After copying the DLLs mentioned to the 3CX Queue Manager service folder, the issue is solved and the application starts running as expected.

Second step: analyze problems in runtime

Once you have built your project, you will get an output file with extension “tcxvoiceapp”. This file contains the DLL and the audio WAV files of your project. Using the 3CX Management Console you upload this file to a Call Queue, the Queue Manager service is restarted, and the voice app is ready to be used.

So, what happens now if the app is not doing what we want? We need to check the logs to understand what the app is doing. Voice apps write logs to the Queue Manager log file. The file name is “3CXQueueManager.log” and it’s located at “C:ProgramData3CXInstance1DataLogs” in Windows, or “/var/lib/3cxpbx/Instance1/Data/Logs” in Linux.

We’ll work with a very simple sample application, which plays a file “Hello.wav”, then tries to execute some C# code (which just throws an exception), and finally transfers the call to the operator (this will not happen because of the error in the previous component). The designer will look like this:

We deploy this app to 3CX, to the Call Queue with extension 801. Then we call to the extension 801, and we’ll see the following in the logs:

  1. 17/05/08 14:32:09.742|100023| Inf|30|0006|: PlugIn[Test01]” INFO: Starting...
  2. 17/05/08 14:32:09.742|100046| Trc|75|0006|: DBG: VAD C:ProgramData3CXInstance1DataVoiceappsTest01Test01.qmext.dll was loaded successfully
  3. 17/05/08 14:32:09.744|100049| Trc|75|0014|: PlugIn[Test01] Trace: Start looking for queues assigned to this app...
  4. 17/05/08 14:32:09.745|100049| Trc|75|0014|: PlugIn[Test01] Trace: This app is assigned to queue number '801', getting queue...
  5. 17/05/08 14:32:09.751|100049| Trc|75|0014|: PlugIn[Test01 - Main] Trace: Caching the following audio files: C:ProgramData3CXInstance1DataIvrPrompts....VoiceappsTest01Audiobeep.wav, C:ProgramData3CXInstance1DataIvrPrompts....VoiceappsTest01AudioHello.wav
  6. 17/05/08 14:32:09.753|100049| Trc|75|0014|: PlugIn[Test01] Trace: Main instance created for queue number '801', start processing calls...
  7. 17/05/08 14:32:17.014|100007| Inf|30|0012|: Call(NPICEAMLUKCX) has been started
  8. 17/05/08 14:32:17.076|100005| Inf|10|0006|: New incoming call to Q:801 from 100; qcid=NPICEAMLUKCX
  9. 17/05/08 14:32:17.082|100049| Trc|75|0006|: PlugIn[Test01 - Main - CallID NPICEAMLUKCX] Trace: OnNewQueueCall - taking call out of the queue and creating CallHandler for this call...
  10. 17/05/08 14:32:17.087|100046| Trc|75|0006|: DBG: Call(NPICEAMLUKCX) has been taken out of the queue Q:801
  11. 17/05/08 14:32:17.092|100046| Trc|75|0006|: DBG: QCall NPICEAMLUKCX state changed: Init -> PluginHandlesIt
  12. 17/05/08 14:32:17.093|100049| Trc|75|0006|: PlugIn[Test01 - CallHandler - CallID NPICEAMLUKCX] Trace: OnStateChanged: obj='PluginHandlesIt'
  13. 17/05/08 14:32:17.131|100033| Trc|75|0011|: Call update(Ins): cid=2, dn=801, internal=<empty>, external=100, ac_stat=Ringing, leg=203; att=''
  14. 17/05/08 14:32:17.131|100046| Trc|75|0011|: DBG: : [202,203]
  15. 17/05/08 14:32:17.394|100033| Trc|75|0011|: Call update(Upd): cid=2, dn=Ext.100 John Doe, internal=<empty>, external=801, ac_stat=Connected, leg=202; att='8aa5115d854643c4a4a56157ad32c9ec'
  16. 17/05/08 14:32:17.400|100046| Trc|75|0011|: DBG: : [202,203]
  17. 17/05/08 14:32:17.404|100033| Trc|75|0011|: Call update(Upd): cid=2, dn=801, internal=<empty>, external=100, ac_stat=Connected, leg=203; att=''
  18. 17/05/08 14:32:17.404|100046| Trc|75|0011|: DBG: : [202,203]
  19. 17/05/08 14:32:17.565|100049| Trc|75|0006|: PlugIn[Test01 - CallHandler - CallID NPICEAMLUKCX] Trace: OnCallEstablished - Taking call out of the queue...
  20. 17/05/08 14:32:17.672|100033| Trc|75|0011|: Call update(Upd): cid=2, dn=801, internal=<empty>, external=100, ac_stat=Connected, leg=203; att='NPICEAMLUKCX'
  21. 17/05/08 14:32:17.677|100046| Trc|75|0011|: DBG: NPICEAMLUKCX: [202,203]
  22. 17/05/08 14:32:17.988|100046| Trc|75|0006|: DBG: CMNotify(NPICEAMLUKCX): NewQCall, legId 203
  23. 17/05/08 14:32:17.988|100046| Trc|75|0006|: DBG: CMNotify(NPICEAMLUKCX): LegStateChanged, legId 203
  24. 17/05/08 14:32:18.028|100049| Trc|75|0020|: PlugIn[Test01 - Callflow - MainFlow - CallID NPICEAMLUKCX] Trace: Start executing component 'playHello'”
  25. 17/05/08 14:32:18.030|100049| Trc|75|0020|: PlugIn[Test01 - Callflow - MainFlow - CallID NPICEAMLUKCX] Trace: Start executing component 'executeSomeCode'”
  26. 17/05/08 14:32:18.541|100049| Trc|75|0020|: PlugIn[Test01 - ExternalCodeExecutionComponent - CallID NPICEAMLUKCX] Trace: Start executing component with objectType='SomeCodeNamespace.MyClass' - methodName='DoSomething'
  27. 17/05/08 14:32:18.582|100030| Err|10|0020|: PlugIn[Test01 - Callflow - MainFlow - CallID NPICEAMLUKCX] ERROR: Error executing last component”: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Exception: This is an exception thrown from my code”
  28.    at SomeCodeNamespace.MyClass.DoSomething()
  29.    --- End of inner exception stack trace ---
  30.    at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
  31.    at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
  32.    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
  33.    at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
  34.    at Test01.ExternalCodeExecutionComponent.executeStart(QMExtendAPI iface, String id)
  35.    at Test01.ExternalCodeExecutionComponent.Start(QMExtendAPI iface, CallQueue callQueue, QueueCall queueCall, ActiveConnection activeConnection, TimerManager timerManager, Dictionary`2 variableMap, TempWavFileManager tempWavFileManager, PromptQueue promptQueue)
  36.    at Test01.Callflow.ProcessStart()
  37. 17/05/08 14:32:18.583|100049| Trc|75|0020|: PlugIn[Test01 - Callflow - ErrorFlow - CallID NPICEAMLUKCX] Trace: Start executing component 'errorHandlerAutoAddedFinalExitCallflow'”
  38. 17/05/08 14:32:18.585|100049| Trc|75|0020|: PlugIn[Test01 - PromptQueue - CallID NPICEAMLUKCX] Trace: Start playing file: C:ProgramData3CXInstance1DataIvrPrompts....VoiceappsTest01AudioHello.wav”
  39. 17/05/08 14:32:18.590|100046| Trc|75|0020|: DBG: Using prompts path 'F1BAA317-E130-44ff-B467-63AE7F9EC061'
  40. 17/05/08 14:32:18.594|100046| Trc|75|0020|: DBG: Playing: [[Hello.wav]] to NPICEAMLUKCX
  41. 17/05/08 14:32:23.797|100045| Dbg|90|0021|: Audio (id=1) has been played for call QC:NPICEAMLUKCX[100->801]
  42. 17/05/08 14:32:23.810|100049| Trc|75|0006|: PlugIn[Test01 - CallHandler - CallID NPICEAMLUKCX] Trace: OnPromptPlayed: obj='1'
  43. 17/05/08 14:32:23.823|100049| Trc|75|0020|: PlugIn[Test01 - Callflow - ErrorFlow - CallID NPICEAMLUKCX] Trace: OnPromptPlayed for component 'errorHandlerAutoAddedFinalExitCallflow'
  44. 17/05/08 14:32:23.824|100049| Trc|75|0020|: PlugIn[Test01 - Callflow - ErrorFlow - CallID NPICEAMLUKCX] Trace: Callflow finished, disconnecting call...
  45. 17/05/08 14:32:23.866|100008| Inf|30|0006|: Call(NPICEAMLUKCX) has been terminated (reason: Unknown)
  46. 17/05/08 14:32:23.868|100049| Trc|75|0006|: PlugIn[Test01 - CallHandler - CallID NPICEAMLUKCX] Trace: OnInboundCallTerminated: obj='487'

We need to note the following:

  1. Every log line from a CFD app starts with “PlugIn[ProjectName”, in our case “PlugIn[Test01”, as highlighted in bold in line 1.
  2. In line 24, we see that the component “playHello” is being executed.
  3. In line 25, we see that the component “executeSomeCode” is being executed.
  4. In line 27, we see that an error occurs while executing component “executeSomeCode”.
  5. Then in line 37, we see that the error handler flow is executed, but as it is empty, no user component is executed there.
  6. In line 38, we see that the file “Hello.wav” is played. When the property AllowDtmfInput is set to true, it is normal that the file is played after the error, because audio files are queued in that case, to be played when the voice app is waiting for a DTMF digit, or when the app is ending.

As we can see, in this sample application the error occurs when we try to execute the component “executeSomeCode”, and therefore we need to check what that component is doing.

See also

You might also be interested in:

Get 3CX Free for 1 Year Today
Download On-Premise Try in the Cloud