Creating an action

An action represents what you want to occur as a result of the WebSphere Automation event, such as sending an email or invoking a webhook. You can create an action by using a curl command or by using the Swagger UI for the WebSphere Automation REST API.

About this task

You must have access to the WebSphere Automation REST API, and you must authenticate with Red Hat OpenShift Container Platform administrator credentials by clicking Authorize on the Swagger UI page.

Creating an action in WebSphere Automation

Use the Swagger user interface for the WebSphere Automation REST APIs to create a new action. The action resource is part of the Self-Secure APIs that is available in the Swagger UI at https://<cpd-route>/websphereauto/secvul/apis/openapi/ui/. For more information on finding the value of your <cpd-route>, see Viewing the REST API.

On the Swagger UI page for Self-Secure APIs, do the following steps to create an action.

  1. Click Post /actions.

    The section expands to show the Parameters tab, an example request body and schema, and responses.

  2. Click Schema to view the action schema.

    Make sure that you are familiar with the schema and the acceptable values for each parameter.

  3. Click Try it out.

    The request body area can now be edited.

  4. Modify the request body by changing the values in quotation marks after the colon.

    For more information, see Action resource. To create a specific type of action, see Creating an email action or Creating a webhook action.

  5. Click Execute.
  6. Examine the response code.

    If your action is valid, the response code is 201 for a successful operation. Your action is ready to be associated with a trigger.

Passing variables from the trigger

You can pass variables to an action from the trigger by using Mustache syntax. The WebSphere Automation action resource can have up to 32 unique variables. For more information, see http://mustache.github.io/mustache.5.html.

The WebSphere Automation action resource supports the following Mustache features:

  • Variables
    {{myVariable}}
  • Sections
    {{#mySection}}
      Hello {{name}}
    {{/mySection}}
  • Inverted sections
    {{^myInvertedSection}}
      No name specified!
    {{/myInvertedSection}}
  • Comments
    {{! A comment}}

The WebSphere Automation action resource does not support the following Mustache features:

  • Partials
    {{> myPartial}}
  • Lambdas
  • Delimiters
    {{=<% %>=}}
      <% erb_style_tags %>
    <%={{ }}=%>

Testing the action

You can test the action manually using the patch operation in the Swagger UI.

On the Swagger UI page for Self-Secure APIs, do the following steps to test an action.

  1. Click Patch /actions/{actionId}.

    The section expands to show the Parameters tab, an example request body and schema, and responses.

  2. Click Try it out.

    The request body area can now be edited.

  3. Paste the actionId of the action into the actionId field.
  4. Copy and paste the JSON snippet for your action into the request body area.
  5. Click Execute.
  6. Examine the response code.

    If your action is valid, the response code is 200 for a successful operation.

  7. Examine the target for the action to see if it completed successfully. For example, if the action was to send an email, confirm that the email is received by an email address that you specified.

What to do next

To invoke an action, you must create a trigger.