Atris

Sort and route new support tickets.
Done by an agent. Checked twice.

Every new ticket gets a type, an urgency and a queue under your written rules, with the urgent ones listed first.

Have Atris do this for you›

1

Real files in

  • customers.csv
    Twenty two customers with their plan and an at risk mark. 23 lines, 2 KB.
  • routing_rules.md
    The support team's written rules for type, urgency and queue. 77 lines, 4 KB.
  • tickets.csv
    Thirty six tickets from one weekend, with two repeats, four unknown senders, one empty body and three that are not support requests. 37 lines, 9 KB.

Sample data written by Atris. Not a real company.

2

Three steps

  1. 1.Read the rules, customers and tickets
  2. 2.Sort every ticket
  3. 3.Write the routing sheet and the handoff

Claude Sonnet 5.5, 1 min. No web. It never saw the check.

3

Checked twice

  • ✓Passed: 36 of 36 tickets appear once in routed.csv
  • ✓Passed: 36 of 36 types equal the type a keyword reading of the written rules gives
  • ✓Passed: 36 of 36 urgency levels equal the level looked up from type, plan and the at risk mark
  • ✓Passed: 36 of 36 queues equal the queue the rules give
  • ✓Passed: 2 of 2 repeat tickets point at the first ticket and 0 other tickets are marked as repeats
  • ✓Passed: 11 of 11 p1 tickets are in the p1 list in handoff.md and 0 lower tickets are in it
  • ✓Passed: 8 of 8 queue counts in handoff.md equal the counts in routed.csv
  • ✓Passed: 11 of 11 lines in the p1 list name the ticket's own queue, 11 of 11 arrival times on them equal the time in the tickets file and the list is oldest first
  • ✓Passed: 2 of 2 repeats and 4 of 4 senders missing from the customer list are named under their own headings in handoff.md, with 0 others

Second review by Claude Opus 5.5: pass.

Then we broke a copy of the output 6 ways on purpose. The check caught 6.

What it wrote. Lines 3 to 14 of handoff.md, copied from the file.
## p1 now
- T-3103 | product_support | reminder texts an hour early (premier, at risk) (2026-11-27 19:30)
- T-3105 | trust_team | login email changed by someone else, locked out (2026-11-27 21:47)
- T-3106 | on_call | booking page blank for clients (2026-11-28 08:02)
- T-3107 | on_call | repeat: booking page still blank (2026-11-28 08:15)
- T-3110 | billing_team | Fernwick invoice shows wrong plan price (at risk) (2026-11-28 10:30)
- T-3115 | on_call | cannot sign in on any device (2026-11-28 14:26)
- T-3116 | trust_team | another business's client details sent to a client (2026-11-28 15:10)
- T-3120 | trust_team | fake Fernwick text asking for password (2026-11-29 08:33)
- T-3121 | on_call | all card payments failing at checkout (2026-11-29 09:14)
- T-3131 | trust_team | sign-in from an unknown city (2026-11-29 21:10)
- T-3135 | on_call | locked out, account shows suspended (2026-11-30 08:12)

How this was run

An AI agent on Claude Sonnet 5.5 was given a folder with the files below and a three-step flow, and nothing else. It had no web access and never saw the check. The check was written before the run and made stricter after it. It works the answer out again from the input files. Then Claude Opus 5.5 reviewed the result against the inputs. The input files are sample data written by Atris, with the problems a real week has planted in them.

Run 1 of 1 on 1 December 2026. The agent took 1 min.

What the second review verified

  • Recomputed type, urgency and queue for all 36 tickets by hand from the rules. The at-risk raises are right: T-3103 bug goes from p2 to p1, T-3110 billing from p2 to p1, T-3108 how_to from p4 to p3 and T-3129 feedback from p4 to p3. The premier how_to and feedback tickets T-3102, T-3109, T-3123 and T-3136 go to account_managers.
  • Repeats are right. T-3107 matches T-3106 even though the email has different capital letters and the subject starts with 'RE:'. T-3125 matches T-3101. T-3126 comes from imani.achebe@mailbox.example, which is not in the customer list, so it is plan unknown and treated as starter. It is correctly not matched to Suncrest by name.
  • Queue counts in handoff.md match routed.csv: trust_team 4, on_call 5, billing_team 8, product_support 6, front_line 4, product_feedback 2, account_managers 4, no_queue 3, for 36 in total.
  • The p1 list has all 11 p1 tickets, oldest first, from T-3103 to T-3135. T-3130 has an empty body and is sorted from its subject as billing p3. T-3128, a wrong figure on client payments, is a bug at p2, not billing. The bundled check.py also passes all 7 of its checks.

