customer-support-chat changedabout-claude/use-case-guides/customer-support-chat
Nearest release: v2.1.307, published 4 hours after 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+24added
Lines−40removed
From line
660
where the diff opens
First seen
14 Aug 2026
this site's first read of the page
Recorded edits12to this page, all time
The whole hunk
from line 660, old and new numbered
/
from line 660
660660
661661 public async Task<string> ProcessUserInput(string userInput)
662662 {
663 Messages.Add(new() { Role = Role.User, Content = userInput });
663 Messages.Add(new UserMessageParam { Content = userInput });
664664
665665 var responseMessage = await GenerateMessage(Messages, maxTokens: 2048);
666666
from line 668
668668 {
669669 var toolResult = HandleToolUse(toolUse.Name, toolUse.Input);
670670
671 Messages.Add(new()
671 Messages.Add(new AssistantMessageParam
672672 {
673 Role = Role.Assistant,
674673 Content = responseMessage.Content
675674 .Select(contentBlock => new ContentBlockParam(contentBlock.Json))
676675 .ToList(),
677676 });
678 Messages.Add(new()
677 Messages.Add(new UserMessageParam
679678 {
680 Role = Role.User,
681679 Content = new List<ContentBlockParam>
682680 {
683681 new ToolResultBlockParam { ToolUseID = toolUse.ID, Content = toolResult },
from line 688
690688 {
691689 if (block.TryPickText(out var followUpText))
692690 {
693 Messages.Add(new() { Role = Role.Assistant, Content = followUpText.Text });
691 Messages.Add(new AssistantMessageParam { Content = followUpText.Text });
694692 return followUpText.Text;
695693 }
696694 }
from line 700
702700 {
703701 if (block.TryPickText(out var textBlock))
704702 {
705 Messages.Add(new() { Role = Role.Assistant, Content = textBlock.Text });
703 Messages.Add(new AssistantMessageParam { Content = textBlock.Text });
706704 return textBlock.Text;
707705 }
708706 }
from line 857
859857 }
860858
861859 String processUserInput(String userInput) {
862 messages.add(MessageParam.builder()
863 .role(MessageParam.Role.USER)
864 .content(userInput)
865 .build());
860 messages.add(MessageParam.ofUser(userInput));
866861
867862 Message responseMessage = generateMessage(messages, 2048);
868863
from line 869
874869 (Map<String, JsonValue>) toolUse._input().asObject().orElseThrow();
875870 String result = handleToolUse(toolUse.name(), toolInput);
876871
877 messages.add(MessageParam.builder()
878 .role(MessageParam.Role.ASSISTANT)
879 .contentOfBlockParams(content.stream().map(ContentBlock::toParam).toList())
880 .build());
881 messages.add(MessageParam.builder()
882 .role(MessageParam.Role.USER)
883 .contentOfBlockParams(List.of(ContentBlockParam.ofToolResult(
884 ToolResultBlockParam.builder()
885 .toolUseId(toolUse.id())
886 .content(result)
887 .build())))
888 .build());
872 messages.add(MessageParam.ofAssistantOfContentBlockParams(
873 content.stream().map(ContentBlock::toParam).toList()));
874 messages.add(MessageParam.ofUserOfContentBlockParams(List.of(ContentBlockParam.ofToolResult(
875 ToolResultBlockParam.builder()
876 .toolUseId(toolUse.id())
877 .content(result)
878 .build()))));
889879
890880 Message followUpResponse = generateMessage(messages, 2048);
891881
from line 884
894884 .findFirst()
895885 .orElseThrow(() -> new IllegalStateException("An error occurred: Unexpected response type"));
896886 String responseText = followUpBlock.asText().text();
897 messages.add(MessageParam.builder()
898 .role(MessageParam.Role.ASSISTANT)
899 .content(responseText)
900 .build());
887 messages.add(MessageParam.ofAssistant(responseText));
901888 return responseText;
902889 } else {
903890 ContentBlock textBlock = content.stream()
from line 892
905892 .findFirst()
906893 .orElseThrow(() -> new IllegalStateException("An error occurred: Unexpected response type"));
907894 String responseText = textBlock.asText().text();
908 messages.add(MessageParam.builder()
909 .role(MessageParam.Role.ASSISTANT)
910 .content(responseText)
911 .build());
895 messages.add(MessageParam.ofAssistant(responseText));
912896 return responseText;
913897 }
914898 }
from line 916
932916
933917 ```php PHP
934918 use Anthropic\Client;
919 use Anthropic\Messages\AssistantMessageParam;
935920 use Anthropic\Messages\Message;
936 use Anthropic\Messages\MessageParam;
937921 use Anthropic\Messages\TextBlock;
938922 use Anthropic\Messages\ToolResultBlockParam;
939923 use Anthropic\Messages\ToolUseBlock;
924 use Anthropic\Messages\UserMessageParam;
940925
941926 class ChatBot
942927 {
from line 928
943928 // MODEL, IDENTITY, TOOLS, and get_quote() mirror the config.py values
944929 // defined earlier in this guide (shown in Python).
945930
946 /** @var list<MessageParam> */
931 /** @var list<UserMessageParam|AssistantMessageParam> */
947932 public private(set) array $messages = [];
948933
949934 public function __construct(
from line 936
951936 ) {}
952937
953938 /**
954 * @param list<MessageParam> $messages
939 * @param list<UserMessageParam|AssistantMessageParam> $messages
955940 */
956941 public function generateMessage(array $messages, int $maxTokens): Message
957942 {
from line 951
966951
967952 public function processUserInput(string $userInput): string
968953 {
969 $this->messages[] = MessageParam::with(role: 'user', content: $userInput);
954 $this->messages[] = UserMessageParam::with(content: $userInput);
970955
971956 $responseMessage = $this->generateMessage($this->messages, maxTokens: 2048);
972957
from line 961
976961 if ($lastBlock instanceof ToolUseBlock) {
977962 $toolResult = $this->handleToolUse($lastBlock->name, $lastBlock->input);
978963
979 $this->messages[] = MessageParam::with(role: 'assistant', content: $content);
980 $this->messages[] = MessageParam::with(
981 role: 'user',
964 $this->messages[] = AssistantMessageParam::with(content: $content);
965 $this->messages[] = UserMessageParam::with(
982966 content: [
983967 ToolResultBlockParam::with(toolUseID: $lastBlock->id, content: $toolResult),
984968 ],
from line 978
994978 throw new \RuntimeException('An error occurred: Unexpected response type');
995979 }
996980
997 $this->messages[] = MessageParam::with(role: 'assistant', content: $firstBlock->text);
981 $this->messages[] = AssistantMessageParam::with(content: $firstBlock->text);
998982
999983 return $firstBlock->text;
1000984 }
from line 985
1001985
1002986 $firstBlock = array_find($content, static fn ($block): bool => $block instanceof TextBlock);
1003987 if ($firstBlock instanceof TextBlock) {
1004 $this->messages[] = MessageParam::with(role: 'assistant', content: $firstBlock->text);
988 $this->messages[] = AssistantMessageParam::with(content: $firstBlock->text);
1005989
1006990 return $firstBlock->text;
1007991 }
No line in this hunk matches that.