•••
 
Documentation   /   For AI builders   /   AI worked example: employee onboarding
 
 

AI worked example: employee onboarding

 

This example shows a complete solution, written the way the AI builders guide describes. Use it as a pattern.

The request

"When we hire someone, HR enters the candidate's details. Salaries over £60,000 need director approval. Then send an offer letter for the candidate to sign, tell IT to set up a laptop, and email the candidate a welcome message. I want a dashboard of hires by status."

The flow

 [salary_check] hidden: over £60,000?
      | no                         | yes
      v                            v
 [make_offer]              [director_approval] question
      |                     | Approve           | Reject
      |                     v                   v
      |              [make_offer_approved]   [rejected] kill
      |                     |
      +--------+------------+
               v
        [offer_gate] Blocker
               v
   [it_laptop]  [welcome_email]  [check_signed]

Both offer items share the alias offer, so later steps can use {{offer}} whichever branch ran.

1. Template: offer letter (Signable)

Template text

<p>{{a_date}}</p>
<p>Dear {{a_counterparty_name}},</p>
<p>We are delighted to offer you the position of {{job_title}} at {{c_entity}}.</p>
<p>Your annual salary will be [[MATH=currency:£,decimals:0]]{{salary}}[[ENDMATH]]. Your employment will begin on {{a_date_start}}.</p>
[[IF=salary(GREATER_THAN £60000)]]
<p>This offer has been approved by a director.</p>
[[ENDIF]]
<p>Please sign below to accept this offer.</p>
[[SIGNATURE_BLOCK]]

Template fields (Variables panel)

--#:
---name:job_title
---type:text
---appears_on:extras
---mini_label:Job title
---required:true

--#:
---name:salary
---type:amount
---appears_on:extras
---mini_label:Annual salary
---string_format:currency
---required:true

Signature blocks

--#:
---id:company_sig
---type:auto
---party:{{c_entity}}

--#:
---id:candidate_sig
---type:manual
---party:{{a_counterparty_name}}
---name:
---email:

2. Workflow: launch form (Settings → Extra fields)

--#:
---name:candidate_name
---type:text
---appears_on:settings
---mini_label:Candidate's full name
---required:true

--#:
---name:candidate_email
---type:text
---appears_on:settings
---mini_label:Candidate's email
---string_format:email
---required:true

--#:
---name:job_title
---type:text
---appears_on:settings
---mini_label:Job title
---required:true

--#:
---name:salary
---type:amount
---appears_on:settings
---mini_label:Annual salary
---string_format:currency
---required:true

--#:
---name:start_date
---type:date
---appears_on:settings
---mini_label:Start date
---required:true

3. Workflow code (Code tab)

Use this workflow for every new hire.

[[CHECKLIST]]

--#item:
---id:salary_check
---action:hidden
---answer:[[IF=salary(GREATER_THAN £60000)]]director[[ELSE]]standard[[ENDIF]]
---done_at:1
---filter1|filter:answer EQUALS standard
---filter1|outcome:make_offer
---filter2|filter:answer EQUALS director
---filter2|outcome:director_approval

--#item:
---depends_on:salary_check
---id:director_approval
---task_stage:Approval
---title:Approve a salary of {{salary}} for {{candidate_name}}
---description:This salary is over £60,000, so a director must approve it.
---action:question
---options:Do you approve this salary?
---answer1|text:Approve
---answer2|text:Reject
---clearance_level:senior
---filter1|filter:answer EQUALS Approve
---filter1|outcome:make_offer_approved
---filter2|filter:answer EQUALS Reject
---filter2|outcome:rejected

--#item:
---depends_on:director_approval
---id:rejected
---title:Offer not approved
---description:The director didn't approve this salary. Start a new task with a revised salary if needed.
---action:kill
---options:Salary not approved
---block:true