What this run does not show

  • Ticket types are tested by keyword lists written by hand from the rules before the run. A ticket worded another way could be typed wrong without the check knowing.
  • The reason column and the few words on each p1 line are read only by the second review.
  • On this run the second review could see the check file and said so. It was not fully independent of the check.

Would the check catch a wrong answer?

A check that cannot fail proves nothing. After the run we took a copy of the output, broke it one small way at a time and ran the check again. It caught 6 of 6. The check was made stricter after the first try at this, and the same untouched output was graded again.

Open every file

flow.md · the three steps the agent followed
# Sort and route new support tickets

function: support
for: the support lead who hands out each morning's tickets
goal: Every new ticket has a type, an urgency and a queue under the written rules, with the most urgent listed first.

## 1. Read the rules, customers and tickets
Read input/routing_rules.md, input/customers.csv and input/tickets.csv. The rules file is the only
authority. Follow its parts in the order it gives them. Do not add rules of your own and do not
soften a rule because a message sounds upset or polite.

## 2. Sort every ticket
For each ticket work out who sent it, whether it is a repeat, its type, its urgency and its queue,
exactly as the rules file says. A ticket with an empty body is sorted from its subject. When a
ticket fits more than one type, use the order in the rules file to choose. Use only the type,
urgency and queue names that appear in the rules file.

## 3. Write the routing sheet and the handoff
Write output/routed.csv with columns ticket_id,type,urgency,queue,repeat_of,reason. One row per
ticket, in the order of the tickets file. repeat_of is the id of the first ticket when this one is a
repeat, otherwise empty. reason is one plain sentence saying which rule decided the type, plus
`plan unknown` when the sender is not in the customer list.

Write output/handoff.md for the support lead with these parts in this order:
- `## p1 now`: one line per p1 ticket, oldest first, each with the ticket id, the queue and a few words on the problem.
- `## Queue counts`: one line per queue in the form `queue_name: count`, for every queue in the rules file, even when the count is 0.
- `## Repeats`: one line per repeat ticket naming it and the first ticket.
- `## Plan unknown`: one line per ticket whose sender is not in the customer list.

## Done looks like
- Every ticket appears once in routed.csv with a type, urgency and queue from the rules file.
- Every p1 ticket is in the p1 list in handoff.md.
- The queue counts in handoff.md equal the counts in routed.csv.
input/customers.csv · 23 lines, 2 KB
customer_email,business_name,contact_name,plan,at_risk
owner@marlowgrooming.example,Marlow Dog Grooming,Tessa Marlow,team,no
hello@suncrestyoga.example,Suncrest Yoga Studio,Imani Achebe,premier,no
bookings@harbourphysio.example,Harbour Physio Clinic,Dr. Callum Reyes-Whitlock,premier,yes
dani@inkandiron.example,Ink and Iron Tattoo,Dani Kowalczyk,starter,no
frontdesk@willowbarber.example,Willow Street Barbers,Omar Haddad,team,no
lena@brightkeystutoring.example,Bright Keys Tutoring,Lena Vasquez,starter,yes
admin@northpointdental.example,Northpoint Dental,Priya Raghunathan,premier,no
info@cedarnails.example,Cedar Nail Bar,Mei-Lin Zhou,team,yes
sam@tunedupbikes.example,Tuned Up Bike Repair,Sam Oyelaran,starter,no
office@graniteclimb.example,Granite Climbing Gym,Hollis Brandt,team,no
jo@petalandstem.example,Petal and Stem Florist,Jo Castellanos,starter,no
care@riversidemassage.example,Riverside Massage,Anneke de Vries,team,no
studio@lumenphoto.example,Lumen Photo Studio,Farid Nasser,premier,no
team@quickfixphones.example,Quick Fix Phone Repair,Bao Tran,starter,no
owner@maplepaws.example,Maple Paws Vet,Dr. Ingrid Solheim,premier,no
mgr@corebalancepilates.example,Core Balance Pilates,Ruth Abernathy,team,no
hi@thelashroom.example,The Lash Room,Chiara Benedetti,starter,no
desk@altitudeswim.example,Altitude Swim School,Kwame Mensah,team,yes
ops@fennelkitchenclasses.example,Fennel Kitchen Classes,Noor Al-Sayed,starter,no
admin@oakhollowtherapy.example,Oak Hollow Therapy,Margit Lindqvist,premier,no
hello@tidelinesurf.example,Tideline Surf Lessons,Kai Fonoti,starter,no
reception@elmcourtchiro.example,Elm Court Chiropractic,Dr. Beatrix Onwudiwe,team,no
input/routing_rules.md · 77 lines, 4 KB
# Fernwick Bookings support: how to sort and route a new ticket

