Follow Discord
Sweep 22 Oct 2026 · 04:32Z Build v2.1.308 527 read Stable v2.1.308 Latest v2.1.308 Next v2.1.308 Feeds RSS JSON llms.txt llms-full.txt Unofficial
One change · api

ticket-routing changedabout-claude/use-case-guides/ticket-routing

Nearest release: v2.1.301, published 5 hours before this site recorded the change. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.

Recorded here
Lines+1,092added
Lines−133removed
From line 6 where the diff opens
First seen 14 Aug 2026 this site's first read of the page
Recorded edits10to this page, all time

The whole hunk

from line 6, old and new numbered
/
lines

The two sides of this change are more than 400 edits apart, too far apart to line up, so this is the differ's own diff of it and the words inside a line are not marked.

from line 6
66 
77## Prerequisites
88 
9* A Claude API key and the Python SDK installed
9* A Claude API key and the Claude SDK installed
1010* Access to, and familiarity with, your existing support ticketing system
1111* A sample set of historical support tickets for testing
1212 
from line 249
249249 
250250Here's an example ticket routing classification prompt:
251251 
252```python
253def classify_support_request(ticket_contents):
252<CodeGroup exclude="shell">
253 <CodeGroupItem language="cURL">
254 Build the prompt in code.
255 </CodeGroupItem>
256 
257 <CodeGroupItem language="CLI">
258 Build the prompt in code.
259 </CodeGroupItem>
260 
261 ```python Python
262 def classify_support_request(ticket_contents):
263 # Define the prompt for the classification task
264 classification_prompt = f"""You will be acting as a customer support ticket classification system. Your task is to analyze customer support requests and output the appropriate classification intent for each request, along with your reasoning.
265 
266 Here is the customer support request you need to classify:
267 
268 <request>{ticket_contents}</request>
269 
270 Please carefully analyze the above request to determine the customer's core intent and needs. Consider what the customer is asking for has concerns about.
271 
272 First, write out your reasoning and analysis of how to classify this request inside <reasoning> tags.
273 
274 Then, output the appropriate classification label for the request inside a <intent> tag. The valid intents are:
275 <intents>
276 <intent>Support, Feedback, Complaint</intent>
277 <intent>Order Tracking</intent>
278 <intent>Refund/Exchange</intent>
279 </intents>
280 
281 A request may have ONLY ONE applicable intent. Only include the intent that is most applicable to the request.
282 
283 As an example, consider the following request:
284 <request>Hello! I had high-speed fiber internet installed on Saturday and my installer, Kevin, was absolutely fantastic! Where can I send my positive review? Thanks for your help!</request>
285 
286 Here is an example of how your output should be formatted (for the above example request):
287 <reasoning>The user seeks information in order to leave positive feedback.</reasoning>
288 <intent>Support, Feedback, Complaint</intent>
289 
290 Here are a few more examples:
291 <examples>
292 <example 2>
293 Example 2 Input:
294 <request>I wanted to write and personally thank you for the compassion you showed towards my family during my father's funeral this past weekend. Your staff was so considerate and helpful throughout this whole process; it really took a load off our shoulders. The visitation brochures were beautiful. We'll never forget the kindness you showed us and we are so appreciative of how smoothly the proceedings went. Thank you, again, Amarantha Hill on behalf of the Hill Family.</request>
295 
296 Example 2 Output:
297 <reasoning>User leaves a positive review of their experience.</reasoning>
298 <intent>Support, Feedback, Complaint</intent>
299 </example 2>
300 <example 3>
301 
302 […]
303 
304 </example 8>
305 <example 9>
306 Example 9 Input:
307 <request>Your website keeps sending ad-popups that block the entire screen. It took me twenty minutes just to finally find the phone number to call and complain. How can I possibly access my account information with all of these popups? Can you access my account for me, since your website is broken? I need to know what the address is on file.</request>
308 
309 Example 9 Output:
310 <reasoning>The user requests help accessing their web account information.</reasoning>
311 <intent>Support, Feedback, Complaint</intent>
312 </example 9>
313 
314 Remember to always include your classification reasoning before your actual intent output. The reasoning should be enclosed in <reasoning> tags and the intent in <intent> tags. Return only the reasoning and the intent.
315 """
316 ```
317 
318 ```typescript TypeScript
319 function classifySupportRequest(ticketContents: string) {
320 // Define the prompt for the classification task
321 const classificationPrompt = `You will be acting as a customer support ticket classification system. Your task is to analyze customer support requests and output the appropriate classification intent for each request, along with your reasoning.
322 
323 Here is the customer support request you need to classify:
324 
325 <request>${ticketContents}</request>
326 
327 Please carefully analyze the above request to determine the customer's core intent and needs. Consider what the customer is asking for has concerns about.
328 
329 First, write out your reasoning and analysis of how to classify this request inside <reasoning> tags.
330 
331 Then, output the appropriate classification label for the request inside a <intent> tag. The valid intents are:
332 <intents>
333 <intent>Support, Feedback, Complaint</intent>
334 <intent>Order Tracking</intent>
335 <intent>Refund/Exchange</intent>
336 </intents>
337 
338 A request may have ONLY ONE applicable intent. Only include the intent that is most applicable to the request.
339 
340 As an example, consider the following request:
341 <request>Hello! I had high-speed fiber internet installed on Saturday and my installer, Kevin, was absolutely fantastic! Where can I send my positive review? Thanks for your help!</request>
342 
343 Here is an example of how your output should be formatted (for the above example request):
344 <reasoning>The user seeks information in order to leave positive feedback.</reasoning>
345 <intent>Support, Feedback, Complaint</intent>
346 
347 Here are a few more examples:
348 <examples>
349 <example 2>
350 Example 2 Input:
351 <request>I wanted to write and personally thank you for the compassion you showed towards my family during my father's funeral this past weekend. Your staff was so considerate and helpful throughout this whole process; it really took a load off our shoulders. The visitation brochures were beautiful. We'll never forget the kindness you showed us and we are so appreciative of how smoothly the proceedings went. Thank you, again, Amarantha Hill on behalf of the Hill Family.</request>
352 
353 Example 2 Output:
354 <reasoning>User leaves a positive review of their experience.</reasoning>
355 <intent>Support, Feedback, Complaint</intent>
356 </example 2>
357 <example 3>
358 
359 […]
360 
361 </example 8>
362 <example 9>
363 Example 9 Input:
364 <request>Your website keeps sending ad-popups that block the entire screen. It took me twenty minutes just to finally find the phone number to call and complain. How can I possibly access my account information with all of these popups? Can you access my account for me, since your website is broken? I need to know what the address is on file.</request>
365 
366 Example 9 Output:
367 <reasoning>The user requests help accessing their web account information.</reasoning>
368 <intent>Support, Feedback, Complaint</intent>
369 </example 9>
370 
371 Remember to always include your classification reasoning before your actual intent output. The reasoning should be enclosed in <reasoning> tags and the intent in <intent> tags. Return only the reasoning and the intent.
372 `;
373 }
374 ```
375 
376 ```csharp C#
377 void ClassifySupportRequest(string ticketContents)
378 {
379 // Define the prompt for the classification task
380 var classificationPrompt = $"""
381 You will be acting as a customer support ticket classification system. Your task is to analyze customer support requests and output the appropriate classification intent for each request, along with your reasoning.
382 
383 Here is the customer support request you need to classify:
384 
385 <request>{ticketContents}</request>
386 
387 Please carefully analyze the above request to determine the customer's core intent and needs. Consider what the customer is asking for has concerns about.
388 
389 First, write out your reasoning and analysis of how to classify this request inside <reasoning> tags.
390 
391 Then, output the appropriate classification label for the request inside a <intent> tag. The valid intents are:
392 <intents>
393 <intent>Support, Feedback, Complaint</intent>
394 <intent>Order Tracking</intent>
395 <intent>Refund/Exchange</intent>
396 </intents>
397 
398 A request may have ONLY ONE applicable intent. Only include the intent that is most applicable to the request.
399 
400 As an example, consider the following request:
401 <request>Hello! I had high-speed fiber internet installed on Saturday and my installer, Kevin, was absolutely fantastic! Where can I send my positive review? Thanks for your help!</request>
402 
403 Here is an example of how your output should be formatted (for the above example request):
404 <reasoning>The user seeks information in order to leave positive feedback.</reasoning>
405 <intent>Support, Feedback, Complaint</intent>
406 
407 Here are a few more examples:
408 <examples>
409 <example 2>
410 Example 2 Input:
411 <request>I wanted to write and personally thank you for the compassion you showed towards my family during my father's funeral this past weekend. Your staff was so considerate and helpful throughout this whole process; it really took a load off our shoulders. The visitation brochures were beautiful. We'll never forget the kindness you showed us and we are so appreciative of how smoothly the proceedings went. Thank you, again, Amarantha Hill on behalf of the Hill Family.</request>
412 
413 Example 2 Output:
414 <reasoning>User leaves a positive review of their experience.</reasoning>
415 <intent>Support, Feedback, Complaint</intent>
416 </example 2>
417 <example 3>
418 
419 […]
420 
421 </example 8>
422 <example 9>
423 Example 9 Input:
424 <request>Your website keeps sending ad-popups that block the entire screen. It took me twenty minutes just to finally find the phone number to call and complain. How can I possibly access my account information with all of these popups? Can you access my account for me, since your website is broken? I need to know what the address is on file.</request>
425 
426 Example 9 Output:
427 <reasoning>The user requests help accessing their web account information.</reasoning>
428 <intent>Support, Feedback, Complaint</intent>
429 </example 9>
430 
431 Remember to always include your classification reasoning before your actual intent output. The reasoning should be enclosed in <reasoning> tags and the intent in <intent> tags. Return only the reasoning and the intent.
432 """;
433 }
434 ```
435 
436 ```go Go
437 func classifySupportRequest(ticketContents string) {
438 // Define the prompt for the classification task
439 classificationPrompt := `You will be acting as a customer support ticket classification system. Your task is to analyze customer support requests and output the appropriate classification intent for each request, along with your reasoning.
440 
441 Here is the customer support request you need to classify:
442 
443 <request>` + ticketContents + `</request>
444 
445 Please carefully analyze the above request to determine the customer's core intent and needs. Consider what the customer is asking for has concerns about.
446 
447 First, write out your reasoning and analysis of how to classify this request inside <reasoning> tags.
448 
449 Then, output the appropriate classification label for the request inside a <intent> tag. The valid intents are:
450 <intents>
451 <intent>Support, Feedback, Complaint</intent>
452 <intent>Order Tracking</intent>
453 <intent>Refund/Exchange</intent>
454 </intents>
455 
456 A request may have ONLY ONE applicable intent. Only include the intent that is most applicable to the request.
457 
458 As an example, consider the following request:
459 <request>Hello! I had high-speed fiber internet installed on Saturday and my installer, Kevin, was absolutely fantastic! Where can I send my positive review? Thanks for your help!</request>
460 
461 Here is an example of how your output should be formatted (for the above example request):
462 <reasoning>The user seeks information in order to leave positive feedback.</reasoning>
463 <intent>Support, Feedback, Complaint</intent>
464 
465 Here are a few more examples:
466 <examples>
467 <example 2>
468 Example 2 Input:
469 <request>I wanted to write and personally thank you for the compassion you showed towards my family during my father's funeral this past weekend. Your staff was so considerate and helpful throughout this whole process; it really took a load off our shoulders. The visitation brochures were beautiful. We'll never forget the kindness you showed us and we are so appreciative of how smoothly the proceedings went. Thank you, again, Amarantha Hill on behalf of the Hill Family.</request>
470 
471 Example 2 Output:
472 <reasoning>User leaves a positive review of their experience.</reasoning>
473 <intent>Support, Feedback, Complaint</intent>
474 </example 2>
475 <example 3>
476 
477 […]
478 
479 </example 8>
480 <example 9>
481 Example 9 Input:
482 <request>Your website keeps sending ad-popups that block the entire screen. It took me twenty minutes just to finally find the phone number to call and complain. How can I possibly access my account information with all of these popups? Can you access my account for me, since your website is broken? I need to know what the address is on file.</request>
483 
484 Example 9 Output:
485 <reasoning>The user requests help accessing their web account information.</reasoning>
486 <intent>Support, Feedback, Complaint</intent>
487 </example 9>
488 
489 Remember to always include your classification reasoning before your actual intent output. The reasoning should be enclosed in <reasoning> tags and the intent in <intent> tags. Return only the reasoning and the intent.
490 `
491 // ...
492 }
493 ```
494 
495 ```java Java
496 void classifySupportRequest(String ticketContents) {
497 // Define the prompt for the classification task
498 String classificationPrompt = """
499 You will be acting as a customer support ticket classification system. Your task is to analyze customer support requests and output the appropriate classification intent for each request, along with your reasoning.
500 
501 Here is the customer support request you need to classify:
502 
503 <request>%s</request>
504 
505 Please carefully analyze the above request to determine the customer's core intent and needs. Consider what the customer is asking for has concerns about.
506 
507 First, write out your reasoning and analysis of how to classify this request inside <reasoning> tags.
508 
509 Then, output the appropriate classification label for the request inside a <intent> tag. The valid intents are:
510 <intents>
511 <intent>Support, Feedback, Complaint</intent>
512 <intent>Order Tracking</intent>
513 <intent>Refund/Exchange</intent>
514 </intents>
515 
516 A request may have ONLY ONE applicable intent. Only include the intent that is most applicable to the request.
517 
518 As an example, consider the following request:
519 <request>Hello! I had high-speed fiber internet installed on Saturday and my installer, Kevin, was absolutely fantastic! Where can I send my positive review? Thanks for your help!</request>
520 
521 Here is an example of how your output should be formatted (for the above example request):
522 <reasoning>The user seeks information in order to leave positive feedback.</reasoning>
523 <intent>Support, Feedback, Complaint</intent>
524 
525 Here are a few more examples:
526 <examples>
527 <example 2>
528 Example 2 Input:
529 <request>I wanted to write and personally thank you for the compassion you showed towards my family during my father's funeral this past weekend. Your staff was so considerate and helpful throughout this whole process; it really took a load off our shoulders. The visitation brochures were beautiful. We'll never forget the kindness you showed us and we are so appreciative of how smoothly the proceedings went. Thank you, again, Amarantha Hill on behalf of the Hill Family.</request>
530 
531 Example 2 Output:
532 <reasoning>User leaves a positive review of their experience.</reasoning>
533 <intent>Support, Feedback, Complaint</intent>
534 </example 2>
535 <example 3>
536 
537 […]
538 
539 </example 8>
540 <example 9>
541 Example 9 Input:
542 <request>Your website keeps sending ad-popups that block the entire screen. It took me twenty minutes just to finally find the phone number to call and complain. How can I possibly access my account information with all of these popups? Can you access my account for me, since your website is broken? I need to know what the address is on file.</request>
543 
544 Example 9 Output:
545 <reasoning>The user requests help accessing their web account information.</reasoning>
546 <intent>Support, Feedback, Complaint</intent>
547 </example 9>
548 
549 Remember to always include your classification reasoning before your actual intent output. The reasoning should be enclosed in <reasoning> tags and the intent in <intent> tags. Return only the reasoning and the intent.
550 """.formatted(ticketContents);
551 }
552 ```
553 
554 ```php PHP
555 function classifySupportRequest(string $ticketContents): void
556 {
557 // Define the prompt for the classification task
558 $classificationPrompt = <<<PROMPT
559 You will be acting as a customer support ticket classification system. Your task is to analyze customer support requests and output the appropriate classification intent for each request, along with your reasoning.
560 
561 Here is the customer support request you need to classify:
562 
563 <request>{$ticketContents}</request>
564 
565 Please carefully analyze the above request to determine the customer's core intent and needs. Consider what the customer is asking for has concerns about.
566 
567 First, write out your reasoning and analysis of how to classify this request inside <reasoning> tags.
568 
569 Then, output the appropriate classification label for the request inside a <intent> tag. The valid intents are:
570 <intents>
571 <intent>Support, Feedback, Complaint</intent>
572 <intent>Order Tracking</intent>
573 <intent>Refund/Exchange</intent>
574 </intents>
575 
576 A request may have ONLY ONE applicable intent. Only include the intent that is most applicable to the request.
577 
578 As an example, consider the following request:
579 <request>Hello! I had high-speed fiber internet installed on Saturday and my installer, Kevin, was absolutely fantastic! Where can I send my positive review? Thanks for your help!</request>
580 
581 Here is an example of how your output should be formatted (for the above example request):
582 <reasoning>The user seeks information in order to leave positive feedback.</reasoning>
583 <intent>Support, Feedback, Complaint</intent>
584 
585 Here are a few more examples:
586 <examples>
587 <example 2>
588 Example 2 Input:
589 <request>I wanted to write and personally thank you for the compassion you showed towards my family during my father's funeral this past weekend. Your staff was so considerate and helpful throughout this whole process; it really took a load off our shoulders. The visitation brochures were beautiful. We'll never forget the kindness you showed us and we are so appreciative of how smoothly the proceedings went. Thank you, again, Amarantha Hill on behalf of the Hill Family.</request>
590 
591 Example 2 Output:
592 <reasoning>User leaves a positive review of their experience.</reasoning>
593 <intent>Support, Feedback, Complaint</intent>
594 </example 2>
595 <example 3>
596 
597 […]
598 
599 </example 8>
600 <example 9>
601 Example 9 Input:
602 <request>Your website keeps sending ad-popups that block the entire screen. It took me twenty minutes just to finally find the phone number to call and complain. How can I possibly access my account information with all of these popups? Can you access my account for me, since your website is broken? I need to know what the address is on file.</request>
603 
604 Example 9 Output:
605 <reasoning>The user requests help accessing their web account information.</reasoning>
606 <intent>Support, Feedback, Complaint</intent>
607 </example 9>
608 
609 Remember to always include your classification reasoning before your actual intent output. The reasoning should be enclosed in <reasoning> tags and the intent in <intent> tags. Return only the reasoning and the intent.
610 PROMPT;
611 }
612 ```
613 
614 ```ruby Ruby
615 def classify_support_request(ticket_contents)
254616 # Define the prompt for the classification task
255 classification_prompt = f"""You will be acting as a customer support ticket classification system. Your task is to analyze customer support requests and output the appropriate classification intent for each request, along with your reasoning.
256 
257 Here is the customer support request you need to classify:
258 
259 <request>{ticket_contents}</request>
260 
261 Please carefully analyze the above request to determine the customer's core intent and needs. Consider what the customer is asking for has concerns about.
262 
263 First, write out your reasoning and analysis of how to classify this request inside <reasoning> tags.
264 
265 Then, output the appropriate classification label for the request inside a <intent> tag. The valid intents are:
266 <intents>
267 <intent>Support, Feedback, Complaint</intent>
268 <intent>Order Tracking</intent>
269 <intent>Refund/Exchange</intent>
270 </intents>
271 
272 A request may have ONLY ONE applicable intent. Only include the intent that is most applicable to the request.
273 
274 As an example, consider the following request:
275 <request>Hello! I had high-speed fiber internet installed on Saturday and my installer, Kevin, was absolutely fantastic! Where can I send my positive review? Thanks for your help!</request>
276 
277 Here is an example of how your output should be formatted (for the above example request):
278 <reasoning>The user seeks information in order to leave positive feedback.</reasoning>
279 <intent>Support, Feedback, Complaint</intent>
280 
281 Here are a few more examples:
282 <examples>
283 <example 2>
284 Example 2 Input:
285 <request>I wanted to write and personally thank you for the compassion you showed towards my family during my father's funeral this past weekend. Your staff was so considerate and helpful throughout this whole process; it really took a load off our shoulders. The visitation brochures were beautiful. We'll never forget the kindness you showed us and we are so appreciative of how smoothly the proceedings went. Thank you, again, Amarantha Hill on behalf of the Hill Family.</request>
286 
287 Example 2 Output:
288 <reasoning>User leaves a positive review of their experience.</reasoning>
289 <intent>Support, Feedback, Complaint</intent>
290 </example 2>
291 <example 3>
292 
293 ...
294 
295 </example 8>
296 <example 9>
297 Example 9 Input:
298 <request>Your website keeps sending ad-popups that block the entire screen. It took me twenty minutes just to finally find the phone number to call and complain. How can I possibly access my account information with all of these popups? Can you access my account for me, since your website is broken? I need to know what the address is on file.</request>
299 
300 Example 9 Output:
301 <reasoning>The user requests help accessing their web account information.</reasoning>
302 <intent>Support, Feedback, Complaint</intent>
303 </example 9>
304 
305 Remember to always include your classification reasoning before your actual intent output. The reasoning should be enclosed in <reasoning> tags and the intent in <intent> tags. Return only the reasoning and the intent.
306 """
307```
617 classification_prompt = <<~PROMPT
618 You will be acting as a customer support ticket classification system. Your task is to analyze customer support requests and output the appropriate classification intent for each request, along with your reasoning.
619 
620 Here is the customer support request you need to classify:
621 
622 <request>#{ticket_contents}</request>
623 
624 Please carefully analyze the above request to determine the customer's core intent and needs. Consider what the customer is asking for has concerns about.
625 
626 First, write out your reasoning and analysis of how to classify this request inside <reasoning> tags.
627 
628 Then, output the appropriate classification label for the request inside a <intent> tag. The valid intents are:
629 <intents>
630 <intent>Support, Feedback, Complaint</intent>
631 <intent>Order Tracking</intent>
632 <intent>Refund/Exchange</intent>
633 </intents>
634 
635 A request may have ONLY ONE applicable intent. Only include the intent that is most applicable to the request.
636 
637 As an example, consider the following request:
638 <request>Hello! I had high-speed fiber internet installed on Saturday and my installer, Kevin, was absolutely fantastic! Where can I send my positive review? Thanks for your help!</request>
639 
640 Here is an example of how your output should be formatted (for the above example request):
641 <reasoning>The user seeks information in order to leave positive feedback.</reasoning>
642 <intent>Support, Feedback, Complaint</intent>
643 
644 Here are a few more examples:
645 <examples>
646 <example 2>
647 Example 2 Input:
648 <request>I wanted to write and personally thank you for the compassion you showed towards my family during my father's funeral this past weekend. Your staff was so considerate and helpful throughout this whole process; it really took a load off our shoulders. The visitation brochures were beautiful. We'll never forget the kindness you showed us and we are so appreciative of how smoothly the proceedings went. Thank you, again, Amarantha Hill on behalf of the Hill Family.</request>
649 
650 Example 2 Output:
651 <reasoning>User leaves a positive review of their experience.</reasoning>
652 <intent>Support, Feedback, Complaint</intent>
653 </example 2>
654 <example 3>
655 
656 […]
657 
658 </example 8>
659 <example 9>
660 Example 9 Input:
661 <request>Your website keeps sending ad-popups that block the entire screen. It took me twenty minutes just to finally find the phone number to call and complain. How can I possibly access my account information with all of these popups? Can you access my account for me, since your website is broken? I need to know what the address is on file.</request>
662 
663 Example 9 Output:
664 <reasoning>The user requests help accessing their web account information.</reasoning>
665 <intent>Support, Feedback, Complaint</intent>
666 </example 9>
667 
668 Remember to always include your classification reasoning before your actual intent output. The reasoning should be enclosed in <reasoning> tags and the intent in <intent> tags. Return only the reasoning and the intent.
669 PROMPT
670 end
671 ```
672</CodeGroup>
308673 
309674<Note>
310675 This prompt is written for Claude Haiku 5.5, which runs here at `low` effort. On Claude Fable 5.1, Claude Fable 5, Claude Opus 5.5, Claude Opus 5, and Claude Sonnet 5.5, ask for the intent and a one-sentence summary of the request instead. See [Keep reasoning in thinking blocks](https://platform.claude.com/docs/en/build-with-claude/refusals-and-fallback#keep-reasoning-in-thinking-blocks).
from line 677
312677 
313678Here are the key components of this prompt:
314679 
315* The prompt template is a Python f-string, allowing the `ticket_contents` to be inserted into the `<request>` tags.
680* The prompt template inserts `ticket_contents` (typescript, csharp, go, java: `ticketContents`; php: `$ticketContents`) into the `<request>` tags.
316681* The prompt gives Claude a clearly defined role as a classification system that carefully analyzes the ticket content to determine the customer's core intent and needs.
317682* The prompt instructs Claude on proper output formatting, in this case to provide its reasoning and analysis inside `<reasoning>` tags, followed by the appropriate classification label inside `<intent>` tags.
318683* The prompt specifies the valid intent categories: "Support, Feedback, Complaint", "Order Tracking", and "Refund/Exchange".
from line 689
324689 
325690It’s hard to know how well your prompt works without deploying it in a test production setting and [running evaluations](https://platform.claude.com/docs/en/test-and-evaluate/develop-tests).
326691 
327Build the deployment structure. Start by defining the method signature for wrapping the call to Claude. Extend the method you began writing earlier, which takes `ticket_contents` as input, so that it now returns a tuple of `reasoning` and `intent` as output. If you have an existing automation using traditional ML, you'll want to follow that method signature instead.
328 
329```python Python
330import re
331 
332# Create an instance of the Claude API client
333client = anthropic.Anthropic()
334 
335# Set the default model
336DEFAULT_MODEL = "claude-haiku-5-5"
337 
338 
339def classify_support_request(ticket_contents):
692Build the deployment structure. Start by defining the method signature for wrapping the call to Claude. Extend the method you began writing earlier, which takes `ticket_contents` (typescript, csharp, go, java: `ticketContents`; php: `$ticketContents`) as input, so that it now returns the reasoning and the intent as output. If you have an existing automation using traditional ML, you'll want to follow that method signature instead.
693 
694<CodeGroup exclude="shell">
695 <CodeGroupItem language="cURL">
696 This workflow needs more logic than a single shell command. Use the Claude SDK to run it.
697 </CodeGroupItem>
698 
699 <CodeGroupItem language="CLI">
700 This workflow needs more logic than a single shell command. Use the Claude SDK to run it.
701 </CodeGroupItem>
702 
703 ```python Python
704 import re
705 
706 # Create an instance of the Claude API client
707 client = anthropic.Anthropic()
708 
709 # Set the default model
710 DEFAULT_MODEL = "claude-haiku-5-5"
711 
712 
713 def classify_support_request(ticket_contents):
714 # Define the prompt for the classification task
715 classification_prompt = f"""You will be acting as a customer support ticket classification system.
716 […]
717 ... The reasoning should be enclosed in <reasoning> tags and the intent in <intent> tags. Return only the reasoning and the intent.
718 """
719 # Send the prompt to the API to classify the support request.
720 message = client.messages.create(
721 model=DEFAULT_MODEL,
722 max_tokens=2048,
723 output_config={"effort": "low"},
724 messages=[{"role": "user", "content": classification_prompt}],
725 stream=False,
726 )
727 reasoning_and_intent = next(
728 (block.text for block in message.content if block.type == "text"), ""
729 )
730 
731 # Use Python's regular expressions library to extract `reasoning`.
732 reasoning_match = re.search(
733 r"<reasoning>(.*?)</reasoning>", reasoning_and_intent, re.DOTALL
734 )
735 reasoning = reasoning_match.group(1).strip() if reasoning_match else ""
736 
737 # Similarly, also extract the `intent`.
738 intent_match = re.search(r"<intent>(.*?)</intent>", reasoning_and_intent, re.DOTALL)
739 intent = intent_match.group(1).strip() if intent_match else ""
740 
741 return reasoning, intent
742 ```
743 
744 ```typescript TypeScript
745 // Create an instance of the Claude API client
746 const client = new Anthropic();
747 
748 // Set the default model
749 const DEFAULT_MODEL = "claude-haiku-5-5";
750 
751 async function classifySupportRequest(
752 ticketContents: string
753 ): Promise<{ reasoning: string; intent: string }> {
754 // Define the prompt for the classification task
755 const classificationPrompt = `You will be acting as a customer support ticket classification system.
756 […]
757 ... The reasoning should be enclosed in <reasoning> tags and the intent in <intent> tags. Return only the reasoning and the intent.
758 `;
759 // Send the prompt to the API to classify the support request.
760 const message = await client.messages.create({
761 model: DEFAULT_MODEL,
762 max_tokens: 2048,
763 output_config: { effort: "low" },
764 messages: [{ role: "user", content: classificationPrompt }]
765 });
766 const textBlock = message.content.find(
767 (block): block is Anthropic.TextBlock => block.type === "text"
768 );
769 const reasoningAndIntent = textBlock?.text ?? "";
770 
771 // Use a regular expression to extract `reasoning`.
772 const reasoningMatch = /<reasoning>(.*?)<\/reasoning>/s.exec(reasoningAndIntent);
773 const reasoning = reasoningMatch?.[1].trim() ?? "";
774 
775 // Similarly, also extract the `intent`.
776 const intentMatch = /<intent>(.*?)<\/intent>/s.exec(reasoningAndIntent);
777 const intent = intentMatch?.[1].trim() ?? "";
778 
779 return { reasoning, intent };
780 }
781 ```
782 
783 ```csharp C#
784 using System.Text.RegularExpressions;
785 // ...
786 
787 // Create an instance of the Claude API client
788 AnthropicClient client = new();
789 
790 // Set the default model
791 const Model DefaultModel = Model.ClaudeHaiku5_5;
792 
793 async Task<(string Reasoning, string Intent)> ClassifySupportRequest(string ticketContents)
794 {
795 // Define the prompt for the classification task
796 var classificationPrompt = """
797 You will be acting as a customer support ticket classification system.
798 […]
799 ... The reasoning should be enclosed in <reasoning> tags and the intent in <intent> tags. Return only the reasoning and the intent.
800 """;
801 // Send the prompt to the API to classify the support request.
802 var message = await client.Messages.Create(new MessageCreateParams
803 {
804 Model = DefaultModel,
805 MaxTokens = 2048,
806 OutputConfig = new OutputConfig { Effort = Effort.Low },
807 Messages = [new() { Role = Role.User, Content = classificationPrompt }],
808 });
809 var reasoningAndIntent = "";
810 foreach (var block in message.Content)
811 {
812 if (block.TryPickText(out var textBlock))
813 {
814 reasoningAndIntent = textBlock.Text;
815 break;
816 }
817 }
818 
819 // Use a regular expression to extract `reasoning`.
820 var reasoningMatch = Regex.Match(reasoningAndIntent, "<reasoning>(.*?)</reasoning>", RegexOptions.Singleline);
821 var reasoning = reasoningMatch.Success ? reasoningMatch.Groups[1].Value.Trim() : "";
822 
823 // Similarly, also extract the `intent`.
824 var intentMatch = Regex.Match(reasoningAndIntent, "<intent>(.*?)</intent>", RegexOptions.Singleline);
825 var intent = intentMatch.Success ? intentMatch.Groups[1].Value.Trim() : "";
826 
827 return (reasoning, intent);
828 }
829 ```
830 
831 ```go Go
832 import (
833 "context"
834 "regexp"
835 "strings"
836 // ...
837 )
838 
839 // Create an instance of the Claude API client
840 var client = anthropic.NewClient()
841 
842 // Set the default model
843 const defaultModel = anthropic.ModelClaudeHaiku5_5
844 
845 func classifySupportRequest(ctx context.Context, ticketContents string) (reasoning, intent string, err error) {
846 // Define the prompt for the classification task
847 classificationPrompt := `You will be acting as a customer support ticket classification system.
848 […]
849 ... The reasoning should be enclosed in <reasoning> tags and the intent in <intent> tags. Return only the reasoning and the intent.
850 `
851 // Send the prompt to the API to classify the support request.
852 message, err := client.Messages.New(ctx, anthropic.MessageNewParams{
853 Model: defaultModel,
854 MaxTokens: 2048,
855 OutputConfig: anthropic.OutputConfigParam{Effort: anthropic.OutputConfigEffortLow},
856 Messages: []anthropic.MessageParam{
857 anthropic.NewUserMessage(anthropic.NewTextBlock(classificationPrompt)),
858 },
859 })
860 if err != nil {
861 return "", "", err
862 }
863 var reasoningAndIntent string
864 for _, block := range message.Content {
865 if textBlock, ok := block.AsAny().(anthropic.TextBlock); ok {
866 reasoningAndIntent = textBlock.Text
867 break
868 }
869 }
870 
871 // Use a regular expression to extract `reasoning`.
872 reasoningMatch := regexp.MustCompile(`(?s)<reasoning>(.*?)</reasoning>`).FindStringSubmatch(reasoningAndIntent)
873 if reasoningMatch != nil {
874 reasoning = strings.TrimSpace(reasoningMatch[1])
875 }
876 
877 // Similarly, also extract the `intent`.
878 intentMatch := regexp.MustCompile(`(?s)<intent>(.*?)</intent>`).FindStringSubmatch(reasoningAndIntent)
879 if intentMatch != nil {
880 intent = strings.TrimSpace(intentMatch[1])
881 }
882 
883 return reasoning, intent, nil
884 }
885 ```
886 
887 ```java Java
888 import java.util.regex.Matcher;
889 import java.util.regex.Pattern;
890 
891 // Create an instance of the Claude API client
892 final AnthropicClient client = AnthropicOkHttpClient.fromEnv();
893 
894 // Set the default model
895 static final Model DEFAULT_MODEL = Model.CLAUDE_HAIKU_5_5;
896 
897 record Classification(String reasoning, String intent) {}
898 
899 Classification classifySupportRequest(String ticketContents) {
900 // Define the prompt for the classification task
901 String classificationPrompt = """
902 You will be acting as a customer support ticket classification system.
903 […]
904 ... The reasoning should be enclosed in <reasoning> tags and the intent in <intent> tags. Return only the reasoning and the intent.
905 """;
906 // Send the prompt to the API to classify the support request.
907 Message message = client.messages().create(MessageCreateParams.builder()
908 .model(DEFAULT_MODEL)
909 .maxTokens(2048L)
910 .outputConfig(OutputConfig.builder().effort(OutputConfig.Effort.LOW).build())
911 .addUserMessage(classificationPrompt)
912 .build());
913 String reasoningAndIntent = message.content().stream()
914 .flatMap(block -> block.text().stream())
915 .map(textBlock -> textBlock.text())
916 .findFirst()
917 .orElse("");
918 
919 // Use a regular expression to extract `reasoning`.
920 Matcher reasoningMatch = Pattern.compile("<reasoning>(.*?)</reasoning>", Pattern.DOTALL)
921 .matcher(reasoningAndIntent);
922 String reasoning = reasoningMatch.find() ? reasoningMatch.group(1).strip() : "";
923 
924 // Similarly, also extract the `intent`.
925 Matcher intentMatch = Pattern.compile("<intent>(.*?)</intent>", Pattern.DOTALL)
926 .matcher(reasoningAndIntent);
927 String intent = intentMatch.find() ? intentMatch.group(1).strip() : "";
928 
929 return new Classification(reasoning, intent);
930 }
931 ```
932 
933 ```php PHP
934 // Create an instance of the Claude API client
935 $client = new Client();
936 
937 // Set the default model
938 const DEFAULT_MODEL = Model::CLAUDE_HAIKU_5_5;
939 
940 /**
941 * @return array{string, string} the reasoning and the intent
942 */
943 function classifySupportRequest(Client $client, string $ticketContents): array
944 {
945 // Define the prompt for the classification task
946 $classificationPrompt = <<<PROMPT
947 You will be acting as a customer support ticket classification system.
948 […]
949 ... The reasoning should be enclosed in <reasoning> tags and the intent in <intent> tags. Return only the reasoning and the intent.
950 PROMPT;
951 // Send the prompt to the API to classify the support request.
952 $message = $client->messages->create(
953 model: DEFAULT_MODEL,
954 maxTokens: 2048,
955 outputConfig: ['effort' => 'low'],
956 messages: [['role' => 'user', 'content' => $classificationPrompt]],
957 );
958 $reasoningAndIntent = '';
959 foreach ($message->content as $block) {
960 if ($block instanceof \Anthropic\Messages\TextBlock) {
961 $reasoningAndIntent = $block->text;
962 break;
963 }
964 }
965 
966 // Use a regular expression to extract `reasoning`.
967 $reasoning = preg_match('/<reasoning>(.*?)<\/reasoning>/s', $reasoningAndIntent, $reasoningMatch)
968 ? trim($reasoningMatch[1])
969 : '';
970 
971 // Similarly, also extract the `intent`.
972 $intent = preg_match('/<intent>(.*?)<\/intent>/s', $reasoningAndIntent, $intentMatch)
973 ? trim($intentMatch[1])
974 : '';
975 
976 return [$reasoning, $intent];
977 }
978 ```
979 
980 ```ruby Ruby
981 # Create an instance of the Claude API client
982 client = Anthropic::Client.new
983 
984 # Set the default model
985 DEFAULT_MODEL = Anthropic::Model::CLAUDE_HAIKU_5_5
986 
987 def classify_support_request(client, ticket_contents)
340988 # Define the prompt for the classification task
341 classification_prompt = f"""You will be acting as a customer support ticket classification system.
342 ...
343 ... The reasoning should be enclosed in <reasoning> tags and the intent in <intent> tags. Return only the reasoning and the intent.
344 """
989 classification_prompt = <<~PROMPT
990 You will be acting as a customer support ticket classification system.
991 […]
992 ... The reasoning should be enclosed in <reasoning> tags and the intent in <intent> tags. Return only the reasoning and the intent.
993 PROMPT
345994 # Send the prompt to the API to classify the support request.
346995 message = client.messages.create(
347 model=DEFAULT_MODEL,
348 max_tokens=2048,
349 output_config={"effort": "low"},
350 messages=[{"role": "user", "content": classification_prompt}],
351 stream=False,
996 model: DEFAULT_MODEL,
997 max_tokens: 2048,
998 output_config: { effort: "low" },
999 messages: [{ role: "user", content: classification_prompt }]
3521000 )
353 reasoning_and_intent = next(
354 (block.text for block in message.content if block.type == "text"), ""
355 )
356 
357 # Use Python's regular expressions library to extract `reasoning`.
358 reasoning_match = re.search(
359 r"<reasoning>(.*?)</reasoning>", reasoning_and_intent, re.DOTALL
360 )
361 reasoning = reasoning_match.group(1).strip() if reasoning_match else ""
1001 reasoning_and_intent = message.content.grep(Anthropic::Models::TextBlock).first&.text || ""
1002 
1003 # Use a regular expression to extract `reasoning`.
1004 reasoning = reasoning_and_intent[%r{<reasoning>(.*?)</reasoning>}m, 1]&.strip || ""
3621005 
3631006 # Similarly, also extract the `intent`.
364 intent_match = re.search(r"<intent>(.*?)</intent>", reasoning_and_intent, re.DOTALL)
365 intent = intent_match.group(1).strip() if intent_match else ""
366 
367 return reasoning, intent
368```
1007 intent = reasoning_and_intent[%r{<intent>(.*?)</intent>}m, 1]&.strip || ""
1008 
1009 [reasoning, intent]
1010 end
1011 ```
1012</CodeGroup>
3691013 
3701014This code:
3711015 
3721016* Creates a client instance using your API key.
373* Defines a `classify_support_request` function that takes a `ticket_contents` string.
374* Sends the `ticket_contents` to Claude for classification using the `classification_prompt`.
375* Returns the model's `reasoning` and `intent` extracted from the response.
376 
377Because the entire reasoning and intent text must be generated before parsing, the example sets `stream=False` (the default).
1017* Defines a `classify_support_request` (typescript, go, java, php: `classifySupportRequest`; csharp: `ClassifySupportRequest`) function that takes a `ticket_contents` (typescript, csharp, go, java: `ticketContents`; php: `$ticketContents`) string.
1018* Sends the `ticket_contents` (typescript, csharp, go, java: `ticketContents`; php: `$ticketContents`) to Claude for classification using the `classification_prompt` (typescript, csharp, go, java: `classificationPrompt`; php: `$classificationPrompt`).
1019* Returns the model's reasoning and intent extracted from the response.
1020 
1021Because the entire reasoning and intent text must be generated before parsing, the example does not stream the response.
3781022 
3791023***
3801024 
from line 1039
3951039 
3961040To assess this, first modify the script to add a function that compares the predicted intent with the actual intent and calculates the percentage of correct predictions. Then add cost calculation and time measurement functionality.
3971041 
398```python Python
399import re
400 
401# Create an instance of the Claude API client
402client = anthropic.Anthropic()
403 
404# Set the default model
405DEFAULT_MODEL = "claude-haiku-5-5"
406 
407 
408def classify_support_request(request, actual_intent):
1042<CodeGroup exclude="shell">
1043 <CodeGroupItem language="cURL">
1044 This workflow needs more logic than a single shell command. Use the Claude SDK to run it.
1045 </CodeGroupItem>
1046 
1047 <CodeGroupItem language="CLI">
1048 This workflow needs more logic than a single shell command. Use the Claude SDK to run it.
1049 </CodeGroupItem>
1050 
1051 ```python Python
1052 import re
1053 
1054 # Create an instance of the Claude API client
1055 client = anthropic.Anthropic()
1056 
1057 # Set the default model
1058 DEFAULT_MODEL = "claude-haiku-5-5"
1059 
1060 
1061 def classify_support_request(request, actual_intent):
1062 # Define the prompt for the classification task
1063 classification_prompt = f"""You will be acting as a customer support ticket classification system.
1064 […]
1065 ...The reasoning should be enclosed in <reasoning> tags and the intent in <intent> tags. Return only the reasoning and the intent.
1066 """
1067 
1068 message = client.messages.create(
1069 model=DEFAULT_MODEL,
1070 max_tokens=2048,
1071 output_config={"effort": "low"},
1072 messages=[{"role": "user", "content": classification_prompt}],
1073 )
1074 usage = message.usage # Get the usage statistics for the API call for how many input and output tokens were used.
1075 reasoning_and_intent = next(
1076 (block.text for block in message.content if block.type == "text"), ""
1077 )
1078 
1079 # Use Python's regular expressions library to extract `reasoning`.
1080 reasoning_match = re.search(
1081 r"<reasoning>(.*?)</reasoning>", reasoning_and_intent, re.DOTALL
1082 )
1083 reasoning = reasoning_match.group(1).strip() if reasoning_match else ""
1084 
1085 # Similarly, also extract the `intent`.
1086 intent_match = re.search(r"<intent>(.*?)</intent>", reasoning_and_intent, re.DOTALL)
1087 intent = intent_match.group(1).strip() if intent_match else ""
1088 
1089 # Check if the model's prediction is correct.
1090 correct = actual_intent.strip() == intent.strip()
1091 
1092 # Return the reasoning, intent, correct, and usage.
1093 return reasoning, intent, correct, usage
1094 ```
1095 
1096 ```typescript TypeScript
1097 // Create an instance of the Claude API client
1098 const client = new Anthropic();
1099 
1100 // Set the default model
1101 const DEFAULT_MODEL = "claude-haiku-5-5";
1102 
1103 async function classifySupportRequest(
1104 request: string,
1105 actualIntent: string
1106 ): Promise<{ reasoning: string; intent: string; correct: boolean; usage: Anthropic.Usage }> {
1107 // Define the prompt for the classification task
1108 const classificationPrompt = `You will be acting as a customer support ticket classification system.
1109 […]
1110 ...The reasoning should be enclosed in <reasoning> tags and the intent in <intent> tags. Return only the reasoning and the intent.
1111 `;
1112 
1113 const message = await client.messages.create({
1114 model: DEFAULT_MODEL,
1115 max_tokens: 2048,
1116 output_config: { effort: "low" },
1117 messages: [{ role: "user", content: classificationPrompt }]
1118 });
1119 // Get the usage statistics for the API call for how many input and output tokens were used.
1120 const usage = message.usage;
1121 const textBlock = message.content.find(
1122 (block): block is Anthropic.TextBlock => block.type === "text"
1123 );
1124 const reasoningAndIntent = textBlock?.text ?? "";
1125 
1126 // Use a regular expression to extract `reasoning`.
1127 const reasoningMatch = /<reasoning>(.*?)<\/reasoning>/s.exec(reasoningAndIntent);
1128 const reasoning = reasoningMatch?.[1].trim() ?? "";
1129 
1130 // Similarly, also extract the `intent`.
1131 const intentMatch = /<intent>(.*?)<\/intent>/s.exec(reasoningAndIntent);
1132 const intent = intentMatch?.[1].trim() ?? "";
1133 
1134 // Check if the model's prediction is correct.
1135 const correct = actualIntent.trim() === intent.trim();
1136 
1137 // Return the reasoning, intent, correct, and usage.
1138 return { reasoning, intent, correct, usage };
1139 }
1140 ```
1141 
1142 ```csharp C#
1143 using System.Text.RegularExpressions;
1144 // ...
1145 
1146 // Create an instance of the Claude API client
1147 AnthropicClient client = new();
1148 
1149 // Set the default model
1150 const Model DefaultModel = Model.ClaudeHaiku5_5;
1151 
1152 async Task<(string Reasoning, string Intent, bool Correct, Usage Usage)> ClassifySupportRequest(string request, string actualIntent)
1153 {
1154 // Define the prompt for the classification task
1155 var classificationPrompt = """
1156 You will be acting as a customer support ticket classification system.
1157 […]
1158 ...The reasoning should be enclosed in <reasoning> tags and the intent in <intent> tags. Return only the reasoning and the intent.
1159 """;
1160 
1161 var message = await client.Messages.Create(new MessageCreateParams
1162 {
1163 Model = DefaultModel,
1164 MaxTokens = 2048,
1165 OutputConfig = new OutputConfig { Effort = Effort.Low },
1166 Messages = [new() { Role = Role.User, Content = classificationPrompt }],
1167 });
1168 // Get the usage statistics for the API call for how many input and output tokens were used.
1169 var usage = message.Usage;
1170 var reasoningAndIntent = "";
1171 foreach (var block in message.Content)
1172 {
1173 if (block.TryPickText(out var textBlock))
1174 {
1175 reasoningAndIntent = textBlock.Text;
1176 break;
1177 }
1178 }
1179 
1180 // Use a regular expression to extract `reasoning`.
1181 var reasoningMatch = Regex.Match(reasoningAndIntent, "<reasoning>(.*?)</reasoning>", RegexOptions.Singleline);
1182 var reasoning = reasoningMatch.Success ? reasoningMatch.Groups[1].Value.Trim() : "";
1183 
1184 // Similarly, also extract the `intent`.
1185 var intentMatch = Regex.Match(reasoningAndIntent, "<intent>(.*?)</intent>", RegexOptions.Singleline);
1186 var intent = intentMatch.Success ? intentMatch.Groups[1].Value.Trim() : "";
1187 
1188 // Check if the model's prediction is correct.
1189 var correct = actualIntent.Trim() == intent.Trim();
1190 
1191 // Return the reasoning, intent, correct, and usage.
1192 return (reasoning, intent, correct, usage);
1193 }
1194 ```
1195 
1196 ```go Go
1197 import (
1198 "context"
1199 "regexp"
1200 "strings"
1201 // ...
1202 )
1203 
1204 // Create an instance of the Claude API client
1205 var client = anthropic.NewClient()
1206 
1207 // Set the default model
1208 const defaultModel = anthropic.ModelClaudeHaiku5_5
1209 
1210 func classifySupportRequest(ctx context.Context, request, actualIntent string) (reasoning, intent string, correct bool, usage anthropic.Usage, err error) {
1211 // Define the prompt for the classification task
1212 classificationPrompt := `You will be acting as a customer support ticket classification system.
1213 […]
1214 ...The reasoning should be enclosed in <reasoning> tags and the intent in <intent> tags. Return only the reasoning and the intent.
1215 `
1216 message, err := client.Messages.New(ctx, anthropic.MessageNewParams{
1217 Model: defaultModel,
1218 MaxTokens: 2048,
1219 OutputConfig: anthropic.OutputConfigParam{Effort: anthropic.OutputConfigEffortLow},
1220 Messages: []anthropic.MessageParam{
1221 anthropic.NewUserMessage(anthropic.NewTextBlock(classificationPrompt)),
1222 },
1223 })
1224 if err != nil {
1225 return "", "", false, anthropic.Usage{}, err
1226 }
1227 // Get the usage statistics for the API call for how many input and output tokens were used.
1228 usage = message.Usage
1229 var reasoningAndIntent string
1230 for _, block := range message.Content {
1231 if textBlock, ok := block.AsAny().(anthropic.TextBlock); ok {
1232 reasoningAndIntent = textBlock.Text
1233 break
1234 }
1235 }
1236 
1237 // Use a regular expression to extract `reasoning`.
1238 reasoningMatch := regexp.MustCompile(`(?s)<reasoning>(.*?)</reasoning>`).FindStringSubmatch(reasoningAndIntent)
1239 if reasoningMatch != nil {
1240 reasoning = strings.TrimSpace(reasoningMatch[1])
1241 }
1242 
1243 // Similarly, also extract the `intent`.
1244 intentMatch := regexp.MustCompile(`(?s)<intent>(.*?)</intent>`).FindStringSubmatch(reasoningAndIntent)
1245 if intentMatch != nil {
1246 intent = strings.TrimSpace(intentMatch[1])
1247 }
1248 
1249 // Check if the model's prediction is correct.
1250 correct = strings.TrimSpace(actualIntent) == strings.TrimSpace(intent)
1251 
1252 // Return the reasoning, intent, correct, and usage.
1253 return reasoning, intent, correct, usage, nil
1254 }
1255 ```
1256 
1257 ```java Java
1258 import java.util.regex.Matcher;
1259 import java.util.regex.Pattern;
1260 
1261 // Create an instance of the Claude API client
1262 final AnthropicClient client = AnthropicOkHttpClient.fromEnv();
1263 
1264 // Set the default model
1265 static final Model DEFAULT_MODEL = Model.CLAUDE_HAIKU_5_5;
1266 
1267 record Classification(String reasoning, String intent, boolean correct, Usage usage) {}
1268 
1269 Classification classifySupportRequest(String request, String actualIntent) {
1270 // Define the prompt for the classification task
1271 String classificationPrompt = """
1272 You will be acting as a customer support ticket classification system.
1273 […]
1274 ...The reasoning should be enclosed in <reasoning> tags and the intent in <intent> tags. Return only the reasoning and the intent.
1275 """;
1276 
1277 Message message = client.messages().create(MessageCreateParams.builder()
1278 .model(DEFAULT_MODEL)
1279 .maxTokens(2048L)
1280 .outputConfig(OutputConfig.builder().effort(OutputConfig.Effort.LOW).build())
1281 .addUserMessage(classificationPrompt)
1282 .build());
1283 // Get the usage statistics for the API call for how many input and output tokens were used.
1284 Usage usage = message.usage();
1285 String reasoningAndIntent = message.content().stream()
1286 .flatMap(block -> block.text().stream())
1287 .map(textBlock -> textBlock.text())
1288 .findFirst()
1289 .orElse("");
1290 
1291 // Use a regular expression to extract `reasoning`.
1292 Matcher reasoningMatch = Pattern.compile("<reasoning>(.*?)</reasoning>", Pattern.DOTALL)
1293 .matcher(reasoningAndIntent);
1294 String reasoning = reasoningMatch.find() ? reasoningMatch.group(1).strip() : "";
1295 
1296 // Similarly, also extract the `intent`.
1297 Matcher intentMatch = Pattern.compile("<intent>(.*?)</intent>", Pattern.DOTALL)
1298 .matcher(reasoningAndIntent);
1299 String intent = intentMatch.find() ? intentMatch.group(1).strip() : "";
1300 
1301 // Check if the model's prediction is correct.
1302 boolean correct = actualIntent.strip().equals(intent.strip());
1303 
1304 // Return the reasoning, intent, correct, and usage.
1305 return new Classification(reasoning, intent, correct, usage);
1306 }
1307 ```
1308 
1309 ```php PHP
1310 // Create an instance of the Claude API client
1311 $client = new Client();
1312 
1313 // Set the default model
1314 const DEFAULT_MODEL = Model::CLAUDE_HAIKU_5_5;
1315 
1316 /**
1317 * @return array{string, string, bool, Usage} the reasoning, the intent, whether the intent is correct, and the usage
1318 */
1319 function classifySupportRequest(Client $client, string $request, string $actualIntent): array
1320 {
1321 // Define the prompt for the classification task
1322 $classificationPrompt = <<<PROMPT
1323 You will be acting as a customer support ticket classification system.
1324 […]
1325 ...The reasoning should be enclosed in <reasoning> tags and the intent in <intent> tags. Return only the reasoning and the intent.
1326 PROMPT;
1327 
1328 $message = $client->messages->create(
1329 model: DEFAULT_MODEL,
1330 maxTokens: 2048,
1331 outputConfig: ['effort' => 'low'],
1332 messages: [['role' => 'user', 'content' => $classificationPrompt]],
1333 );
1334 // Get the usage statistics for the API call for how many input and output tokens were used.
1335 $usage = $message->usage;
1336 $reasoningAndIntent = '';
1337 foreach ($message->content as $block) {
1338 if ($block instanceof \Anthropic\Messages\TextBlock) {
1339 $reasoningAndIntent = $block->text;
1340 break;
1341 }
1342 }
1343 
1344 // Use a regular expression to extract `reasoning`.
1345 $reasoning = preg_match('/<reasoning>(.*?)<\/reasoning>/s', $reasoningAndIntent, $reasoningMatch)
1346 ? trim($reasoningMatch[1])
1347 : '';
1348 
1349 // Similarly, also extract the `intent`.
1350 $intent = preg_match('/<intent>(.*?)<\/intent>/s', $reasoningAndIntent, $intentMatch)
1351 ? trim($intentMatch[1])
1352 : '';
1353 
1354 // Check if the model's prediction is correct.
1355 $correct = trim($actualIntent) === trim($intent);
1356 
1357 // Return the reasoning, intent, correct, and usage.
1358 return [$reasoning, $intent, $correct, $usage];
1359 }
1360 ```
1361 
1362 ```ruby Ruby
1363 # Create an instance of the Claude API client
1364 client = Anthropic::Client.new
1365 
1366 # Set the default model
1367 DEFAULT_MODEL = Anthropic::Model::CLAUDE_HAIKU_5_5
1368 
1369 def classify_support_request(client, request, actual_intent)
4091370 # Define the prompt for the classification task
410 classification_prompt = f"""You will be acting as a customer support ticket classification system.
411 ...
412 ...The reasoning should be enclosed in <reasoning> tags and the intent in <intent> tags. Return only the reasoning and the intent.
413 """
1371 classification_prompt = <<~PROMPT
1372 You will be acting as a customer support ticket classification system.
1373 […]
1374 ...The reasoning should be enclosed in <reasoning> tags and the intent in <intent> tags. Return only the reasoning and the intent.
1375 PROMPT
4141376 
4151377 message = client.messages.create(
416 model=DEFAULT_MODEL,
417 max_tokens=2048,
418 output_config={"effort": "low"},
419 messages=[{"role": "user", "content": classification_prompt}],
1378 model: DEFAULT_MODEL,
1379 max_tokens: 2048,
1380 output_config: { effort: "low" },
1381 messages: [{ role: "user", content: classification_prompt }]
4201382 )
421 usage = message.usage # Get the usage statistics for the API call for how many input and output tokens were used.
422 reasoning_and_intent = next(
423 (block.text for block in message.content if block.type == "text"), ""
424 )
425 
426 # Use Python's regular expressions library to extract `reasoning`.
427 reasoning_match = re.search(
428 r"<reasoning>(.*?)</reasoning>", reasoning_and_intent, re.DOTALL
429 )
430 reasoning = reasoning_match.group(1).strip() if reasoning_match else ""
1383 # Get the usage statistics for the API call for how many input and output tokens were used.
1384 usage = message.usage
1385 reasoning_and_intent = message.content.grep(Anthropic::Models::TextBlock).first&.text || ""
1386 
1387 # Use a regular expression to extract `reasoning`.
1388 reasoning = reasoning_and_intent[%r{<reasoning>(.*?)</reasoning>}m, 1]&.strip || ""
4311389 
4321390 # Similarly, also extract the `intent`.
433 intent_match = re.search(r"<intent>(.*?)</intent>", reasoning_and_intent, re.DOTALL)
434 intent = intent_match.group(1).strip() if intent_match else ""
1391 intent = reasoning_and_intent[%r{<intent>(.*?)</intent>}m, 1]&.strip || ""
4351392 
4361393 # Check if the model's prediction is correct.
437 correct = actual_intent.strip() == intent.strip()
1394 correct = actual_intent.strip == intent.strip
4381395 
4391396 # Return the reasoning, intent, correct, and usage.
440 return reasoning, intent, correct, usage
441```
1397 [reasoning, intent, correct, usage]
1398 end
1399 ```
1400</CodeGroup>
4421401 
4431402Here is a breakdown of the edits:
4441403 
445* The `classify_support_request` method now takes the `actual_intent` from the test cases and compares it against Claude’s intent classification to assess whether they match.
1404* The `classify_support_request` (typescript, go, java, php: `classifySupportRequest`; csharp: `ClassifySupportRequest`) method now takes the `actual_intent` (typescript, csharp, go, java: `actualIntent`; php: `$actualIntent`) from the test cases and compares it against Claude’s intent classification to assess whether they match.
4461405* The method extracts usage statistics for the API call to calculate cost based on input and output tokens used.
4471406 
4481407### Run your evaluation
4491408 
Feedback