How to Auto-Approve Deputy Leave Requests with AI Policy Checks

Build a Spojit workflow that receives a Deputy leave request, checks it against your leave policy with Miraxa, auto-approves the straightforward cases, and routes the edge cases to a person for sign-off in Slack.

What This Integration Does

Approving leave by hand is slow and inconsistent: a manager has to remember how much balance someone has, whether the dates clash with a blackout period, and how many people are already off that week. This workflow does the routine reasoning for you. When a leave request comes in from Deputy, the intelligent layer evaluates it against the policy you describe and returns a clear decision. Requests that obviously fit the rules are approved straight away, and only the genuine judgment calls reach a human. Your team gets faster answers and your managers spend their time on the cases that actually need them.

The workflow is started by an incoming HTTP request: a Webhook trigger receives the leave-request event, verified by a Slack signing connection. From there the data flows through a Connector node in Agent mode that produces a structured decision, a Condition node that splits clear-cut cases from edge cases, a Human node that pauses for approval when needed, and a final Connector node that writes the outcome back to Deputy with create-leave. Each run handles one request and leaves the Deputy record in either an approved or a pending state; because the Webhook trigger supports opt-in deduplication, a replayed event will not double-process the same request.

Prerequisites

  • A Deputy connection (API key) added under Connections, with permission to read employees and create or update leave records.
  • A Slack connection for posting decisions and reaching approvers, plus a Slack signing connection if you verify the inbound webhook with Slack's scheme.
  • The source system (Deputy automation, an internal form, or a relay) configured to POST each new leave request to the workflow's webhook URL.
  • Your leave policy written out in plain language: balance rules, notice period, blackout dates, and the maximum number of staff allowed off at once.
  • The email addresses, roles, or teams of the managers who should handle escalated requests.

Step 1: Receive the request with a Webhook trigger

Add a Trigger node and set its type to Webhook. Spojit gives you a unique URL to POST to. Choose a signing connection (the Slack scheme works well if the request originates from a Slack-side automation, or use Custom/Spojit for an internal relay) so only verified callers can start a run. The trigger output is the parsed JSON body, available as {{ input }}. Configure the caller to send the fields you need, for example:

{
  "employeeId": "204",
  "employeeName": "Jordan Lee",
  "dateStart": "2026-07-14",
  "dateEnd": "2026-07-18",
  "leaveType": "Annual",
  "comment": "Family holiday"
}

Turn on event-id deduplication so a retried delivery does not create a second decision. The trigger returns 202 with an executionId to the caller immediately.

Step 2: Look up the employee's balance in Deputy

Add a Connector node in Direct mode, choose the Deputy connector, and select the get-employee tool. Map its ID input to {{ input.employeeId }}. This returns the employee record so the policy check has real data to reason over (such as leave balance and start date). Bind the result to a variable like employee. If you also want to know who else is off that week, add a second Direct-mode Deputy node using list-leave and keep its result as existingLeave for the agent to consider.

Step 3: Evaluate against policy with an Agent-mode Connector node

Add a Connector node and switch it to Agent mode. This is where the intelligent layer does the judgment. Write a prompt that states your policy and hands it the request and the data from Step 2:

You are evaluating a staff leave request against company policy.

Policy:
- Annual leave needs at least 14 days notice.
- The employee must have enough balance to cover the days requested.
- No more than 2 people in the same location may be off on any given day.
- Dates from 2026-12-20 to 2027-01-03 are a blackout period.

Request: {{ input }}
Employee record: {{ employee }}
Existing approved leave: {{ existingLeave }}

Decide whether this clearly meets every rule, clearly breaks a rule,
or needs human judgement.

Define a Response Schema so the node returns reliable structured JSON instead of prose. Use a shape such as:

{
  "decision": "approve | reject | escalate",
  "reason": "string",
  "confidence": "number"
}

Bind the result to review. You now have {{ review.decision }} and {{ review.reason }} to branch on. Agent mode uses AI credits; the Response Schema keeps the output predictable for the next step.

Step 4: Branch the clear cases from the edge cases

Add a Condition node that tests {{ review.decision }}. Send the value approve down the true branch straight to the write-back step (Step 6), and send escalate down a branch that goes to the Human node in Step 5. For reject you can route to a Send Email or a Slack send-message step that notifies the requester with {{ review.reason }} and stops there. Keeping the condition tied to the structured field (not free text) is what makes the routing dependable.

Step 5: Route edge cases to a Human approval

On the escalate branch, add a Human node so a manager makes the final call. Set a clear Message and a templated Notification title and body so approvers see context, for example a body of {{ input.employeeName }} requested {{ input.leaveType }} leave {{ input.dateStart }} to {{ input.dateEnd }}. Miraxa flagged: {{ review.reason }}. Add the managers as Approval slots (the only required field) using User, Role, or Team atoms, set a Timeout (minutes) if you want stale requests to lapse, and optionally enable Email approvers. Approvers respond in the Approvals inbox. When every slot approves, the node outputs { approved: true, outcome: "APPROVED" } and the run continues to Step 6; a rejection or timeout halts the workflow, so add a Slack send-message or Send Email step after a separate notify path if you want the requester informed of a stop. To alert the managers proactively, place a Slack Direct-mode node with send-message just before the Human node.

Step 6: Write the approval back to Deputy and notify Slack

On both the auto-approve branch and the post-Human-approval path, add a Connector node in Direct mode using the Deputy connector and the create-leave tool. Map its leave object input to the request details and set the status to approved, for example:

{
  "Employee": "{{ input.employeeId }}",
  "DateStart": "{{ input.dateStart }}",
  "DateEnd": "{{ input.dateEnd }}",
  "Status": 1,
  "ApprovalComment": "{{ review.reason }}"
}

Finish with a Slack Direct-mode node calling send-message to post the outcome to your team channel, for example Leave for {{ input.employeeName }} approved automatically: {{ review.reason }}. You can also add a Send Email node to confirm directly with the employee.

Tips

  • Keep the policy in the Agent-mode prompt short and rule-by-rule. Specific, numbered rules produce far more consistent decisions than a paragraph of prose.
  • Use the confidence field from the Response Schema as a safety valve: in the Condition node, escalate any decision below a threshold even if the agent said approve.
  • For policies that change often, store them in a Knowledge collection and query them with a Knowledge node, then feed the result into the prompt instead of hard-coding rules. See the policy-lookup pattern in the Learn More links.
  • Open Miraxa in the designer and describe the flow in a sentence to scaffold the nodes, then fine-tune each one in the properties panel.

Common Pitfalls

  • Skipping the Response Schema: without it the agent may return free text and the Condition node will not match cleanly. Always force structured JSON.
  • Forgetting that a rejected or timed-out Human node halts the run. Downstream "on reject do X" branching is not supported, so put requester notifications on a separate path or before the Human step.
  • Date and timezone mismatches: make sure the dates you pass to create-leave match the format Deputy expects and that notice-period math accounts for the requester's timezone.
  • Replayed webhook deliveries: enable event-id deduplication on the trigger, otherwise a retried POST can produce a second decision and a duplicate leave record.

Testing

Before turning the workflow on for everyone, test against one employee. Send a sample POST to the webhook URL with a request that clearly passes every rule and confirm it auto-approves and writes back to Deputy. Then send one that obviously breaks a rule and confirm it rejects without escalating. Finally send a borderline case (for example, leave just inside the notice window) and confirm it reaches the Approvals inbox, then approve it and check that the Deputy record updates and the Slack message posts. Watch each run in the execution history to verify the agent's decision and the branch it took.

Learn More

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.