Creating a Phone Support Portal with the 3CX Call Flow Designer – Part 2

Introduction

In the previous guide of this series Creating a Phone Support Portal with 3CX Call Flow Designer – Part 1, we explained how to create the application callflow, to validate whether a customer has a support contract, and then transfer the call to the appropriate department. We have left the validation using different data sources for subsequent articles.

This guide describes how to perform the validation using a web service.

💡 Tip: The project for this example application is available via the CFD Demos GitHub page, and is installed along with the 3CX Call Flow Designer in your Windows user documents folder, i.e. “C:\Users\YourUsername\Documents\3CX Call Flow Designer Demos”.

How to Invoke the Web Service

The 3CX Call Flow Designer includes the HTTP Requests, “Web Services REST” and Web Services (POST) components out of the box to invoke web services. The Web Services (POST) component is provided for backward compatibility only and is not recommended for new projects. It is a simplification of the HTTP Requests component, which sets the HTTP method to POST, and creates the URL concatenating the provided URL and the web service name, so for example if the URL is http://www.example.com and the web service name is “MyWebMethod”, then the HTTP POST request is sent to http://www.example.com/MyWebMethod. On the other hand, the “Web Services REST” component provides additional capabilities, like authentication.

For this example, we use the HTTP Request component, which is more flexible for modern REST web services that require other HTTP methods than POST:

  1. Open the user component created in the previous article to perform the customer validation (ValidateData), drag an HTTP Request component from the toolbox and drop it into the design surface.

HTTP Request component configuration in 3CX CFD

  1. Rename the component to validateDataWS and configure the URL, the request type, the content type and the content data to send, as in the example image above. Add headers to the request if needed. In this case, we send the data as “application/x-www-form-urlencoded”, using this expression to create the data to send:

CONCATENATE("ID=",callflow$.CustomerID,"&PIN=",callflow$.CustomerPIN)

  1. Then we need to set the HTTP request result to the output property ValidationResult. Assuming that the web service returns the value 1 when the validation is successful, and 0 otherwise, we can use an Assign a Variable component to set the result to the variable callflow$.ValidationResult using this expression:

EQUAL(validateDataWS.ResponseContent,1)

Example callflow in 3CX CFD

Consider the example call flow above.

Analyzing Web Service Response

In this case we simplified our scenario, and defined that the web service returns a number “1” or “0” depending on the validation result. This is usually not the case, and the response in most common cases is XML or JSON. In that case the response needs to be parsed, and to do that it’s necessary to use an Execute C# Code” or Execute C# File” component. Using these components we can execute C# code, and use the XML classes from .NET core to parse XML, or the Newtonsoft library to parse JSON.

Conclusion

This guide presented how to invoke a web service to validate the data entered by the customer. The next guides in this series describe how to perform this validation via these external data sources:

  • XML Text File
  • CSV Text File
  • SQL Server Database

The third part of the series Creating a Phone Support Portal with the 3CX Call Flow Designer – Part 3 shows how to perform the validation using XML and CSV text files.

See Also

Last Updated

This document was last updated on 29th April 2021

https://www.3cx.com/docs/cfd-creating-phone-support-portal-2/