Action Scripting

Using templates to create scripts that adjust content blocks within action fields including email subject, messages, tool tips and more

David Gravina avatar
Written by David Gravina
Updated over a week ago

Goodest Pro users have the ability to customise content within an action based on data passed through to the action from a button or link. Scripts allow you to create unique content in multiple locations within an action, including:

  • Action Description

  • Email Subject

  • Email Body

  • Email Tool Tips

We utilise Django Templates to create logic within the text body of these fields with a subset of variables being made available to the logic, either passed through via a previous action or a url parameter.

Things you can do:

  • Replace one word or an entire version of an email or text block, based on a variable passed to the Action using basic IF/THEN/ELSE logic.

  • Create loops to produce multiple text output based on a variable.

Practically speaking you can modify the message subject and/or body based on user input. This input can be provided in a few different ways including clicking on a button from a previous action and via links created by you.

In this example for the ACF (which also showcases our search and mapping features) the campaigners changed the text in the body of the email based on which event action (which are being used to show threatened species rather than actual events) the user selects and clicks on. If none is chosen (the user navigates directly to the Email action page) they use a generic block of text.

Almost 100 paddles were created in this example and the parameter request.from_event is used to pass the name of the event that was clicked (via the url parameter). This parameter is automatically added to the button on each event paddle.

To achieve the outcome there is one Email Politician action and many event paddles. The Map feature with search provides an easy way to navigate to a nearby hreatened species paddle –  and the script handles the rest.

An abridged version of the script is shown below to illustrate the method. This is added within the email message body …

As a constituent in your electorate I would like to bring your attention to Australia’s extinction crisis and the fact that nationally-threatened plants and animals can be found in {% if not request.place_name %}our cities and towns.
{% elif request.from_event = 'Adelaide' %}Adelaide.
{% elif request.from_event = 'CanberraQueanbeyan' %}Canberra and Queanbeyan.
{% elif request.from_event = 'Melbourne' %}Melbourne.
{% elif request.from_event = 'Brisbane' %}Brisbane.
{% elif request.from_event = 'Darwin' %}Darwin.
{% elif request.from_event = 'Hobart' %}Hobart.
{% elif request.from_event = 'Perth' %}Perth.
{% elif request.from_event = 'Sydney' %}Sydney.
{% endif %}
As my elected representative I ask that you take action to address this problem.
{% if not request.place_name %}{% elif request.from_event = 'Adelaide' %}
22 threatened species can be found in Adelaide, including the endangered Southern Brown Bandicoot. These medium-sized marsupials with long snouts are solitary animals that forage for food under leaf litter and dig distinctive cone-shaped holes in soil.
{% elif request.from_event = 'CanberraQueanbeyan' %}
24 threatened species can be found in Canberra and Queanbeyan, including the endangered Grassland Earless Dragon. As its name suggests, these small lizards are found in native grasslands and lack external ear openings.
{% elif request.from_event = 'Melbourne' %}
46 threatened species can be found in Melbourne, including the vulnerable Striped Legless Lizard. Without legs, this sleek little lizard can move with ease through its grassland environment, and can burrow quickly into soil.
{% elif request.from_event = 'Brisbane' %}
30 threatened species can be found in Brisbane, including the critically endangered Eastern Curlew. This large shorebird takes an annual migratory flight to Russia and north-eastern China to breed, arriving back in Australia in August to feed on crabs and molluscs in intertidal mudflats.
{% elif request.from_event = 'Darwin' %}
9 threatened species can be found in Darwin, including the vulnerable Flatback Turtle. Named after it’s flat shell (unlike the curved shell of other sea turtles), these endemic turtles breed and nest only in Australia.
{% elif request.from_event = 'Hobart' %}
29 threatened species can be found in Hobart, including the endangered Tasmanian Devil. The world’s largest marsupial carnivore is now restricted to Tasmania after disappearing from the Australian mainland approximately 400 years ago.
{% elif request.from_event = 'Perth' %}
35 threatened species can be found in Perth, including the critically endangered Western Swamp Tortoise. With limited numbers and habitat remaining, this carnivorous tortoise is the most endangered reptile in Australia.
{% elif request.from_event = 'Sydney' %}
80 threatened species can be found in Sydney, including the vulnerable koala. These iconic marsupials survive on a diet of eucalyptus leaves and can eat up to a kilogram a day.
{% endif %}

As a constituent in your electorate I ask that you:

- Speak up within your party for environment laws that actually protect nature, and an independent regulator to enforce them.

– Oppose attempts to rush changes to our laws before the EPBC review is complete.

By creating strong environment laws and funding the protection and restoration of urban habitat, we can create jobs, make our cities more liveable and help end extinction.

You can read more about how weak environment laws have let urban sprawl destroy the habitat of Australia’s threatened species, and what we can do to turn the extinction crisis around in ACF’s recent report, The extinction crisis in Australia’s cities and towns:

I look forward to hearing from you on this important matter,

In this simpler example you can see how we used the links (which we converted to buttons using CSS, see below for how to do that) within a Page to pass the same variable to an Email Decision Maker action tool. Each option triggers a different Action Description, Email Tip, Subject and Email body.

The options within the Page include this url, with each one changing the bolded text:

(For this example we set the first ‘Page' to be the first thing displayed on the Do Gooder microsite’s home page so that the links would be visible). Note that you can also turn these links into buttons

The template within each field is similar and structured like this:

Action Description:

This is a demo showing the scriptabilty of an email to the same people.
You chose {% if request.from_event = 'Option-1' %}Option 1{% elif request.from_event = 'Option-2' %}Option 2{% elif request.from_event = 'Option-3' %}Option 3{% elif request.from_event = 'Option-4' %}Option 4{% endif %}.

Email Message Body:

Email content customised for
{% if request.from_event = 'Option-1' %}Option 1
{% elif request.from_event = 'Option-2' %}Option 2
{% elif request.from_event = 'Option-3' %}Option 3
{% elif request.from_event = 'Option-4' %}Option 4
{% endif %}

We used the same format for the Subject and the Tool tips in that example.

Finally, to turn the links into buttons we added this CSS in the Custom Theme tab of the Campaign itself ..

.action-description .intro a:hover {

text-decoration: none;
background-color: #d25033;


.action-description .intro a {

background-color: #ff6d4c;
color: white;
padding: 10px 20px;
display: inline-block;
border-radius: 25px;


Other variables you can base your logic on or feed into your templates include:

  • Geo-data from address lookups, for eg: or request.country_long_name and so forth based on these:

{u'city': u'Melbourne', u'street_number': u'100', u'from_event': u'Melbourne', u'country': u'AU', u'street_name': u'Bourke Street', u'zoom': u'15', u'mlng': u'144.97004299999998', u'state_long_name': u'Victoria', u'mlat': u'-37.806897445095125', u'state': u'VIC', u'postal_code': u'3000', u'location': u'100 Bourke Street, Melbourne VIC, Australia', u'lng': u'144.9699956', u'county': u'Melbourne', u'lat': u'-37.8120241', u'country_long_name': u'Australia', u'formatted_address': u'100 Bourke St, Melbourne VIC 3000, Australia', u'vicinity': u'Melbourne', u'place_name': u'100 Bourke St'}

Did this answer your question?