when an request is created send an adoptive card to chat
Loading
when an request is created send an adoptive card to chat
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Tuhin PaulPosted Apr 8, 2026, 11:11 AM
To bridge the gap between a .NET 10 backend and a chat interface (like Microsoft Teams or Slack), the most robust architectural approach is to use an asynchronous, event-driven pattern. This ensures that your API remains responsive while the "Heavy Lifting" of message formatting and delivery happens in the background.
1. The Architecture
Rather than sending the card directly within the request pipeline, use an Internal Domain Event.
Trigger: A POST request hits your FastAPI or .NET endpoint.
Process: Save to the DB, then publish a message to a service bus (Azure Service Bus, RabbitMQ, or MediatR).
Consumer: A background worker picks up the event, constructs the Adaptive Card JSON, and posts it to the Chat Webhook.
2. Implementation (C# 14 / .NET 10)
Using the new Primary Constructors and Raw String Literals makes the JSON construction significantly cleaner.
3. Key Considerations for Production
Resilience: Wrap your webhook call in a Polly retry policy. Chat platforms often rate-limit incoming webhooks if your system spikes in traffic.
Security: Never hardcode the Webhook URL. Use Azure Key Vault or User Secrets to manage the endpoint URI.
Schema Validation: For complex cards, use the
AdaptiveCardsNuGet package to build the card object graph instead of raw JSON. This provides compile-time safety for your UI layout.4. Alternative: The Logic App / Power Automate Route
If you want to keep your microservice "lean," you can simply push a message to an Azure Service Bus queue. You then set up a Logic App with a "When a message is received" trigger that uses the built-in "Post an Adaptive Card" connector. This decouples your C# code entirely from the Chat UI logic.