Last updated 12 October 2026 by the support lead. These rules apply to every ticket in a batch.
Work through parts A to E in order for each ticket.

## A. Who sent it

Look the sender up in the customer list by email address only. Ignore capital letters and spaces
around the address. Do not match on a person's name or on a business named in the message.

If the email is not in the customer list, treat the plan as `starter` and the at risk mark as `no`,
and write `plan unknown` in the reason.

## B. Is it a repeat

A ticket is a repeat when the same sender email already sent an earlier ticket in the same batch
with the same subject. When comparing subjects ignore capital letters and any `Re:` or `Fwd:` at
the front.

A repeat gets the same type, urgency and queue as the first ticket. Put the first ticket's id in
`repeat_of`. The first ticket is not a repeat and its `repeat_of` stays empty.

## C. Type

Give each ticket one type. Read the subject and the body. Go down this list and stop at the first
type that fits, even when a later type also fits.

1. `not_support`: the message is not a customer asking about their Fernwick account. This covers
   sales offers, recruiters and job enquiries, and messages meant for one of the businesses that use
   Fernwick (for example a member of the public trying to change their own appointment).
2. `security`: someone other than the customer got into an account or its data, or may have. This
   covers a login, email or password changed by someone else, a sign-in the customer does not
   recognise, one business's client details shown or sent to someone outside that business, and
   messages pretending to be Fernwick that ask for a password.
3. `outage`: the customer cannot use Fernwick at all, or their clients cannot. This covers not being
   able to sign in with the right password, a booking page that will not load, and card payments
   failing for every client.
4. `billing`: money between the customer and Fernwick. This covers charges for a plan or add-on,
   Fernwick invoices, refunds from Fernwick, the card on file for the plan, and cancelling a plan.
   Money that a business's own clients pay to that business is not billing. A wrong figure there is
   a `bug`.
5. `bug`: one part of the product gives a wrong result or an error while the rest works.
6. `how_to`: the customer asks how to do something, or whether the product can do something.
7. `feedback`: praise, a complaint or an idea for the product, with nothing to fix and no question
   to answer.

## D. Urgency

Start from this table, using the type and the plan from part A.

| type        | premier | team | starter |
|-------------|---------|------|---------|
| security    | p1      | p1   | p1      |
| outage      | p1      | p1   | p1      |
| billing     | p2      | p2   | p3      |
| bug         | p2      | p3   | p3      |
| how_to      | p3      | p4   | p4      |
| feedback    | p4      | p4   | p4      |
| not_support | none    | none | none    |

Then, if the customer list marks the sender as at risk, raise the urgency by one level (p4 becomes
p3, p3 becomes p2, p2 becomes p1). Nothing goes above p1. `none` stays `none`.

## E. Queue

| type        | queue            |
|-------------|------------------|
| security    | trust_team       |
| outage      | on_call          |
| billing     | billing_team     |
| bug         | product_support  |
| how_to      | front_line       |
| feedback    | product_feedback |
| not_support | no_queue         |

