Teams message extension timing out when calling external API during query

Doumbia 60 Reputation points
2025-12-10T09:41:55.4133333+00:00

On a custom Teams message extension that triggers an external API call during the composeExtension/query event, but I’m running into an issue where the request intermittently times out inside Teams even though the same API call works reliably when tested directly from Postman or using my bot endpoint outside Teams.

I’m using Bot Framework SDK (Node.js) with an Azure Function backend, and logs show that the bot receives the invoke request but sometimes never completes the round-trip back to Teams before the 5-second timeout. I’ve already tried reducing payload size, enabling App Insights logging, and moving the API call to a proxy layer, but the behavior is still inconsistent.

Microsoft Teams | Development
Microsoft Teams | Development
Building, integrating, or customizing apps and workflows within Microsoft Teams using developer tools and APIs
{count} votes

Answer accepted by question author
  1. Steven-N 15,160 Reputation points Microsoft External Staff Moderator
    2025-12-10T11:26:56.1866667+00:00

    Hi Doumbia

    Thank you for reaching out to Microsoft Q&A forum

    As far as I know, the root cause of this behavior is Search‑based message extensions are synchronous: when a user types or submits a query, Teams sends an composeExtension/query invoke and expects HTTP 200 within five seconds; if you miss that SLA, the client drops the request and shows “Unable to reach app.” This deadline is not configurable. Timeouts typically occur when the backend experiences cold‑start latency or network/TLS overhead (common on serverless plans), or when the extension spends too long building/returning results. These conditions explain why your direct tests succeed (no strict client SLA and a warmed host) while Teams queries sometimes fail.Link reference: Respond to search command

    Therefore, to mitigate this behavior, you can consider trying below methods:

    1) Response‑first pattern (meet the 5‑second SLA).

    Always return a valid composeExtension response within ~5 seconds, the external API call with a ~4‑second safety timer. If it completes, send real results, otherwise return a lightweight default and offer an Action to continue in a dialog (task module) for long operations. This avoids “Unable to reach app” while still supporting multi‑step work.

    References:

    Create and send dialogs

    Respond to search command

    2) Eliminate cold starts and startup jitter in Azure Functions.

    You can consider hosting the Node.js backend on Azure Functions Premium or Flex Consumption, enable Always‑Ready and Prewarmed instances, and add a warmup trigger to preload dependencies so the language worker is hot before Teams invokes your bot and co‑locate the Function App and any external API in the same Azure region and reuse HTTP clients with keep‑alive to avoid per‑request TLS handshakes.

    References:

    Azure Functions hosting options

    Best practices for reliable Azure Functions

    Understanding serverless cold start

    Hope my answer will help you, for any further concern, kindly let me know in the comment section.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".     

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.