You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Added a new SVG file for the AWS Converse sequence.
- This visual aid enhances the documentation and understanding
of the integration process.
- The SVG is located in the images directory for easy access.
Generated by Copilot
<p>This article is part of the AWS Bedrock with .NET series. If you haven't already, start with <ahref="/blog/ai/bedrock">Getting Started with AWS Bedrock</a> and <ahref="/blog/ai/bedrock/advanced">Advanced Integration & Production Setup</a> to understand authentication, configuration, and cost optimization before diving into conversational patterns.</p>
21
+
</CalloutBox>
22
+
19
23
<SectionHeading="The Problem: AI That Forgets"Level="4">
20
24
<p>
21
25
Picture a customer contacting your support bot about a billing issue. They explain the problem, the bot asks for their account number, they provide it — and then the next response treats them like a stranger. No memory of the account number. No memory of the issue. The user has to start over.
@@ -85,6 +89,11 @@
85
89
</CalloutBox>
86
90
</Section>
87
91
92
+
<SectionHeading="How the Converse API Flows End to End"Level="4">
93
+
<p>Before we write any code, here's a visual map of the full request lifecycle — from your .NET application calling the SDK, through Bedrock's Converse API, down to the Foundation Model, and back. Notice the <b>multi-turn conversation loop</b> and the <b>tool use</b> opt block — both are native to the Converse API and impossible with InvokeModel.</p>
94
+
<BlogImageImagePath="/images/blog/ai/bedrock/aws-converse-sequence.svg"Description="Sequence diagram: .NET application using AWS Bedrock Converse API with multi-turn conversation loop and tool use"Number="1" />
95
+
</Section>
96
+
88
97
<SectionHeading="How: Building an AI Customer Service Agent with Converse API"Level="4">
89
98
<SectionHeading="1. Prerequisites"Level="5">
90
99
<ul>
@@ -99,12 +108,15 @@
99
108
<CodeSnippetLanguage="csharp">
100
109
using Amazon.BedrockRuntime;
101
110
using Amazon.BedrockRuntime.Model;
111
+
using System;
102
112
using System.Collections.Generic;
103
113
using System.Threading.Tasks;
104
114
105
115
public class BedrockCustomerSupportService
106
116
{
107
117
privatereadonlyAmazonBedrockRuntimeClient_client;
118
+
// NOTE: Verify the latest Claude model ID in the AWS Bedrock console.
119
+
// This example uses Claude 3 Haiku as of Jan 2026 — model IDs may change.
@@ -148,7 +160,7 @@ public class BedrockCustomerSupportService
148
160
}
149
161
</CodeSnippet>
150
162
<CalloutBoxType="tip"Title="Full Example on GitHub">
151
-
<p>See the complete implementation and usage in the <ahref="https://github.com/ajaysskumar/ai-playground/blob/main/AwsBedrockExamples/Services/BedrockCustomerSupportService.cs"target="_blank">BedrockCustomerSupportService.cs</a> file on GitHub.</p>
163
+
<p>See the complete implementation and usage in the <ahref="https://github.com/ajaysskumar/ai-playground/blob/main/AwsBedrockExamples/Services/BedrockCustomerSupportService.cs"target="_blank">BedrockCustomerSupportService.cs</a> file on GitHub. Also refer to the <ahref="/blog/ai/bedrock">Getting Started with AWS Bedrock</a> article for foundational setup and IAM authentication.</p>
152
164
</CalloutBox>
153
165
</Section>
154
166
<SectionHeading="3. How the Example Works"Level="5">
@@ -162,21 +174,23 @@ public class BedrockCustomerSupportService
162
174
<SectionHeading="4. Example Use Case: AI Customer Service Agent"Level="5">
163
175
<p>Suppose a user is troubleshooting an issue with their order. The conversation might look like this:</p>
164
176
<CodeSnippetLanguage="csharp">
165
-
// Example conversation history
177
+
// Example conversation history — showing 5+ turns to demonstrate context retention
166
178
var conversationHistory = new List<Message>
167
179
{
168
-
newMessage{Role="user", Content=newList<ContentBlock>{newContentBlock{Text="My order hasn't arrived yet."}}},
169
-
newMessage{Role="assistant", Content=newList<ContentBlock>{newContentBlock{Text="I'm sorry to hear that. Can you provide your order number?"}}},
newMessage{Role="user", Content=newList<ContentBlock>{newContentBlock{Text="My order hasn't arrived yet. I ordered it last week."}}},
181
+
newMessage{Role="assistant", Content=newList<ContentBlock>{newContentBlock{Text="I'm sorry to hear that. Can you provide your order number? And what's your delivery address region?"}}},
182
+
newMessage{Role="user", Content=newList<ContentBlock>{newContentBlock{Text="It's order 12345, and I'm in the East Coast region."}}},
183
+
newMessage{Role="assistant", Content=newList<ContentBlock>{newContentBlock{Text="Thanks! Order 12345 was shipped 5 days ago to the East Coast. It should arrive within 2-3 days. Would you like me to track it further or escalate this?"}}},
184
+
newMessage{Role="user", Content=newList<ContentBlock>{newContentBlock{Text="Can you escalate this to a human agent? I'm concerned since it's been a week."}}}
171
185
};
172
186
173
187
var service = new BedrockCustomerSupportService();
<p>The AI will respond with a context-aware message, such as confirming the order status or providing next steps.</p>
191
+
<p>Notice how in turn 4, the AI references "Order 12345" and "East Coast region" seamlessly — context from earlier turns. This multi-turn awareness is exactly what Converse API enables. The AI doesn't forget, and the user experience feels natural.</p>
178
192
</Section>
179
-
<SectionHeading="6. Demo: Interactive Customer Support Chat"Level="5">
193
+
<SectionHeading="5. Demo: Interactive Customer Support Chat"Level="5">
180
194
<p>Below is a complete demo of a console-based customer support chat using the Bedrock Converse API. This example shows how to maintain the conversation loop, collect user input, and keep the conversation history updated for each turn.</p>
181
195
<CodeSnippetLanguage="csharp">
182
196
// Customer support chat demo
@@ -238,18 +252,19 @@ public class BedrockCustomerSupportService
238
252
<SectionHeading="Summary"Level="4">
239
253
<ul>
240
254
<li><b>What:</b> The Bedrock Converse API enables multi-turn, context-aware conversations with generative AI models.</li>
241
-
<li><b>When:</b> Use it for chatbots, customer support, and any scenario requiring context retention.</li>
242
-
<li><b>How:</b> Integrate with AWS SDK for .NET and pass conversation history for seamless, intelligent interactions.</li>
255
+
<li><b>When:</b> Use it for chatbots, customer support, and any scenario requiring context retention and continuous dialogue.</li>
256
+
<li><b>How:</b> Integrate with AWS SDK for .NET (.net 8+), maintain conversation history as a list of Message objects, and pass the entire history with each request so the model sees full context.</li>
243
257
</ul>
244
258
<p>
245
-
For more details and the full code, see the <ahref="https://github.com/ajaysskumar/ai-playground/blob/main/AwsBedrockExamples/Services/BedrockCustomerSupportService.cs"target="_blank">GitHub example</a>.
259
+
The beauty of Converse API is its simplicity — you don't need to manage complex state servers or reinvent conversation patterns. AWS handles the heavy lifting, and you focus on building great user experiences.
246
260
</p>
247
261
</Section>
248
262
249
263
<SectionHeading="References & Further Reading"Level="4">
250
264
<ul>
251
-
<li><ahref="https://docs.aws.amazon.com/bedrock/latest/userguide/converse-api.html"target="_blank">AWS Bedrock Converse API Documentation</a></li>
252
-
<li><ahref="https://github.com/ajaysskumar/ai-playground/blob/main/AwsBedrockExamples/Services/BedrockCustomerSupportService.cs"target="_blank">BedrockCustomerSupportService.cs on GitHub</a></li>
265
+
<li><ahref="/blog/ai/bedrock">AWS Bedrock with .NET: Getting Started</a> — foundation article for IAM, authentication, and cost optimization</li>
266
+
<li><ahref="https://docs.aws.amazon.com/bedrock/latest/userguide/converse-api.html"target="_blank">AWS Bedrock Converse API Documentation</a> — official AWS reference</li>
267
+
<li><ahref="https://github.com/ajaysskumar/ai-playground/blob/main/AwsBedrockExamples/Services/BedrockCustomerSupportService.cs"target="_blank">BedrockCustomerSupportService.cs on GitHub</a> — full runnable example</li>
0 commit comments