One exception: a `how_to` or `feedback` ticket from a sender on the `premier` plan goes to
`account_managers` instead.
input/tickets.csv · 37 lines, 9 KB
ticket_id,received_at,from_email,from_name,subject,body
T-3101,2026-11-27 18:42,owner@marlowgrooming.example,Tessa Marlow,Charged twice for November,"Hi, my card statement shows two charges of $49 on 25 November for the team plan. We only have one account. Please refund one of them."
T-3102,2026-11-27 19:05,hello@suncrestyoga.example,Imani Achebe,How do I set up a class pass?,"We want to sell a pass of ten classes that clients use up over three months. How do I set that up, and can it expire on its own?"
T-3103,2026-11-27 19:30,bookings@harbourphysio.example,Callum Reyes Whitlock,Reminder texts going out an hour early,Since the clocks changed our reminder texts tell patients their appointment is an hour earlier than it is. The calendar itself shows the right time. Two patients turned up early today and one left. Everything else is working.
T-3104,2026-11-27 20:11,growth@rankrocket-seo.example,Devon at RankRocket,Your unpaid invoice for search ranking services,"Hello, this is a reminder about the invoice for our search ranking package. Our agency can put Fernwick on page one in 30 days. Reply to book a call and we will waive the first month."
T-3105,2026-11-27 21:47,dani@inkandiron.example,Dani Kowalczyk,Someone changed my login email,I just got a notice saying the login email on my account was changed to an address I have never seen. I did not do this. Now I can't sign in either. Please stop whoever this is.
T-3106,2026-11-28 08:02,frontdesk@willowbarber.example,Omar Haddad,Booking page not loading,Three clients have told me our booking page is just a blank white screen this morning. I tried it on my phone and it is the same. Saturday is our busiest day.
T-3107,2026-11-28 08:15,FrontDesk@WillowBarber.example,Omar Haddad,RE: Booking page not loading,Still blank. Any update? We are turning people away at the door because they could not book.
T-3108,2026-11-28 09:20,lena@brightkeystutoring.example,Lena Vasquez,Can I take deposits for lessons?,"A few parents keep cancelling late. Can I ask for a deposit when they book a lesson? If so, where is the setting?"
T-3109,2026-11-28 09:58,admin@northpointdental.example,Priya Raghunathan,Please add a waiting list,"It would help us a lot if patients could join a waiting list for a full day and get told when a slot opens. Nothing is broken, this is just a request for the product team."
T-3110,2026-11-28 10:30,info@cedarnails.example,Mei-Lin Zhou,Invoice shows the wrong plan price,Our November invoice from Fernwick says $79. We are on the team plan which is $49. Please correct the invoice and tell me what my card will be charged.
T-3111,2026-11-28 11:05,marcus.bell@postbox.example,Marcus Bell,Move my haircut to Friday,"Hi, I have a haircut booked with Omar on Thursday at 4. Can you move my appointment to Friday afternoon instead? Thanks, Marcus"
T-3112,2026-11-28 11:40,sam@tunedupbikes.example,Sam Oyelaran,Calendar sync shows every booking twice,"Since Thursday my Google calendar shows each booking two times. The calendar inside Fernwick is right, it is only the synced copy that doubles up."
T-3113,2026-11-28 12:15,office@graniteclimb.example,Hollis Brandt,Cancel our plan at the end of the month,"We are closing for refurbishment. How do we cancel our plan from 30 November, and will we be charged for December if we do it today?"
T-3114,2026-11-28 13:02,jo@petalandstem.example,Jo Castellanos,Thank you!,No question this time. Ravi on your team walked me through my whole setup last week and was so patient. Just wanted someone to know.
T-3115,2026-11-28 14:26,care@riversidemassage.example,Anneke de Vries,Cannot sign in on any device,"My password is right and I have reset it twice. Every time I get 'Something went wrong' on the laptop, the tablet and my phone. I cannot see who is coming in today."
T-3116,2026-11-28 15:10,studio@lumenphoto.example,Farid Nasser,Client got another studio's confirmation email,"One of my clients forwarded me her booking confirmation. It has the name and phone number of a client of a different business on it, not hers. That is someone else's private details going to my client."
T-3117,2026-11-28 16:45,team@quickfixphones.example,Bao Tran,Refund for an upgrade made by mistake,I pressed upgrade by accident yesterday and was charged $19 for an add-on I do not want. Please refund it and put me back on what I had.
T-3118,2026-11-28 18:03,owner@maplepaws.example,Ingrid Solhiem,Client export is missing phone numbers,When I export my client list the phone column is empty for about half the clients. The numbers are there when I open each client. The rest of the export looks right.
T-3119,2026-11-29 07:50,mgr@corebalancepilates.example,Ruth Abernathy,Is there a way to block out holidays?,"We close between 24 December and 2 January. Is there a way to block those days so nobody can book, without doing it one day at a time?"
T-3120,2026-11-29 08:33,hi@thelashroom.example,Chiara Benedetti,Text from Fernwick asking for my password,I got a text saying my Fernwick account is suspended and to reply with my password to restore it. Is this really from you? I have not replied.
T-3121,2026-11-29 09:14,desk@altitudeswim.example,Kwame Mensah,Card payments all failing,"Every card a parent has tried since last night is declined at checkout. Three parents have phoned. It is all failing, not just one card. We are taking cash only for now."
T-3122,2026-11-29 10:02,ops@fennelkitchenclasses.example,Noor Al-Sayed,Why was I charged after cancelling?,I cancelled my plan on 2 November and have the email to prove it. On 25 November I was charged $19 again. Please refund it.
T-3123,2026-11-29 10:48,admin@oakhollowtherapy.example,Margit Lindqvist,"Two therapists, one room: how to stop double booking?",Two of our therapists share one treatment room. How do I set things up so that when one books the room the other cannot be booked into it at the same time?
T-3124,2026-11-29 11:30,talent@brightpath-recruit.example,Brightpath Recruit,Experienced support agents available now,We place vetted support candidates with growing software firms. Three candidates are ready to start in December. Shall I send their profiles?
T-3125,2026-11-29 12:20,owner@marlowgrooming.example,Tessa Marlow,Charged twice for November,Sending this again as I have heard nothing since Friday. Two charges of $49 on the same day. I would like one back please.
T-3126,2026-11-29 13:05,imani.achebe@mailbox.example,Imani Achebe,Class pass is not applying the discount,"Writing from my own email as I am away from the studio. At Suncrest Yoga the ten class pass is meant to take a booking off the pass, but at checkout clients are being asked for the full price. Booking without a pass works as normal."
T-3127,2026-11-29 14:40,office@graniteclimb.example,Hollis Brandt,Waiver form before the first visit,"Separate question from my other message. Can clients sign our waiver form online before their first visit, and how do I switch that on?"
T-3128,2026-11-29 15:55,admin@northpointdental.example,Priya Raghunathan,Report total does not match payouts,"The November revenue report in Fernwick says our patients paid $18,240. The payouts listed for the same dates add up to $17,905. One of these two screens is showing a wrong figure. Which is right?"
T-3129,2026-11-29 17:20,info@cedarnails.example,Mei-Lin Zhou,Love the new calendar view,The new week view is so much easier to read. One idea for later: it would be nice to colour each column by staff member. No reply needed.
T-3130,2026-11-29 19:44,team@quickfixphones.example,Bao Tran,Update the card on file for my plan,
T-3131,2026-11-29 21:10,owner@maplepaws.example,Dr. Ingrid Solheim,Sign-in from a city we have never been to,The security page lists a sign-in at 3:12 this morning from a city none of us has ever visited. Nobody here was awake. I have not changed anything yet.
T-3132,2026-11-30 06:35,mgr@corebalancepilates.example,Ruth Abernathy,Error when one instructor saves a note,One of my instructors gets 'Could not save note' every time she adds a client note. The other four instructors can save notes fine and she can do everything else.
T-3133,2026-11-30 07:05,hi@thelashroom.example,Chiara Benedetti,How do I add a second location?,I am opening a second room across town in January. How do I add it so clients can pick which one they are booking?
T-3134,2026-11-30 07:40,care@riversidemassage.example,Anneke de Vries,Need a copy of our October invoice,My bookkeeper needs the October invoice from Fernwick for our plan. I cannot find where to download it. Could you send a copy?
T-3135,2026-11-30 08:12,ops@fennelkitchenclasses.example,Noor Al-Sayed,Charged twice and now locked out,"Following my earlier message it got worse. There is now a second $19 charge, and since this morning I can't sign in at all. The screen says the account is suspended. I have a class to run tonight and cannot see who booked."
T-3136,2026-11-30 08:30,admin@oakhollowtherapy.example,Margit Lindqvist,Gift vouchers,It would be wonderful to sell gift vouchers through the booking page. Several clients have asked this month. Passing it on as a suggestion.
output/handoff.md · written by the agent, 34 lines
# Handoff

