Work Market Developer Portal

WorkMarket Developer Portal

We are building the modern work market,
a frictionless exchange between businesses and workers.
See API Docs

    

Relay Rules Engine

The heart and soul of the Relay system itself is indeed the Rules engine that delivers on the classic process of "if/then" logic. Most of the activities that you would want to create through the Relay such as the Sequence or Schedule features would require some analysis to see if that process completed successfully and if not, perform some different operation. The Work Market Relay's Rule Engine feature provides you the ability to leverage the full power of the platform, whether you're using it to integrate with your own platform or drive productivity within Work Market itself.

Contact Us

Feel free to reach out to Work Market's Solutions Engineering team at solutions@workmarket.com. Someone from the team will contact you within 48 hours.

Basic Anatomy of a Rule

As described above, rules can be most simply described as "if/then" cases that should determine a decision to proceed. An example would be "if it's raining in a region, then reschedule all assignments within that area." Another example could be a routing rule that says if no one accepts an assignment within a period of time, then change the parameters of the assignment (for example the radius for possible resources). Then check again after a period of time and continue the scope until you've tried your widest range acceptable and still if no one accepts, then alert the manager.

Here is an example of a Webhook that would call the relay for such a rule:

On Create:
POST https://relay.assignmentportal.com/co/<id>/relay
Content-Type: application/json

[{
    "action": "wm_sendAssignment",
    "relayId": "139",
    "relayAccessToken": "o4y----------sZR",
    "wmAssignmentId": "${assignment_id}",
    "sendToGroups": "${custom_field_55717}",
    "sendRadius": "15",
    "comment": "Send to group w/ 15 mile radius immediately"
}, {
    "action": "wm_sendAssignment",
    "relayId": "140",
    "relayAccessToken": "iu4----------6ut",
    "delayInSeconds": "120",
    "wmAssignmentId": "${assignment_id}",
    "sendToGroups": "${custom_field_55717},12345",
    "sendRadius": "45",
    "comment": "After 2 minutes, send to same group + group 12345 w/ 45 mile radius"
}, {
    "action": "wm_sendAssignment",
    "relayId": "141",
    "relayAccessToken": "IYh----------hhr",
    "delayInSeconds": "240",
    "wmAssignmentId": "${assignment_id}",
    "sendToGroups": "${custom_field_55717},12345,78910",
    "sendRadius": "90",
    "comment": "After 4 minutes (from webhook event), send to 3 groups w/ 90 mile radius"
},{
    "action": "sendEmails",
    "actionCondition": "status==draft",
    "delayInSeconds": "300",
    "relayId": "194",
    "relayAccessToken": "jpv----------jIw",
    "emails": ["youralertaddress@yourdomain.com", ${owner_email}],
    "subject": "Assignment ${assignment_id} still in 'draft' status after sending to all groups with 90-mile radius",
    "body": "https://www.workmarket.com/assignments/details/${assignment_id}",
    "bodyHtml": "<a href='https://www.workmarket.com/assignments/details/${assignment_id}'>https://www.workmarket.com/assignments/details/${assignment_id}</a>",
    "wmAssignmentId": "${assignment_id}",
    "comment":"After 5 minutes, if there were no valid recipients (assignment still in 'draft' status), send email alerts"
}]