Website Forms Routing

Quick links in this article:

In this article, we’ll cover how to setup a simple routing flow for website form submissions collected via your website. If you’ve not yet setup your website forms in Gnatta, start here: Website Forms

About website forms

Unlike other channels in Gnatta, a website form is by it’s nature not a customer conversation (yet!). It’s a form submission collected from your website, which means your website is the originator.

The goal is to turn that form submission into an email thread with the customer. Using Gnatta Workflow, you’ll be able to convert the data fields collected on your form and create a conversation with the customer as a recipient.

If you don’t convert the form into a conversation of it’s own, and create an interaction and assign it, then any messages will be sent to wherever the form submission came from (likely a website admin email address) - not the customer! Creating the conversation is how you tell Gnatta who the originator is.

This applies regardless of the method used to collect the form submission.

API Method

If you’ve used an HTTP request to collect your forms, you’ll need to setup your routing flow on an External HTTP Request event, and then use the data that’s been passed through to Gnatta to do the following:

  • Use a JavaScript action to extract the data from the HTTP request and log it into Gnatta data fields and context values

  • Create an interaction to store the conversation (only interactions can be assigned to agents)

  • Create an email conversation addressed to the customer, within that interaction

  • Add a message containing the form details into the conversation, in lieu of an ‘inbound email’ so the agent can read it before responding

  • Queue the interaction (according to your routing plan) ready for assignation to an agent

When the website form is then assigned to an agent, they’ll be able to see the form submission and reply to the customer via the email address left on the form.

If you’re using this method to collect forms, ensure you’re making a POST request to the relevant external HTTP endpoint, in JSON. More setup notes available here: Website Forms

image-20240919-100349.png
A simple routing flow creating and assigning interactions from form submissions

If you’re using this method, please see an example JavaScript function below.

// Grab Data var data = JSON.parse(context.GetObjectJson("Interaction.Data")); context.Log(JSON.stringify(data)); // Helper function to find an object by ID function findById(id) { return data.find(function (d) { return d.Type.Id === id; }); } // Extract values with null-checks var phoneNumber = findById("INSERT YOUR GNATTA DATA GUID"); phoneNumber = phoneNumber ? phoneNumber.Data.value : ''; var reason = findById("INSERT YOUR GNATTA DATA GUID"); reason = reason ? reason.Data.value : ''; var contacting = findById("INSERT YOUR GNATTA DATA GUID"); contacting = contacting ? contacting.Data.value : ''; var regarding = findById("INSERT YOUR GNATTA DATA GUID"); regarding = regarding ? regarding.Data.value : ''; // Log and set values in the context function logAndSet(varName, value) { context.Log(varName + ": " + value); context.Set("Var." + varName, value); } logAndSet("PhoneNumber", phoneNumber); logAndSet("Reason", reason); logAndSet("Contacting", contacting); logAndSet("Regarding", regarding);

Email Notifications Method

We’ll work through creating a routing workflow for this method, step-by-step, in the next section!

If you’re forwarding your form submissions into Gnatta via email, you’ll need to setup your routing flow on a New Message Received event mapped to the email address receiving the form notifications. Then your routing flow will need to do the following:

  • Use a Find Text action(s) to extract the form fields from the email message body and log them into Gnatta data fields

  • Create an interaction to store the conversation (only interactions can be assigned to agents)

  • Create an email conversation addressed to the customer, within that interaction

  • Add a message containing the form details into the conversation, in lieu of an ‘inbound email’ so the agent can read it before responding

  • Queue the interaction (according to your routing plan) ready for assignation to an agent

When the website form is then assigned to an agent, they’ll be able to see the form submission and reply to the customer via the email address left on the form.

Setup a routing flow

In the example scenario below, we’re going to use the email notifications method. That means we’re going to start by creating our routing flows on a New Message Received event for the email account receiving the notifications. In our example, email notifications will arrive in the following format:

Email: testing@gnatta.com Name: Testing Name Reason: Order issues Message: My order is faulty, please can you send me some return instructions

If the event hasn’t already been created, navigate to Settings > Workflow > Events > Add Event > New Message Received and select your email account to get started. You don’t need to attach any flows yet, as we haven’t created them!

create NMR.gif
Create a New Message Received event for the email account receiving form submissions

Once you’ve saved your new event, navigate to the builder and open a blank flow. Give it a name and description by clicking Untitled in the header bar (you can’t save a flow until it’s got a name).

Extract form fields

We’re going to start the flow by extracting the form data from the body of the email notification. To do that, we’ll need the Find Text action. This action uses RegEx to search for specific strings of text, and stores them in an Output you can select later in your flow. For example, this is a Regex that will search for an email address: \b\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*\b

In the Find Text action, you’ll need to:

  • Provide the RegEx for the string of text you’re searching for

  • Tell Gnatta where to look (i.e. the body of the email notification using Echo.Body)

  • Give the output an obvious name so you can find it later in your flow i.e. RegEx.Email

You’ll need to repeat this step for each of the form fields collected by your form. In our example, we’re going to search for:

  • An email address

  • The customer name

  • A reason for contact

  • The message summary

If you don’t know how to write RegEx, we’d suggest generating it using a tool like ChatGPT:

Create the interaction

After you’ve added all of your Find Text actions to extract and store your form fields, it’s time to create a new interaction in the right queue.

At this point, it’s best to create it in a Created state so it doesn’t reach an agent before we’ve finished setting up the interaction (we’ll set it to Queued at the end of the flow instead).

Whilst we’re creating the interaction, it’s a good opportunity to select the data group we want to display to operators when they receive the interaction and preset some of those data fields with the data we’ve extracted.

To preset a data field, select Preset Data on the Create Interaction action, and find the relevant field. Once you’ve selected it, click ‘Explore’ to open the contextual data panel. Your RegEx outputs should be available right at the top - select the relevant output to insert it into your field.

You don’t need to map the customer’s message into a field (unless you specifically want to!) - in the next few steps, we’re going to be pasting that directly into a message on the interaction, so it’ll present to the agent like any other inbound email.

Create a conversation

Now that you have an interaction, you can create a conversation within it - think of it like hitting ‘New Email’ in Outlook or Gmail. Set up your Create Conversation action like this:

  • Select Email as the channel, and the relevant media account

  • Set the subject line - we’ve used Thanks for getting in touch

  • The recipient should be the email address you extracted earlier: Regex.Email

When it’s ready, click submit.

You’ve now created the conversation, but it doesn’t yet contain any messages. If it was to be assigned to the agent like this, they’d see only an empty interaction (though the data group and fields would be set). So we’re going to now use the Add Message action to paste in a copy of the customer’s message to the email thread.

You can either use the Find Text output of Regex.Message (if you created it earlier), or you can paste in the entire body of the form submission notification using Echo.Body. Keep in mind that the agent will see this message, and when they respond to it, the customer will be able to see it in the threaded reply.

Send an autoresponse

Depending on your processes, you may also want to send a confirmation note to the customer to acknowledge receipt of their email whilst they wait for an agent to respond. If you’re doing that, you’ll need the Send Autoresponse action.

Queue the interaction

With all of your automation and configuration complete, it’s time to change the state of the interaction to Queued so it can reach an operator. It’s important this step is done last, or an interaction might reach an agent before the other steps are complete! This is done with the Set Queued State action - it’s all preset for you, no configuration needed.

Once done, you’re ready to save and publish your flow, then attach it to your event. Then it’s time to test, and make sure all is working as expected! Submit the form on your site, and then monitor Workflow logs to see what happens on your flow.

Â