## p1 now
- T-3103 | product_support | reminder texts an hour early (premier, at risk) (2026-11-27 19:30)
- T-3105 | trust_team | login email changed by someone else, locked out (2026-11-27 21:47)
- T-3106 | on_call | booking page blank for clients (2026-11-28 08:02)
- T-3107 | on_call | repeat: booking page still blank (2026-11-28 08:15)
- T-3110 | billing_team | Fernwick invoice shows wrong plan price (at risk) (2026-11-28 10:30)
- T-3115 | on_call | cannot sign in on any device (2026-11-28 14:26)
- T-3116 | trust_team | another business's client details sent to a client (2026-11-28 15:10)
- T-3120 | trust_team | fake Fernwick text asking for password (2026-11-29 08:33)
- T-3121 | on_call | all card payments failing at checkout (2026-11-29 09:14)
- T-3131 | trust_team | sign-in from an unknown city (2026-11-29 21:10)
- T-3135 | on_call | locked out, account shows suspended (2026-11-30 08:12)

## Queue counts
- trust_team: 4
- on_call: 5
- billing_team: 8
- product_support: 6
- front_line: 4
- product_feedback: 2
- account_managers: 4
- no_queue: 3

## Repeats
- T-3107 is a repeat of T-3106
- T-3125 is a repeat of T-3101

