Agentic HR Employee Q&A

An HR-assistant agent that combines the employee's specific row (country, tenure, role band) with the right policy doc to answer correctly — not a generic RAG-only bot that hallucinates country-specific rules.

All recipes· agents· 12 minutesintermediateen
Instance: localhost:8080

Opens your running SynapCores (Agentic HR Employee Q&A will be staged for a preview — nothing runs until you click Run). No instance yet? Install free in ~30s.

Share

Objective

HR answers the same 50 questions a week (PTO, parental leave, expenses), and country/role-specific rules differ. Generic RAG bots get the answer wrong because they don't see the employee's row. This recipe wires an HR-assistant that reads who's asking (country, tenure, role band) and combines it with the right policy doc.

Step 1: Create employees + policy docs

CREATE TABLE IF NOT EXISTS recipe_hr_employees (
  employee_id   INTEGER PRIMARY KEY,
  email         TEXT,
  country       TEXT,
  hire_date     DATE,
  role_band     TEXT,            -- 'IC1' .. 'IC6' / 'M1' .. 'M5'
  status        TEXT             -- 'active' | 'leave' | 'terminated'
);

CREATE TABLE IF NOT EXISTS recipe_hr_policies (
  policy_id   INTEGER PRIMARY KEY,
  title       TEXT,
  scope       TEXT,              -- 'global' or 'country:XX' or 'role:IC' etc.
  body        TEXT,
  embedding   VECTOR(384)
);

Step 2: Seed

INSERT INTO recipe_hr_employees VALUES
 (1001,'alice@yourco.com','US','2023-06-15','IC4','active'),
 (1002,'bob@yourco.com',  'UK','2024-11-02','IC3','active'),
 (1003,'carol@yourco.com','DE','2022-03-20','M2','active'),
 (1004,'dan@yourco.com',  'US','2025-09-08','IC2','active');

INSERT INTO recipe_hr_policies (policy_id, title, scope, body) VALUES
 (1,'Parental Leave — US','country:US',     'US-based employees receive 12 weeks of paid parental leave at full salary, available within 12 months of the qualifying event. Eligibility requires 6 months of tenure at time of leave.'),
 (2,'Parental Leave — UK','country:UK',     'UK-based employees receive statutory maternity/paternity pay supplemented to 18 weeks at full salary. Eligibility requires 26 weeks of tenure at the 15th week before the expected birth.'),
 (3,'Parental Leave — DE','country:DE',     'German employees receive Elternzeit up to 36 months, with Elterngeld funded by the state. Top-up to full salary for the first 14 weeks is provided by the company. No tenure requirement.'),
 (4,'PTO',                'global',         'All employees receive 20 days of PTO accrued per calendar year. Unused PTO does not roll over beyond 5 days. Bank holidays follow the local calendar.'),
 (5,'Expense Limits — IC',  'role:IC',      'Individual contributors may book domestic flights up to $500, hotels up to $250/night, and meals up to $75/day. Above-limit expenses require manager approval.'),
 (6,'Expense Limits — M',   'role:M',       'Managers may book domestic flights up to $800, hotels up to $400/night, and meals up to $120/day. International travel always requires VP approval regardless of role.');

Step 3: Embed (scoped)

UPDATE recipe_hr_policies SET embedding = EMBED(scope || ' — ' || title || ' — ' || body);

Step 4: Ground truth — employee row

SELECT email, country, role_band, (julianday('now') - julianday(hire_date)) / 30 AS months_tenure
FROM recipe_hr_employees WHERE email = 'bob@yourco.com';

Expected: Bob, UK, IC3, ~18 months tenure.

Step 5: Ground truth — policy retrieval (scope matters)

SELECT title, scope, COSINE_SIMILARITY(embedding, EMBED('country:UK — parental leave eligibility')) AS sim
FROM recipe_hr_policies ORDER BY sim DESC LIMIT 2;

Expected: Parental Leave — UK ranks first.

Step 6: Ask the HR agent

SELECT AGENT_RUN(
  'aidb-assistant',
  'An employee asks: "How many parental leave days am I entitled to?" The employee email is bob@yourco.com. Use execute_query to look up their country, hire date, and role band from recipe_hr_employees. Use rag_search on recipe_hr_policies to find the parental-leave policy for that country. Output the specific answer for this employee — quote the exact number of weeks, eligibility requirement, and whether the employee meets it given their tenure. Cite the policy ID.'
) AS hr_answer_bob;

Cleanup

DROP TABLE IF EXISTS recipe_hr_employees;
DROP TABLE IF EXISTS recipe_hr_policies;

Use it from your agent

  • Slack bot: turn this into a Slack slash command — /hr "how many parental leave days?" resolves the asker's email → calls the Step-6 SQL → posts the answer.
  • REST/SDK: wrap in a POST /v1/query/execute from your internal HR portal.
  • Why this beats RAG-only: the answer is employee-specific. Generic HR bots hallucinate country-specific eligibility because they don't see the row. SynapCores fixes that by giving the agent SQL access to the asker's record.

Key Concepts Learned

  • Country/role-scoped policies need the employee's row to answer correctly — pure RAG fails here.
  • Embedding the scope token alongside the policy body makes country/role retrieval much sharper.
  • HR ticket volume drops 50%+ when this pattern is in place because the asker gets the right answer the first time.

Tags

ai-agentagent-runhrpeople-opspolicyemployee-staterag

Run this on your own machine

Install SynapCores Community Edition free, paste the SQL or Cypher above into the bundled web UI, and watch it run.

Download Free CE