messaging
The Teams messaging endpoint’s turn: what happens between Azure Bot Service POSTing an activity and a card appearing in the channel.
Split out from conversation.ts because the two callers have genuinely
different contracts. conversation.ts runs a turn and RETURNS the reply, which
is what a direct HTTP caller (or the in-repo preview UI) wants. A real channel
cannot work that way: Bot Service ignores the response body and expects a fast
200, so this module acknowledges first and delivers the reply out-of-band
through the Connector API.
The sequence for a message activity:
- validate the inbound JWT and pin the reply destination to the
token’s
serviceUrl(seeauth.ts); - return
200immediately - Bot Service retries an activity it thinks timed out, and a duplicate turn means a duplicate card; - show the typing indicator, run the agent, and POST the card back.
Step 2 is why this is fire-and-forget rather than awaited: a card-producing agent turn takes seconds to tens of seconds, far longer than the ~15s Bot Service allows a bot to acknowledge.