## Plan unknown
- T-3104: sender not in the customer list, treated as starter / not at risk
- T-3111: sender not in the customer list, treated as starter / not at risk
- T-3124: sender not in the customer list, treated as starter / not at risk
- T-3126: sender not in the customer list, treated as starter / not at risk
output/routed.csv · written by the agent, 37 lines
ticket_id,type,urgency,queue,repeat_of,reason
T-3101,billing,p2,billing_team,,Billing rule: charged twice for the Fernwick plan.
T-3102,how_to,p3,account_managers,,How-to rule: asks how to set up a class pass.
T-3103,bug,p1,product_support,,Bug rule: reminder texts show the wrong time while the calendar and the rest work.
T-3104,not_support,none,no_queue,,Not-support rule: sales offer from an SEO agency. plan unknown
T-3105,security,p1,trust_team,,Security rule: login email changed by someone else (matched before outage).
T-3106,outage,p1,on_call,,Outage rule: booking page will not load for clients.
T-3107,outage,p1,on_call,T-3106,"Outage rule: booking page will not load for clients (repeat of T-3106, same type as the first ticket)."
T-3108,how_to,p3,front_line,,How-to rule: asks whether deposits can be taken and where the setting is.
T-3109,feedback,p4,account_managers,,Feedback rule: product idea with nothing broken and no question.
T-3110,billing,p1,billing_team,,Billing rule: Fernwick invoice shows the wrong plan price.
T-3111,not_support,none,no_queue,,"Not-support rule: member of the public asking to move their own appointment, which is for the business. plan unknown"
T-3112,bug,p3,product_support,,Bug rule: synced calendar copy doubles bookings while the Fernwick calendar is right.
T-3113,billing,p2,billing_team,,Billing rule: cancelling a plan and December charges (matched before how_to).
T-3114,feedback,p4,product_feedback,,Feedback rule: praise with no question.
T-3115,outage,p1,on_call,,Outage rule: cannot sign in with the right password on any device.
T-3116,security,p1,trust_team,,Security rule: one business's client details sent to someone outside that business.
T-3117,billing,p3,billing_team,,Billing rule: refund for a charged add-on.
T-3118,bug,p2,product_support,,Bug rule: export phone column empty while the rest works.
T-3119,how_to,p4,front_line,,How-to rule: asks how to block out holiday dates.
T-3120,security,p1,trust_team,,Security rule: message pretending to be Fernwick asking for a password.
T-3121,outage,p1,on_call,,Outage rule: card payments failing for every client.
T-3122,billing,p3,billing_team,,"Billing rule: charged after cancelling a plan, refund requested."
T-3123,how_to,p3,account_managers,,How-to rule: asks how to stop double booking a shared room.
T-3124,not_support,none,no_queue,,Not-support rule: recruiter offer. plan unknown
T-3125,billing,p2,billing_team,T-3101,"Billing rule: repeat of T-3101, same type as the first ticket."
T-3126,bug,p3,product_support,,Bug rule: class pass discount not applied at checkout while normal booking works (sender matched by email only). plan unknown
T-3127,how_to,p4,front_line,,How-to rule: asks whether clients can sign a waiver online and how to switch it on.
T-3128,bug,p2,product_support,,"Bug rule: wrong figure on a report of client payments is a bug, not billing."
T-3129,feedback,p3,product_feedback,,Feedback rule: praise and an idea with no reply needed.
T-3130,billing,p3,billing_team,,"Billing rule: card on file for the plan (body empty, sorted from subject)."
T-3131,security,p1,trust_team,,Security rule: sign-in the customer does not recognise.
T-3132,bug,p3,product_support,,Bug rule: note saving fails for one instructor while the rest works.
T-3133,how_to,p4,front_line,,How-to rule: asks how to add a second location.
T-3134,billing,p2,billing_team,,Billing rule: asks for a copy of a Fernwick invoice.
T-3135,outage,p1,on_call,,Outage rule: cannot sign in at all (matched before billing).
T-3136,feedback,p4,account_managers,,Feedback rule: product suggestion with nothing to fix.
check.py · the check, written before the run
"""Works out type, urgency and queue for every ticket from the input files and compares them with the agent's sheet.

The type comes from a keyword reading of the rules in input/routing_rules.md, taken in the same
order as the rules. Urgency and queue are then looked up from the plan and at risk mark in
input/customers.csv.
"""
import csv, re, sys
from pathlib import Path
root = Path(sys.argv[1]); ok = True
def say(passed, text):
    global ok; ok = ok and passed; print(("PASS " if passed else "FAIL ") + text)

