Share via

Bot Framework Authorization Error: “Authorization has been denied for this request” when sending activity from AWS Lambda

Devam Jatinbhai Parikh 0 Reputation points
2026-01-12T06:06:41.7966667+00:00

I am running a Microsoft Bot Framework bot (Node.js) deployed on AWS Lambda (Node.js 18) behind API Gateway.

The bot successfully receives incoming messages (from Teams / Bot Connector), processes them, and even fetches external data (PagerDuty API). However, it fails when trying to send a response back using context.sendActivity().

Error

BotFrameworkAdapter.processActivity(): 500 ERROR
RestError: Authorization has been denied for this request.
    at ConnectorClient.sendOperationRequest

This results in an unhandled promise rejection and Lambda exits with an error.

Observations

Incoming activities are processed correctly

The failure only happens when sending the outgoing activity

Error originates from @azure/core-http / ConnectorClient

This started happening recently (worked before)

Environment

Bot Framework SDK: botbuilder (Node.js)

Runtime: AWS Lambda (nodejs18.x)

Channel: Microsoft Teams

Bot is registered in Azure (Azure Bot / App Registration)

Credentials (MicrosoftAppId, MicrosoftAppPassword) are injected via Lambda environment variables

Things already verified

App ID matches Azure Bot registration

Messaging endpoint is correctly configured

Bot receives messages without issue

PagerDuty API calls succeed

  • Error occurs only during replyI am running a Microsoft Bot Framework bot (Node.js) deployed on AWS Lambda (Node.js 18) behind API Gateway. The bot successfully receives incoming messages (from Teams / Bot Connector), processes them, and even fetches external data (PagerDuty API). However, it fails when trying to send a response back using context.sendActivity().

    Error

      BotFrameworkAdapter.processActivity(): 
    
    This results in an unhandled promise rejection and Lambda exits with an error.

    Observations

    • Incoming activities are processed correctly
    • The failure only happens when sending the outgoing activity
    • Error originates from @azure/core-http / ConnectorClient

    Environment

    • Bot Framework SDK: botbuilder (Node.js)
    • Runtime: AWS Lambda (nodejs18.x)
    • Channel: Microsoft Teams
    • Bot is registered in Azure (Azure Bot / App Registration)
    • Credentials (MicrosoftAppId, MicrosoftAppPassword) are injected via Lambda environment variables

    Things already verified

    • App ID matches Azure Bot registration
    • Messaging endpoint is correctly configured
    • Bot receives messages without issue
    • PagerDuty API calls succeed
    • Error occurs only during reply
Azure AI Bot Service
Azure AI Bot Service

An Azure service that provides an integrated environment for bot development.


1 answer

Sort by: Most helpful
  1. AI answer

    2026-01-12T06:06:55.8033333+00:00

    The error message "Authorization has been denied for this request" when trying to send an outgoing activity from your Microsoft Bot Framework bot indicates that there may be an issue with the permissions or the credentials being used for the outgoing request. Here are some steps to troubleshoot the issue:

    1. Verify Credentials: Ensure that the MicrosoftAppId and MicrosoftAppPassword being used in your AWS Lambda environment variables are correct and match the values in your Azure Bot registration.
    2. Check API Permissions: Confirm that your bot has the necessary permissions configured in Azure. The bot needs appropriate permissions to send messages back to the users. You may need to check the API permissions in the Azure portal for your bot registration.
    3. Token Acquisition: Ensure that your bot is acquiring a valid access token before sending the message. If the token is missing or invalid, it could lead to authorization errors. You can use the Microsoft Authentication Library (MSAL) for acquiring tokens correctly.
    4. Review Messaging Endpoint: Double-check that the messaging endpoint configured in Azure is correct and accessible. This endpoint should point to your AWS Lambda function.
    5. Inspect Logs: Look at the logs in AWS CloudWatch for any additional error messages or stack traces that might provide more context about the failure.
    6. Test with Postman: You can use Postman to manually test sending requests to the Bot Framework API using the same credentials to see if you can reproduce the issue outside of your Lambda function.

    If these steps do not resolve the issue, consider checking the Microsoft Graph authorization errors documentation for more insights on common authorization problems.


    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer 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.