--#item:
---depends_on:salary_check
---id:make_offer
---alias:offer
---task_stage:Offer
---title:Offer letter sent to {{candidate_name}}
---action:auto_document
---options:{offer_letter_template_key}
---stage:send
---pass_variables:counterparty_IS_{{candidate_name}}_AND_date_start_IS_{{start_date}}_AND_job_title_IS_{{job_title}}_AND_salary_IS_{{salary}}_AND_candidate_sig:name_IS_{{candidate_name}}_AND_candidate_sig:email_IS_{{candidate_email}}

--#item:
---depends_on:director_approval
---id:make_offer_approved
---alias:offer
---task_stage:Offer
---title:Offer letter sent to {{candidate_name}}
---action:auto_document
---options:{offer_letter_template_key}
---stage:send
---pass_variables:counterparty_IS_{{candidate_name}}_AND_date_start_IS_{{start_date}}_AND_job_title_IS_{{job_title}}_AND_salary_IS_{{salary}}_AND_candidate_sig:name_IS_{{candidate_name}}_AND_candidate_sig:email_IS_{{candidate_email}}

--#item:
---id:offer_gate
---title:Waiting for the offer to be sent
---action:stop
---options:done_at
---block:true

--#item:
---id:it_laptop
---task_stage:Onboarding
---title:Set up a laptop for {{candidate_name}}
---description:Starts on [[DATE=D MMMM YYYY]]{{start_date}}[[ENDDATE]] as {{job_title}}.
---action:done
---clearance_level:{it_email}

--#item:
---id:welcome_email
---action:auto_email
---to:{{candidate_email}}
---subject:Welcome to {{c_name}}
---body:Dear {{candidate_name}},~~~~~~We've sent your offer letter for the role of {{job_title}}. Please sign it using the link in the separate email.~~~~~~We look forward to welcoming you on [[DATE=D MMMM YYYY]]{{start_date}}[[ENDDATE]].

--#item:
---id:check_signed
---task_stage:Onboarding
---title:Check the offer has been signed
---description:[[LINK={{document_url_base}}{{offer}}]]Open the offer letter[[ENDLINK]]
---action:done

Why it's built this way

  • salary_check is a Hidden item with no ---depends_on, so it runs at the start. Its two filters don't overlap and cover every case.
  • Both branches need an offer letter, but an item can only depend on one item. So there are two offer items, one per branch, with a shared alias.
  • The Blocker offer_gate brings the branches back together. The items after it have no ---depends_on and appear once everything before the Blocker is done.
  • job_title is in both the launch form and the template fields, so the template also works on its own. The workflow passes it in.
  • The rejected branch ends with a Kill.

4. Dashboard

  1. In Data Studio, create a task dataset from this workflow with the columns Task, Status, Stage and Started. Generate its shareable link.
  2. Open the feed with view=1 to see the exact column names it uses.
  3. Create a Web page template:
[[INCLUDE=data(prefix:hires_):https://plainly.com/report-json?h={hires_dataset_id}&key={hires_dataset_key}]]
<h2>Hires by status</h2>
[[INCLUDE=widget(type:summary_table,columns:hires_{status_column}|hires_{status_column},column_headings:Status|Hires,show:count)]]
<h2>All hires</h2>
[[INCLUDE=widget(type:table,columns:hires_{task_column}|hires_{status_column}|hires_{stage_column},column_headings:Candidate|Status|Stage)]]
  1. Create a document from it, and add its URL as a dashboard.

5. Placeholders to replace

Placeholder Replace with
{offer_letter_template_key} The offer letter template's key
{it_email} The IT team's email address
{hires_dataset_id}, {hires_dataset_key} From the dataset's shareable link
{status_column}, {task_column}, {stage_column} The column names shown in the feed

6. Test plan

  1. Start a task with a salary of £45,000. Check the offer is sent with no approval step, and that IT and the welcome email follow.
  2. Start a task with £75,000 and approve it. Check the approval step appears only for seniors, and that the offer follows.
  3. Start a task with £75,000 and reject it. Check the task is killed and nothing else happens.
  4. Sign one offer as the candidate and check the dashboard shows the tasks.