TYPE_WORDS = [  # same order as part C of the rules file; first hit wins
    ("not_support", r"search ranking|our agency|candidates|recruit|haircut booked|move my appointment"),
    ("security", r"someone changed|i did not do this|asking for my password|someone else's private details|sign-in from a city|client of a different business"),
    ("outage", r"can't sign in|cannot sign in|not loading|blank white screen|all failing|locked out"),
    ("billing", r"charged|invoice|refund|card on file|cancel our plan|cancel my plan"),
    ("bug", r"twice|an hour early|missing|not applying|does not match|error"),
    ("how_to", r"how do i|how to|can i |is there a way|can clients"),
]
TABLE = {"security": ("p1", "p1", "p1"), "outage": ("p1", "p1", "p1"), "billing": ("p2", "p2", "p3"),
         "bug": ("p2", "p3", "p3"), "how_to": ("p3", "p4", "p4"), "feedback": ("p4", "p4", "p4"),
         "not_support": ("none", "none", "none")}
QUEUE = {"security": "trust_team", "outage": "on_call", "billing": "billing_team", "bug": "product_support",
         "how_to": "front_line", "feedback": "product_feedback", "not_support": "no_queue"}
PLANS = ["premier", "team", "starter"]
RAISE = {"p4": "p3", "p3": "p2", "p2": "p1", "p1": "p1", "none": "none"}

cust = {r["customer_email"].strip().lower(): r for r in csv.DictReader((root/"input/customers.csv").open())}
tickets = list(csv.DictReader((root/"input/tickets.csv").open()))
want, first_seen = {}, {}
for t in sorted(tickets, key=lambda r: (r["received_at"], r["ticket_id"])):
    email = t["from_email"].strip().lower()
    subject = re.sub(r"^\s*((re|fwd)\s*:\s*)+", "", t["subject"].strip().lower())
    key = (email, subject)
    if key in first_seen:
        typ, urg, queue, _ = want[first_seen[key]]
        want[t["ticket_id"]] = (typ, urg, queue, first_seen[key]); continue
    first_seen[key] = t["ticket_id"]
    text = (t["subject"] + " " + t["body"]).lower().replace("’", "'")
    typ = next((name for name, words in TYPE_WORDS if re.search(words, text)), "feedback")
    c = cust.get(email)
    plan = c["plan"] if c else "starter"
    urg = TABLE[typ][PLANS.index(plan)]
    if c and c["at_risk"].strip().lower() == "yes":
        urg = RAISE[urg]
    queue = "account_managers" if typ in ("how_to", "feedback") and plan == "premier" else QUEUE[typ]
    want[t["ticket_id"]] = (typ, urg, queue, "")

path = root/"output/routed.csv"
if not path.exists():
    say(False, "output/routed.csv was not written"); sys.exit(1)
rows = list(csv.DictReader(path.open()))
got = {(r.get("ticket_id") or "").strip(): r for r in rows}
def cell(k, col):
    return (got.get(k, {}).get(col) or "").strip().lower()
n = len(want)
once = sum(1 for k in want if sum(1 for r in rows if (r.get("ticket_id") or "").strip() == k) == 1)
say(once == n and len(rows) == n, f"{once} of {n} tickets appear once in routed.csv")
right = sum(1 for k, w in want.items() if cell(k, "type") == w[0])
say(right == n, f"{right} of {n} types equal the type a keyword reading of the written rules gives")
right = sum(1 for k, w in want.items() if cell(k, "urgency") == w[1])
say(right == n, f"{right} of {n} urgency levels equal the level looked up from type, plan and the at risk mark")
right = sum(1 for k, w in want.items() if cell(k, "queue") == w[2])
say(right == n, f"{right} of {n} queues equal the queue the rules give")
reps = {k: w[3] for k, w in want.items() if w[3]}
right = sum(1 for k, first in reps.items() if cell(k, "repeat_of") == first.lower())
extra = sum(1 for k in want if k not in reps and cell(k, "repeat_of"))
say(right == len(reps) and extra == 0, f"{right} of {len(reps)} repeat tickets point at the first ticket and {extra} other tickets are marked as repeats")

