Open Navigation

Mustache

Use the Mustache templating system

Overview

The Mustache connector can be used as a simple way of turning values returned by other connectors into variables that can be used in messages.

This can help you to work with your data in a more systematic manner.

Example - turning values into variables

The following workflow gives a very simplified example of this:

mustache-workflow

Here we have:

  1. Used the first Salesforce connector to List Opportunities (returning Account Id, Name, Owner Id and Amount for each)
  2. Used the Loop connector to process each opportunity one-by-one
  3. For each opportunity, Got Owner Name in Salesforce
  4. Used Mustache Template to create template variables using outputs from all of the above and set the message using these variables
  5. Sent the formatted message to a Slack channel

From the screenshot above you can see that we have created a list of Parameters for the Mustache Template step, by clicking the Add Property to Parameters button:

In the Template code box we have then been able to create a message which includes the parameter variables enclosed in { }:

mustache-template-code

The debug output for one opportunity in the loop would then show:

mustache-debug

And there would be a series of messages sent to the Slack channel which you have set in the final step:

mustache-slack

Example 2 - using Mustache templates in config data

You could also use mustache template variables in your config data messages.

For example you could set a standard 'new opportunity' message in Configurable data in your workflow settings:

config-data-1

This message can use { } to use a mustache variable:

config-data-2

Then for any Mustache step in your workflow you can set the parameter and make the Template Code pick up the config message for a new opportunity:

mustache-ex2-step

The debug output will then show that the config data 'new opportunity' message and Mustache parameter have combined to correctly format the message:

mustache-ex2-debug

Was this article helpful?
Yes
No