Introduction

In this article we’ll explain how to use the Email Sender component to send an e-mail message from a voice app created with the 3CX Call Flow Designer (formerly VAD).

The project for this application is installed along with the 3CX Call Flow Designer, in folder “Documents\3CX Call Flow Designer Demos”. You just need to change the SMTP server settings with your credentials. This application will record audio from the user, save that audio to a WAV file, and send that file as an attachment in an e-mail message.

Step 1: Create the project

First, we need to create a new project. Open the CFD and go to “File > New > Project”, select the folder where you want to save it, and enter a name for the project. In this case we’ll name it “EMailDemo”.

Step 2: Record audio from the user and save it to a file

Now we’ll record audio from the user and save it to a file, so we can send it as an attachment in an e-mail message later. To do this, we need to use a Record component:

Drag a Record 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 “recordYourMessage”.

Double click on the Record component to open the configuration dialog. Set the following properties:

Configure the “Prompts” with a WAV file to invite the user to leave a message.

Set the “Save to file” property to the expression “true” (without quotes, this is the “true” boolean value).

Set the “File name” property to the following expression, which will dynamically create the file name concatenating the text “CallFrom_” with the caller number, and finally “.wav”: CONCATENATE("CallFrom_",session.ani,".wav")

Press OK to save the changes.

Step 3: Send the audio recorded via e-mail

Now we need to send the audio just recorded as a file attached to an e-mail message. To do this, we need to add a new E-Mail Sender component to the “Audio Recorded” branch of the Record component, and configure it as follows:

Please note that for the fields that are expressions (they have the Fx button on the right), any constant value needs to be quoted. This is because these fields can also reference variables or be set with the result of a function invocation. In order to create a constant string value, we need to add quotes to it.

For the Subject property, we’re using an expression in order to include the number of the caller as well.

The list of attachments contains files, each one described by two columns:

Name: this is the name of the file that the email recipient will see. Here we enter Recording.wav so the file will always be attached with that name.

File: this is an expression to create a file name. Here we can’t use exactly the same expression that we defined for the Record component, because for the Record component we used a relative path specifying only the filename, and that causes that the recording is saved in the project audio folder. But for the E-Mail Sender component we need to specify the full path, therefore we use the variable “session.audioFolder” in the following expression:

CONCATENATE(session.audioFolder,"/CallFrom_",session.ani,".wav")

As a result, we’ll be attaching the file that was recorded in the previous step.

Step 4: Build and Deploy to 3CX Phone System

The project is ready. We just need to build and upload it to our 3CX Phone System server. To do this:

Go to “Build > Build All”. The CFD will create the file “EMailDemo.tcxvoiceapp”.

Go to the “3CX Management Console > Call Queues”, create a new queue, configure it with name and extension, check the “Voice apps” option, and upload the file created by the CFD in the previous step.

Save the changes to the queue. The voice app is ready to use. Make a call to the configured extension, record the message and you should receive an email with the recording attached.