hand = (root/"output/handoff.md").read_text() if (root/"output/handoff.md").exists() else ""
m = re.search(r"^#+[^\n]*p1[^\n]*\n(.*?)(?=^#+ |\Z)", hand, re.S | re.M | re.I)
p1_part = m.group(1) if m else ""
p1 = [k for k, w in want.items() if w[1] == "p1"]
named = sum(1 for k in p1 if k in p1_part)
others = sum(1 for k, w in want.items() if w[1] != "p1" and k in p1_part)
say(named == len(p1) and others == 0, f"{named} of {len(p1)} p1 tickets are in the p1 list in handoff.md and {others} lower tickets are in it")
queues = sorted(set(QUEUE.values()) | {"account_managers"})
good = 0
for q in queues:
    m = re.search(r"^[\s\-*`]*" + q + r"[`*]*\s*:\s*\**(\d+)", hand, re.M)
    if m and int(m.group(1)) == sum(1 for r in rows if (r.get("queue") or "").strip().lower() == q) == sum(1 for w in want.values() if w[2] == q):
        good += 1
say(good == len(queues), f"{good} of {len(queues)} queue counts in handoff.md equal the counts in routed.csv")
def part(name):
    m = re.search(r"^#+[^\n]*" + name + r"[^\n]*\n(.*?)(?=^#+ |\Z)", hand, re.S | re.M | re.I)
    return [l for l in (m.group(1) if m else "").splitlines() if re.search(r"T-\d+", l)]
arrived = {t["ticket_id"]: t["received_at"].strip() for t in tickets}
p1_lines = part("p1")
p1_ids = [re.search(r"T-\d+", l).group(0) for l in p1_lines]
in_order = p1_ids == sorted(p1_ids, key=lambda k: (arrived.get(k, ""), k))
with_queue = sum(1 for k, l in zip(p1_ids, p1_lines) if k in want and re.search(r"\b" + want[k][2] + r"\b", l.lower()))
stamps = [(k, d, h) for k, l in zip(p1_ids, p1_lines) for d, h in re.findall(r"(\d{4}-\d{2}-\d{2})?[ T]?\b(\d{1,2}:\d{2})\b", l)]
stamps += [(k, d, "") for k, l in zip(p1_ids, p1_lines) for d in re.findall(r"\d{4}-\d{2}-\d{2}(?![ T]?\d{1,2}:\d{2})", l)]
true_times = sum(1 for k, d, h in stamps if d in arrived.get(k, "") and h.zfill(5) in arrived.get(k, ""))
shown = f"{true_times} of {len(stamps)} arrival times on them equal the time in the tickets file" if stamps else "no arrival times are shown on them"
say(in_order and with_queue == len(p1) == len(p1_lines) and true_times == len(stamps),
    f"{with_queue} of {len(p1)} lines in the p1 list name the ticket's own queue, {shown} and the list is {'oldest first' if in_order else 'not oldest first'}")
rep_lines = part("repeats")
rep_ok = sum(1 for k, first in reps.items() if any(re.findall(r"T-\d+", l)[:1] == [k] and first in l for l in rep_lines))
unknown = [t["ticket_id"] for t in tickets if t["from_email"].strip().lower() not in cust]
unk_ids = [re.search(r"T-\d+", l).group(0) for l in part("plan unknown")]
unk_ok = sum(1 for k in unknown if k in unk_ids and "plan unknown" in cell(k, "reason"))
extra = len(rep_lines) - rep_ok + sum(1 for k in unk_ids if k not in unknown) + sum(1 for k in want if k not in unknown and "plan unknown" in cell(k, "reason"))
say(rep_ok == len(reps) and unk_ok == len(unknown) and extra == 0,
    f"{rep_ok} of {len(reps)} repeats and {unk_ok} of {len(unknown)} senders missing from the customer list are named under their own headings in handoff.md, with {extra} others")
sys.exit(0 if ok else 1)

customers.csv: sample data written by Atris. Fingerprint 2fa77c9ce629.

routing_rules.md: sample data written by Atris. Fingerprint c58f62c21da1.

tickets.csv: sample data written by Atris. Fingerprint 23ecee61b880.

handoff.md: written by the agent. Fingerprint b6c877835550.

routed.csv: written by the agent. Fingerprint 13ae356e4e08.


More customer support work, and every other desk job

For agentsGitHub
What is AtrisBlogApp StorePricingPrivacyTerms