Filter worker configuration

A Filter worker takes non-user generated input such as events, and triggers Botnet Actions.

Type: Filter Worker

To create a filter worker you need to create it from the CLI. A sample worker payload can be down here. Once you have created the worker using the CLI, it will return an ID for you.

You need to then update/create a bot and place the filter worker at the top with the id and the type of r2-filter-worker.

More on sending the page events can be found here.

Page Events

Page events allow the host page to send events to core. These events are un-trusted events and should be treated accordingly.

The page event object looks like this:

  • The alias is the name of the alias sent up in the pageEvent. You can have more than one alias with the same value.
  • The actions are valid botnetActions they can be found here. You can have more then one action per alias.
  • The match object is optional, if you use the match object the path is a valid jsonpath, testing can be done here. The value is the value of the item found

Worker example with page event

Worker payload with Page events


{
  "Name": "filterWorker",
  "Description": "Filter Worker",
  "Enabled": true,
  "Type": "r2-filter-worker",
  "Config": {
    "Avatar": "default-bot"
  },
  "Data": {
    "pageEvents": [
      {
        "alias": "hit-api",
        "actions": [
          {
            "type": "baas",
            "alias": "wellBaaas"
          },
          {
            "type": "baas",
            "alias": "wellBaaas1"
          }
        ]
      },
      {
        "alias" : "send-something",
        "match" :{
          "path": "$.user.name",
          "value": "botty"
        },
        "actions" : [
          {
            "type": "message",
            "value": "hello there, botty"
          }
        ]
      },
      {
        "alias": "send-something",
        "actions": [
          {
            "type": "message",
            "value": "hello there"
          }
        ]
      },
      {
        "alias": "trigger-flow",
        "actions": [
          {
            "type": "flow",
            "value": {
              "type": "r2-avalanche-worker",
              "deferRelease": true,
              "id": "d2ccd1dc-3c51-4ec1-be29-bf6588602b48"
            }
          }
        ]
      }
    ]
  }
}