Actions - smbc-digital/form-builder GitHub Wiki

Actions allow you to specify actions which are performed on a page or form bases. Page actions can be run on either the POST or GET action and on form action they are ran on successful submission of the form(POST)

These are configured within FormActions, if to be executed on successful submission or within PageActions if for a page

{
  "FormName": "Form actions",
  "FormActions": [],
   "Pages": [
    {
      "PageSlug": "page-one",
      "PageActions": []
    }]
}

Retrieve External Data

Retrieve external data action type allows you to perform a request to an endpoint to retrieve some additional data. The data returned is stored within the formanswers in the key specified in TargetQuestionId. It allows you to use the data within behaviours.

If you require the external data to also be added in the form submission, you can set a flag on the properties ( see below ) to allow this functionality. With the "IncludeInFormSubmission": true property. False by default.

Query strings can be specified within the URL and will be replaced at execution with the matching answer value, this can be done by specifying the questionId surrounded by '{' within the url

{{questionId}}

DSL properties

Property Type Required Default Value Description
Type enum ✔️ actions type
PageActionSlugs List ✔️ One object per env containing URL, AuthToken, and Env name
URL string ✔️ Url used to retrieve data from
Env string ✔️ Environment name
AuthToken string Authtoken
TargetQuestionId string ✔️ QuestionId the data will be mapped to
IncludeInFormSubmission bool false Include this data in the form submission
HttpActionType enum ✔️ Unknown When the action is to be perform on GET or POST

Example

"PageActions": [
        {
          "Type": "RetrieveExternalData",
          "Properties": {
            "TargetQuestionId": "mapPost",
            "HttpActionType": "Post",
            "PageActionSlugs": [
              {
                "Environment": "local",
                "URL": "https://localhost:44359/api/v1/Home",
                "AuthToken": "authtoken"
              }
            ]
          }
        },
        {
          "Type": "RetrieveExternalData",
          "Properties": {
            "TargetQuestionId": "mapGet",
            "IncludeInFormSubmission": true,
            "HttpActionType": "Get",
            "PageActionSlugs": [
              {
                "Environment": "local",
                "URL": "https://localhost:44359/api/v1/Home/{{firstQuestion}}",
                "AuthToken": "authtoken"
              }
            ]
          }
        }
      ]

Email

Email action type allows you to configured a basic email which can be sent to a specified email address

To use an email address entered from a page, you can specify the questionId required and on execution of action the value collected will be used, this can be achieved by specifying the questiondID surrounded by {{

{{questionId}}

DSL properties

Property Type Required Default Value Description
Type enum ✔️ actions type
To string ✔️ email address is being sent to
From string ✔️ email address to be sent from
Content string ✔️ email content
Subject string ✔️ email subject
HttpActionType enum ✔️ Unknown When the action is to be perform on GET or POST

Example

"PageActions": [
  {
    "Type": "UserEmail",
    "Properties": {
      "To": "[email protected], {{primaryEmailAddress}}, {{secondaryEmailAddress}}",
      "From": "[email protected]",
      "Content": "<h1>Thank you for contacting us</h1>",
      "Subject": "Email subject",
      "HttpActionType": "Post"
    }
  }
]

Validate

Validate action type allows you to perform a request to an endpoint to valid a case reference.

Query strings can be specified within the URL and will be replaced at execution with the matching answer value, this can be done by specifying the caseReference surrounded by '{' within the URL

{{caseReference }}

DSL properties

Property Type Required Default Value Description
Type enum ✔️ actions type
PageActionSlugs List ✔️ One object per env containing URL, AuthToken, and Env name
URL string ✔️ Url used to retrieve data from
Env string ✔️ Environment name
AuthToken string ✔️ Authtoken
HttpActionType enum ✔️ Unknown When the action is to be perform on GET or POST

Example

"PageActions": [
        {
          "Type": "Validate",
          "Properties": {
            "HttpActionType": "Get",
            "PageActionSlugs": [
              {
                "Environment": "local",
                "URL": "https://localhost:44359/api/v1/Home/validtrue?caseReference={{caseReference}}",
                "AuthToken": "authToken"
              }
            ]
          }
        }
      ]

Templated Email

'Templated Email' action type allows you to send a specified email address based on Notify email template.

To use an email address entered from a page, you can specify the questiondID surrounded by {{ questiondID }}. See json for example

To add case reference to Notify email template, you can specify the parameter name on Notify as reference and set json field to true for 'IncludeCaseReference'. See json for example

*NOTE: When mapping question id to personalisation field, these specific data types need to append prefixes for it to work. Date ('-day', '-month', '-year'), time ('-hours', '-minutes', '-ampm'), and address ('-address', '-address-description', '-postcode'). See json for example

DSL properties

Property Type Required Default Value Description
Type enum ✔️ actions type
To string ✔️ email address is being sent to
TemplateId string ✔️ Notify Template Id
EmailTemplateProvider string ✔️ Only one provider allow per a form: Notify or Fake
Personalisation string Add question id to map to notify parameters for email template
IncludeCaseReference bool To include case reference Id

Example

  "FormActions": [
    {
      "Type": "TemplatedEmail",
      "Properties": {
        "EmailTemplateProvider": "Notify",
        "To": "{{email}}",
        "TemplateId": "00000000-0000-0000-0000-0000000000",
        "IncludeCaseReference": true,
        "Personlisation": [
          "firstName",
          "lastName",
          "dobone-day",
          "dobone-month",
          "dobone-year",
          "timeoptional-hours",
          "timeoptional-minutes",
          "timeoptional-ampm",
          "email",
          "phoneNumber",
          "address-address",
          "address-address-description",
          "address-postcode"
        ]
      }
    }
  ],
⚠️ **GitHub.com Fallback** ⚠️