Testing, Debugging & Migrating Apps Βuilt with 3CX CFD
- Introduction
- Building your CFD Project
- Fixing Project Compilation Errors
- An Error Occurs when the CFD Tries to Create the C# Script
- An Error Occurs Compiling the C# Script
- Fixing Errors in the C# scripts provided
- Fixing Errors Caused by Nested Namespaces
- Fixing Errors Caused by Missing References
- Fixing Project Runtime Errors
- See Αlso
Introduction
The 3CX Call Flow Designer is a powerful tool for creating voice applications quickly and easily, without the need to have great programming or telephony skills. These applications are deployed on the 3CX Phone System server, implemented as Call Flow Apps. Through the management interface it is possible to define the conditions for which each of these applications is activated, e.g. for a specific inbound rule.
While creating these applications using the CFD is significantly easier than doing it programmatically, you can always make mistakes. In these cases it is necessary to correctly diagnose the problem to resolve it.
Building your CFD Project
When your CFD project is ready, you need to build it:
- Go to “Build” > “Build All” or press Ctrl + B.
- If needed, assign an extension number to the project, otherwise leave the Extension field empty.
- CFD creates a “Release” folder in the CFD Project “Output” folder, containing a ZIP archive with a manifest file, a C# script and project WAV files, ready for upload to 3CX.
- Upload the generated ZIP archive to 3CX and the 3CX Call Flow Server compiles your script.
- A green icon indicates a succesful compilation and the CFD app is ready for use. Otherwise, click to open the app to check for any compilation error(s).
Fixing Project Compilation Errors
These are examples of the various possible compilation errors that may occur:
An Error Occurs when the CFD Tries to Create the C# Script
This may happen for example if some component is not properly configured, a component property has not been set, etc.
For example, using a “Transfer” component without the “Destination” property set, we get an error.
When building this project the error message appears in the “Error List” panel. Double-click on the error to show the designer with the problematic component selected.
An Error Occurs Compiling the C# Script
After successfully building your CFD app, on upload to 3CX a compilation error may occur, due to various reasons like errors in component configured expressions or missing references.
Fixing Errors in the C# scripts provided
One of the most common errors is providing C# code that causes errors. For example, when using an Execute C# Code component with the following configuration:
When this project is built from the CFD, no error is detected, as the C# code is not being compiled yet. However, when the generated ZIP is uploaded to the 3CX Management Console, this error occurs:
As you can see, in this case the errors shown are the errors reported by the C# compiler. These errors provide a good hint for what needs to be adjusted to get the app working.
Fixing Errors Caused by Nested Namespaces
When using the “Execute C# File” component, if your script has a namespace declaration, the resulting script is not compiled by 3CX. For example, if we include the following script in our project via an “Execute C# File” component:
{ public class MyClass { public int DoSomething(int a, int b) { return a + b; } } }
When we upload the project to 3CX, an
{ public int DoSomething(int a, int b) { return a + b; } }
Fixing Errors Caused by Missing References
When you use an Execute C# Script of Execute C# Code component, you provide the C# code to execute. This C# code may need external DLL references, not included in the 3CX server. In this case, when 3CX builds your CFD app scripts, you see an error like “Error CS0246: The type or namespace name 'YourCustomLibrary' could not be found (are you missing a using directive or an assembly reference?)”.
The 3CX Call Flow Server includes ONLY these reference assemblies when compiling a CFD script:
- mscorlib
- System
- System.Core
- System.Runtime
- System.Collections
- System.Core
- System.IO
- System.IO.FileSystem
- System.Runtime
- System.Collections
- Microsoft.CSharp
- netstandard
- System.Linq
- System.Linq.Expressions
- System.Linq.Parallel
- System.Linq.Queryable
- System.Net.Http
- Newtonsoft.Json
- System.Xml
- System.Xml.Linq
- System.Xml.ReaderWriter
- System.Xml.Serialization
- System.Xml.XDocument
- System.Xml.XmlDocument
- System.Xml.XmlSerializer
- System.Xml.XPath
- System.Xml.XPath.XDocument
- System.Xml.XPath.XmlDocument
- System.Xml.XDocument
- System.Private.Xml
- System.Private.Xml.Linq
- System.Private.Uri
- 3cxpscomcpp2
- MailKit
- MimeKit
- MySqlConnector
- Npgsql
- System.ComponentModel
- System.ComponentModel.Primitives
- System.Data
- System.Data.Common
- System.Data.SqlClient
- System.Net.Primitives
- System.Net.Sockets
- System.Security.Cryptography.Algorithms
- System.Security.Cryptography.Primitives
- System.Text.RegularExpressions
- TcxMail
- System.Threading
- System.Threading.Timer
- System.Threading.Tasks
- System.Threading.Tasks.Dataflow
- AWSSDK.Core
- AWSSDK.Polly
- CallFlow.CFD
You can use any class from those assemblies in your C# code. Unfortunately, additional libraries cannot be included as compilation references. If you need to use other third-party DLLs, you need to create a separate program to use those DLLs, and connect to this program by different means, e.g. using a web service interface.
Fixing Project Runtime Errors
Once you have built your project with the CFD, uploaded it to 3CX with successful script compilation, the voice app is ready to be used.
If the app is not doing what it is designed to do, you need to check the logs to investigate the app’s operation. Call Flow Apps write log messages to the “3CXCallFlow.log” file:
- on Windows in: “C:\ProgramData\3CX\Instance1\Data\Logs”
- on Linux in: “/var/lib/3cxpbx/Instance1/Data/Logs”
Our example is based on a very simple application with the above callflow, playing a file “Hello.wav”, then tries to execute some C# code which throws an exception, and finally transfers the call to the operator. The transfer fails due to the error in the “Execute C# File” component. Deploying this app to 3CX and then calling it, we notice these log entries:
at _mytestapp.Main_59.Main.MyClass.DoSomething() at _mytestapp.Main_59.Main.executeSomeCodeExternalCodeExecutionComponent.ExecuteCode() at CallFlow.CFD.ExternalCodeExecutionComponent.ExecuteStart() at CallFlow.CFD.ExternalCodeExecutionComponent.Start(TimerManager timerManager, Dictionary`2 variableMap, TempWavFileManager tempWavFileManager, PromptQueue promptQueue) at _mytestapp.Main_59.Main.ProcessStart()
Note that:
- Every log line from a CFD app starts with “From script: ProjectName”, in our case “From script: MyTestApp”, as highlighted in bold on line 1.
- The “CallID” is shown on each line, identifying which log line belongs to each call.
- On line 2, we see that the component “playHello” is being executed.
- On line 7, we see that the component “executeSomeCode” is being executed.
- On line 9, we see that an error occurs while executing component “executeSomeCode”.
- On line 10, we see that the error handler flow is executed, but as it is empty, no user component is executed.
In this example application the error occurs when trying to execute the component “executeSomeCode”, so we need to check what that component is doing.
See Αlso
- Install the 3CX Call Flow Designer
- Accessing a database from a CFD voice app
- Sending emails from a CFD voice app
- How to play a sequence of digits from a 3CX Call Flow Designer voice app
- Automated Telephone Ordering Voice app with CRM integration via the 3CX API
- Creating a Phone Support Portal with the 3CX Call Flow Designer – Part 1, 2, 3, 4
- Routing Calls Based on the Time of Day
- Creating an outbound dialer
- Time-Based Routing without Programming
- Using the Authentication component to validate customers
- Using the Credit Card Component
- Text to Speech and Speech to Text with the 3CX Call Flow Designer
- Creating a predictive dialer with the 3CX CFD
- Using the Loop component to navigate upwards
- Registering and making callbacks
- Using the survey component
- Using the CRM Lookup component
- See how to integrate 3CX with the CRM API
Last Updated
This document was last updated on 25th May 2023