When dealing with timeouts in a Teams message extension, especially during external API calls, it's important to consider the following factors:
- Timeout Duration: Teams has a strict timeout limit of 5 seconds for responding to the
composeExtension/queryrequests. If your API call takes longer than this, Teams will terminate the request, resulting in a timeout error. - Performance Optimization: Since you've already tried reducing the payload size and moving the API call to a proxy layer, consider further optimizing your API call. This could involve caching responses, optimizing the backend processing time, or simplifying the data being returned.
- Asynchronous Processing: If possible, consider implementing an asynchronous pattern where the Teams extension can respond immediately (e.g., with a loading indicator) and then follow up with the actual data once the API call completes. This way, you can avoid hitting the strict timeout limit.
- Monitoring and Logging: Since you mentioned enabling App Insights logging, ensure that you are capturing detailed logs around the API call duration. This will help you identify any bottlenecks or issues that might be causing the delays.
- Network Latency: Sometimes, network issues can cause delays in the API response. Ensure that your Azure Function and the external API are in the same region to minimize latency.
By addressing these areas, you may be able to reduce the occurrence of timeouts and improve the reliability of your Teams message extension.
References: