Sending Emails from a Call Flow

Introduction

This guide describes how to use the “Email Sender” component to send an email message from a Call Flow app created with the 3CX Call Flow Designer (formerly VAD).

💡 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”.

To customize this example project you just need to change the SMTP server settings with your credentials. This application records audio from the user, saves that audio to a WAV file, and sends 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, e.g. EMailDemo.

Step 2: Record Audio from User and Save to File

To record audio from the user, save it to a file and send it as an attachment in an e-mail message, we need to use a “Record” component:

  1. 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” and rename it to “recordYourMessage”.
  2. Double-click on the “Record” component to configure these properties:

Record component configuration in 3CX CFD.

  • 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 the quotes, this is the “true” boolean value).
  • Set the “File name” property to the following expression, which dynamically creates the file name concatenating the text “CallFrom_” with the caller number and “.wav”, e.g.:

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

  1. Press “OK” to save the changes.

Step 3: Send the Recorded Audio via E-mail

To send the recorded audio as a file attached to an e-mail message, we add a new “EMail Sender” component to the “Audio Recorded” branch of the Record component and configure it:

Email Sender component configuration in 3CX CFD

Please note that for expression fields, i.e. have the “x” button on the right, any constant value needs to be quoted, as these fields can also reference variables or be set with the result of a function invocation. To create a constant string value, we need to add quotes to it.

For the “Subject” property, we use an expression to also include the number of the caller.

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

  • “Name”: the name of the file that the email recipient(s) see. Here we enter “Recording.wav” so the file is always attached with that name.
  • “File”: 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, as the recording is saved in the project audio folder. But for the “EMail Sender” component we need to specify the full path, therefore we use the variable “session.audioFolder” in the expression to attach the file recorded in the previous step:

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

Step 4: Build and Deploy to 3CX Phone System

The project is ready to build and upload to our 3CX Phone System server, with these steps:

  1. Select “Build” > “Build All” and the CFD generates the file “EMailDemo.zip”.
  2. Go to the “3CX Management Console” > “Advanced” > “Call Flow Apps” > “Add/Update”, and upload the file created by the CFD in the previous step.
  3. The Call Flow app is ready to use. Make a call to it, record the message and you should receive an email with the recording attached.

See Also

Last Updated
This document was last updated on 29th April 2021
https://www.3cx.com/docs/cfd-emails-voice-app/