Using the Survey component
Introduction
The Survey component lets a CFD app ask questions to the caller, and automatically store the user’s feedback to a CSV file. However, storing the information in a CSV file in the 3CX server is not always the best approach, and we need to send the information somewhere else, for example a database or a web service. In this demo we will show how to create an application with the 3CX Call Flow Designer to accomplish this.
💡 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”.
In this demo we will use the Survey component to ask 3 questions to the caller:
- Have we resolved the issue you called about? For yes press 1, for no press 2.
- How would you rate the attention received? Please use a number from 1 to 5, where 1 is bad and 5 is excellent.
- Please leave your comments as a recorded message, and press # to finish the recording.
Then we will send this information to a database for further processing.
Step 1: Create the Project
First, we need to create a new project. Open the CFD and go to “File” > “New” > “Callflow Project”, select the folder where you want to save it, and enter a name for the project, e.g. “SurveyDemo”.
Step 2: Add the Survey component
Let’s add a Survey component and configure the options we need:
- Drag a “Survey” component from the toolbox, and drop it into the design surface of the “Main” callflow. Then select the component added, go to the “Properties Window” and rename it to “CustomerFeedback”.
- Double-click on the “Survey” component to configure these properties:
- Recordings Path: specify a folder in your 3CX server to store the customers’ recordings.
- Export to CSV File: specify the name of a CSV file in which the component will store the results.
- “Introductory Prompts” - configure an Audio File Prompt to play a WAV file with a welcome message, e.g. “Welcome to this survey demo app”.
- “Goodbye Prompts” - configure an Audio File Prompt to play a WAV file when the survey ends, e.g. “Thanks for your feedback, have a nice day.”.
- “Timeout Prompts” - configure an Audio File Prompt to play a WAV file that explains that no digit was detected, e.g. “Sorry, we didn’t receive any digit”.
- “Invalid Digit Prompts” - configure an Audio File Prompt to play a WAV file that explains that the digit entered is invalid, e.g. “Sorry, the selected option is not valid”.
- Configure 3 questions:
- A Yes/No question, with Tag set to “solved”, and the following prompt: “Have we resolved the issue you called about? For yes press 1, for no press 2.”
- A Range question, with Tag set to “rating”, and the following prompt: “How would you rate the attention received? Please use a number from 1 to 5, where 1 is bad and 5 is excellent.”
- A Recording question, with Tag set to “comments”, and the following prompt: “Please leave your comments as a recorded message, and press # to finish the recording.”. Set this question to offer playing it back to the caller, and configure the Pre Recording Prompt to a message saying “This is your recording.”, and Post Recording Prompt to a message saying “To keep it press 2, to discard it and record another message press 2”.
- Add the caller’s number as an additional output field, so it’s included in the generated CSV file. To do this, set the name to callerand the value to the variablesession.ani.
- Press “OK” to save the changes.
Step 3: Use a C# script to get the value for each answer
The Survey component automatically adds users’ responses to the CSV file. However, in this case we want to send this information to a database. To do this, we have the
1234567891,NO,3,/surveydemo/recordings/SurveyRecording_20210420130525_1157558617.wav
Then, the
- We will use a very simple C# script to extract the first value (solved response). The script is the following:
- We repeat the procedure for the other two values:
- For the rating response we use the code: return surveyResult.Split(',')[2];
- For the recording we use the code: return surveyResult.Split(',')[3];
- So far, the callflow will look like the following:
Step 4: Store the values in a database
Now that we have each value splitted from the original
- Drag a Database Access component from the toolbox to the designer, just under the last Execute C# Code component added in the previous step. Rename the component to “AddResultToDatabase”.
- Double click the component to open the configuration dialog. Configure the component as follows:
- Database Type: select your database type (the supported databases are Microsoft SQL Server, MySQL and PostgreSQL).
- Server: use the Expression Editor to create an expression that returns the database server IP address or server name. This could be a constant string or you can use for example a variable to store the information.
- Port: specify the port number to which the database connection should be established.
- Database: specify the name of the database to which you want to connect.
- User Name: specify the username to use to connect to the database.
- Password: specify the password to use to connect to the database.
- Statement Type: we will use NonQuery in this case, because we want to execute a statement that will not return any data.
- Timeout: leave the default value of 30 seconds, or specify a reasonable value to wait for the statement execution.
- SQL Statement: here we will build the SQL statement using the Expression Editor, so we can concatenate static text and variables. The expression we will use is the following:
- Press “OK” to save the changes.
Step 5: Build and Deploy to 3CX Phone System
The project is ready to build and upload to our 3CX Phone System server, with these steps:
- Select “Build” > “Build All” and the CFD generates the file “SurveyDemo.zip”.
- Go to the “3CX Management Console” > “Advanced” > “Call Flow Apps” > “Add/Update”, and upload the ZIP file generated by the CFD in the previous step.
- The Call Flow app is ready to use. Make a call to the application, answer the questions and check your answers in the database.
See Also
- Learn more about CFD components.
- Automated Telephone Ordering Voice app with CRM integration via the 3CX API.
- Sending emails from a CFD voice app.
- Routing Calls Based on the Time of Day.
- 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.
- Using the Loop component to navigate upwards
- Registering and making callbacks
- Using the CRM Lookup component
- See how to integrate your PBX with a CRM via the 3CX API.
Last Updated
This document was last updated on 29th April 2021
https://www.3cx.com/docs/cfd-survey-component/