Forms Autoresponder

Hooks allows us to create custom email notifications that are sent to the customer upon form submission. In this example we will create a hook that will send a email to the customer that includes a PDF guide for them to download.

Navigate to Orchestration > List and click Add Job to add a new job to the existing list. (This section was previously called Automations > Hooks; a job is still a hook.)

The Orchestration list in the Core dna admin, with the Add Job button

Add Name & Description to the new job, this will also display on the Orchestration list page

  1. Open the Triggers tab and configure the “Entity Event Triggers”:

    1. Entity: Form Submission

    2. Method: Completed

    3. Parent Form: the form this autoresponder is for

Entity Event Trigger set to Form Submission / Completed with a Parent Form selected

Setting Parent Form scopes the hook to a single form, so it only runs for submissions of that form. This is the cleanest way to restrict a form hook, and it replaces the Template condition that earlier versions of this guide used to compare the form ID. If all you need is “only this form”, you can skip the condition below and go straight to Add Action.

  1. Save the Job

Upon save you will be redirected to the “Actions” page in the admin where conditions and actions can be configured. Actions can also be accessed via the List page.

For this example we need to configure the following:

  • “Add Action” - to send the email to the customer

  • “Add Condition” (optional) - only needed to filter on something other than which form was submitted

The final setup will look like below:

The job’s Actions page with a Condition containing a Send Email action

The example below still configures a condition, because conditions remain useful for filtering on anything other than which form was submitted — a particular field value, for instance. When a condition is used, it is configured first and the action is configured within it.

Add Condition (optional)

  1. Add description to the condition, this will also be displayed in the action area in the admin as per the previous screenshot

  2. Choose Condition Type = Template and add the following:

{$result->setMatching($event->getRecord()->form->id == 7)}

The above code snippet ensures the email notification is only sent to customers that complete the form that has id = 7.

You no longer need a condition just to restrict a hook to one form: set Parent Form on the Entity Event Trigger instead, as described above. A Template condition is still the right tool for any other kind of filtering.

Form ID can be retrieved from the Forms module. Hover over the ‘edit’ pencil and check the link at the bottom of the page:

The Forms list with the edit pencil hovered and the form’s link, ending in its id, shown in the browser status bar
  1. Click Save to save the condition

Add Action

Now navigate back to the actions and add a new action under the created condition. Actions can be accessed via the Orchestration > List page:

The Orchestration list with the job’s Actions count highlighted
  1. Add a new action by clicking on the “Add Action” link under the created condition

The Add Action link inside the condition on the Actions page
  1. Choose the “Send Email” action

The Add Action chooser with Send Email highlighted
  1. Configure the action:

    1. Add description

    2. Unique Identifier

    3. Set “Sender” - the name and address the email is sent from, for example Core dna <noreply@example.com>

    4. Set “Recipients” - one recipient per line, as Name <email>

    5. Set “Subject”

    6. Set “Template file” from your BitBucket Repository or use the below “Template code” area

In order to send the email directly to the customer who submitted the form, set “Recipients” to pull the customer’s name and email address from the submitted form:

Recipient built from the submitted form’s fields

{$event->getRecord()->data.firstname} {$event->getRecord()->data.lastname} <{$event->getRecord()->data.email}>

The Recipients field of the Send Email action filled from the submitted form

The last step is to add the email notification HTML & CSS code in the Template Code area. This will determine the structure & style of the sent email.

Please find an eBook HTML template that can be used as a starting point:

https://drive.google.com/file/d/1bzaOkOx3L9-XRbnI1gy9HlYLlXpIc6F7/view?usp=sharing

The autoresponder email as received: an eBook Download message with a Download button

The last step is to enable the Job with the Published switch in the main Orchestration > List area:

The Published switch of the job in the Orchestration list

All form submissions can be viewed in the Interactions > Forms > Form Submissions area in the admin, while all sent emails can be viewed in the Interactions > Mailer > Emails area in the admin.

Was this page helpful?

Your answer goes to the docs team.