Event actions are powerful. They allow you to invoke other tasks as a response to an incoming event. And, because a single task can subscribe to multiple event topics, it means you can create multi-phase tasks that are executed over time.

For developers

Options

  • "method"  – required, must be one of "post" , "put" , "patch" , "delete" 
  • "url"   – required, must be a string starting with http:// or https:// 
  • "headers"  – optional, may be a JSON object of header names and values
  • "body"   – required, may be a string to represent a plain request body, or may be a JSON object to be automatically serialized to JSON

Note: Mechanic will only automatically serialize to JSON if the Content-Type  header is either blank or set to application/json .

Example

This task sends the merchant's input to a third-party API that simply echoes it back. Great for testing. ;)

Subscriptions:

mechanic/user/text

Script:

{
  "action": {
    "type": "http",
    "options": {
      "method": "post",
      "url": "https://postman-echo.com/post",
      "body": {{ event.data | json }}
    }
  }
}
Did this answer your question?