Send Mautic Form to different Recipients based on Formfield

Hello,

I am using Mautic now for about 1 year and just ran in a Challenge.

I’ve a Mautic form with Radiobuttons where the User can select which Department he want to connect with.

o General Question (1)
o Sales (2)
o Technical Support (3)
and so on

I want to send the Request to the Person in Charge. So for example:

1: info@company.org
2: sales@company.org
3: support@company.org

I’ve tried different approaches, but non worked. For example I’ve tried campaigns, but couldn’t find a way to use Formfields in the Campaign E-Mails.

I cannot accept that this couldn’t be possible in a easy way. This Form gonna replace a Powermail Form in TYPO3 and there it kind of works like a charm. Is there a way to do this out of the box or with a workaround?

Any help is very appriciated.

Thanks!

Great question. hopefully someone really creative has a good answer as i’m curious how to do this now!

A really dirty workaround is to define the the Radiobuttons as E-Mail and then tell the Action to send the Mail to the “Contact” - but then of course you don’t have the customer E-Mail. But the workaround shows how desperate I am. :smiley:

I would create custom fields to save that “person in charge” email address, along with custom fields for all the fields that you’d like to include in the notification email, so they can be saved to the contact record.

Set the form to update those fields, and then use a campaign to send the email notification; in the campaign, use the “send email to user” action and, in the To field, write `{contactfield=person_in_charge}’ (or whatever ID that field has).

You can create your form as a campaign form and use it to trigger the campaign directly, or create it as a standalone form and have it add them to a segment that triggers the campaign (if you use the latter option, make sure to add a step to the campaign that removes the contact from the segment, so if they submit a second enquiry the campaign will be repeated).

Make sure the campaign is set to allow contacts to restart it.

I considered this, but this really the only way?

The Problem with this is, that using a campaign would be kind of complex. In my case I’ve a installation with 5 country pages and a total of 9 translations. The Radiobuttons are always different, so every page and every country site has it’s own contact form with arround 5-9 options (e-mails) to choose from.

And I’m only talking about the contact forms, there also others forms.

So this would blow up the overhead to a limit the customer would never ever pay for and I totaly get that, cause it’s such a simple task.

Is there no other way? Or would it be an option to create like a plugin which does the job? Would it be possible to like change the “submit action” “send form results” and make an extension / plugin out of it?

Thanks!

Ah, I see. This could get quite complex!

An alternative just sprung to mind (I haven’t been able to test it), but have you tried on the form setting the department radio button values as those email addresses (you could still set the labels to “General question”, " Sales",etc, so it wouldn’t look different for your users). In the form actions, add a “send form results” action and, in the To field, reference the department field (eg {form field=which_department} - you’ll find the exact string to use is already in the body of the email).

Like I say, I haven’t tested this, but it might work!

Thank’s for following up, very appriciated!

I’ve tried to set the values of the Radiobuttons to E-Mail Adresses of the appartments. So for example:

(info@company.com) General Question
(sales@company.com) Sales
(support@company.com) Support
and so on. And then I’ve set the Radiobutton to E-Mail.

Not sure if you ment it this way. This works like a charm, but in practice, I loose the customer (Lead) E-Mail, because the Radiobutton result is saved to the Leads E-Mailfield.

That’s why I was thinking about a Plugin to solve this by adding additional Features to the Formaction “Send Form Results” - in case this is possible in Mautic.

Cheers,
Lufi

Hi,
I’m really @lufi asked this scenario, because shows how flexible Mautic can be.
In my opinion you should take advantage of the “contact ownership” concept built into Mautic.

1. Create multiple users in Mautic
One for each role you’d like to have: info, sales, support.

2. Assign owner
Once a person fills out the form, you can assign contact owner as a campaign step based on the radio button choosen.

3. Send email to user
From this moment you are able to send email to a specific Mautic user as campaign step:

image

Make sure you are turning on the switched called “send to contact owner”

4. Contact ownership is everywhere
Contact ownership can used in conditions, you can change via campaign steps. You can send email to user via Forms

5. Set identity in emails
Sender identity can be set as “send from owner” on any email using the advanced tab!

+1: Contact ownership can be used in tokens
WHAT? Mautic can do this? Sure it can :smiley:
In many areas of Mautic contact owner’s data can be used as tokens:

I think this can be a good video tutorial one day.
Let me know how this works out for you.
Joey

1 Like

Hello Joe,

thank’s alot for this very complete description. I like this approache because it seems to be very complete and logic.

But then again, how to access the formdata when sending the E-Mail within the campaign?

Cheers,
Lufi

You can tie the form data to a field, and use regular tokens. {contactfield=issuereported}.
Would that work?

Hello Joey,

You mean like creating a custom field for each formfield on the Website?

Cheers,
Lufi

No, just for the data you want to save and use later.
If it’s the same field between forms, then you can just save one. In case it’s okay to overwrite it.
J

Thanks for the workaround.

I really love Mautic and its extensiveness. It’s just a great and powerful tool.
But at this point it totally misses the market. For me it just feels so wrong and like a big error by design, when you have to create fake fields to handle formfields for such a simple task.
Not talking about the problem when the user overwrite his records before the data being send.

As mentioned this is so easy to do in TYPO3 with Powermail and so I was thinking about creating a plugin, but the documentation on this is really bad.

So here is my solution, as I was looking for simple solution for me as well as the customer.
Solution is tested and worked like a charm for me. Here’s what you can do, for everyone also looking something like this:

  1. Create 1 custom field and label it “Owner (form)” - set Type to Text
  2. Create 2 MySQL Trigger as follows (just copy the code 1:1, should work out of the box):
DELIMITER ;;
CREATE TRIGGER `set_lead_owner_from_radiobutton_on_insert` BEFORE INSERT ON `leads` FOR EACH ROW
IF (NEW.owner_form != NULL) THEN
  IF (SELECT count(id) FROM users WHERE users.id=NEW.owner_form) > 0 THEN
    SET NEW.owner_id = NEW.owner_form;
  ELSE
    SET NEW.owner_id = NULL;
  END IF;
END IF;;
DELIMITER ;

DELIMITER ;;
CREATE TRIGGER `set_lead_owner_from_radiobutton_on_update` BEFORE UPDATE ON `leads` FOR EACH ROW
IF (NEW.owner_form != NULL) THEN
  IF (SELECT count(id) FROM users WHERE users.id=NEW.owner_form) > 0 THEN
    SET NEW.owner_id = NEW.owner_form;
  ELSE
    SET NEW.owner_id = NULL;
  END IF;
END IF;;
DELIMITER ;
  1. Create a form with a Radiobutton or Selectbox and set the “Contact Field” to our custom field “Owner (Form)”
    Note: Values of the Radiobuttons / Selectboxes need to be set to the User IDs of your Mautic Instance. So you have to create an user for every Select- oder Radiobutton-Option.
  2. Select for example “Send form results” in Actions and set “Send to owner” to yes.

That’s it.

So what does it do. It’s basically all about the MySQL Triggers. Every time a new Lead is created or updated and our custom field “Owner (form)” is not null and has a valid entry (User ID), the trigger copies the value from our field to the original Owner Field of the lead. So we can then use Owner of the Lead (in my case a Department) to send him a E-Mail.

I hope this is helpfull to someone. But even more I hope that Mautic is gonna fix this in the future, as I believe this a very essential task when it come to enterprise Websites.

Cheers,
Lufi :slight_smile:

Hi there!

Sorry that you found the documentation bad - we are actually in the process of improving and migrating our developer docs, so please take a look at the WIP docs here: Getting started with Plugins — Mautic Developer Documentation 3.0.0 documentation which are much improved!

1 Like

Hi @lufi
I think this is a super-interesting use case and I think there could be a possibility to make it work.

To sum up the use case (apprx.)
We need to create a form, where one field (department) should determine where the form action email is sent. This is not possible right now. We can access the freshly filled out form data as {formfield=message} and send as Form Action. But the Form Action that sends the email can have either a fixed recipient or the contact owner.

We could save all the form data in custom fields, make it a Campaign form, where we relay the email based on a condition (If contactfield department = eCommerce, owner = John). But this is cumbersome, slow and why would we need to save the data once it’s in the formfield.

The solution could be the possibility to save owner information in the form itself. @volha is working on n amazingly useful enhancement [WIP] Add the stage and owner fields to the contact fields list by volha-pivavarchyk · Pull Request #11248 · mautic/mautic · GitHub, where owner field could be designated to fields. This would allow to automatically add an owner in a hidden field (or not hidden whatever). Change owner is not available as form action at the momment.

But if we display the data differently, we could reach the routing functionality:

The form could be like this:

Let’s pretend the icecream flavor is connected to the owner. If we can map it the following way:

image

Then the ownership is designated based on choice and a Form action can send the communication to the right person + set ownership.
Instead of email, we can even have a dropdown that chooses the right owner.

2 Likes

I had basically the same use case and ended up using Zapier to send the email because in our case we couldn’t change the owner.

another option would be to be able to use a token/variable in the campaign action to send the email. In our case, the email address we want to send an alert to is a field on the contact record. Being able to set the “Send email to user” value to {contactfield=rep_email_address} would meet our needs.