Skip to content

Creating a new workflow

Matt Porritt edited this page Aug 4, 2018 · 8 revisions

Here's how you might create a simple workflow to send an HTTP request in response to a user logging in.

The intended audience for these instructions is a Moodle Administrator, with knowledge of Moodle's admin Interface and elements.

Manage Workflow Page

The following image shows the the Manage Workflow Moodle Administration page.

Manage Workflow Page

This page allows you to create a new Workflow, by clicking the Add new trigger workflow button

This page also shows summary information about the currently defined workflow, this summary information is:

  • Name: This is the name given to the workflow when it was created.
  • Description: This is the summary of what the summary does.
  • Event: This is the Moodle event that triggers the workflow.
  • Active: This shows the status of the workflow. Workflows can be active or inactive. Inactive workflows are not triggered when the associated Moodle event is fired.
  • Steps: This is the number of steps defined for a workflow. All workflows require at least one step.
  • Last triggered: This is the date and time the workflow was last processed. This is not the time when the associated Moodle event was triggered.
  • Manage: These icons allow you to: copy, delete or edit existing workflows.

Add / Edit a Workflow page

The following image shows the user interface for adding or editing a workflow.

Edit Workflow Page

The elements of this page are:

  • Name: This is the name given to the workflow when it was created.
  • Description: This is the summary of what the summary does.
  • Event to Monitor: This is the Moodle event that triggers the workflow.
  • Workflow active: Workflows can be active or inactive. Inactive workflows are not triggered when the associated Moodle event is fired. The default is active.
  • Add workflow step: This button allows you to add the required steps to the workflow. It opens a modal form window.
  • Save or Cancel buttons: Save or cancel the changes to the workflow.

Create a new workflow

The following steps will guide you on how to setup a workflow that posts data to a http endpoint.

Describe Workflow and choose event to monitor.

  1. As an admin, go to Site administration > plugins > Admin tools > Event Trigger

  2. Press "Add new trigger workflow"

Add new workflow

  1. Give the trigger a name/description to help you remember what it does.

  2. Search for an event to monitor and select it. This is a searchable list, if you enter the text "graded" you will see a list of related events.

Search event image

Manage workflow steps.

There are 3 types of steps:

  • Filter - Ability to check if the event meets certain conditions before processing it.
  • Lookup - Most core events only contain a small amount of information, this allows you to obtain extra information from Moodle to pass to the trigger/action. (for example a users email or the course fullname)
  • Trigger - this is an action such as an external HTTP post or email and should typically be the last step in your workflow.

Add an Http Post trigger

  1. Press "Add workflow step"
  2. Choose "Trigger" -> "Http Post"

Add workflow step

  1. Enter a name/description to help you remember what it does.
  2. Enter the url.
  3. Enter the http headers/parameters that should be used.

Datafields

When developing the action/ trigger workflow steps, you can include a range of variables contained from the event or from the lookups by using the format {fieldname} for example if you wanted to include user information in the http post parameters you would enter:

param1={user_email}&param2={user_firstname}

...and the users email and firstname would be passed to the external url with the names "param1" and "param2"