403 Forbidden "Region not allowed" when trying to start a new conversation

Andreas Lange 0 Reputation points
2025-03-03T11:22:45.94+00:00

Hello,

this question is about the botframework and directline. Hope this is the right place for it.

We are faced with a strange problem since a few weeks: sometimes the request for generating a new conversation is answered with 403 (Forbidden) and we get the error

{
  "code": "RegionNotAllowed",
  "message": "The request received in france but target regional bot belongs to europe. Please check BaseURI  https://docs.microsoft.com/azure/bot-service/rest-api/bot-framework-rest-direct-line-3-0-api-reference?view=azure-bot-service-4.0#base-uri."
}

In detail:

The resources in the resource group were created one year ago and everything ran fine until now. The webchat is hosted in one app service and the bot runs in another app service. We use the botframework-webchat (4.18.0, latest version) npm package as frontend and first create a token using /v3/directline/tokens/generate. The webchat component then uses this token to create a new conversation by sending a POST request to the directline endpoint /v3/directline/conversations. This request is answered with 403 (Forbidden) sporadically (if answered with 200, everything works just fine).

Since the azure bot resource (and all the other resources too) was created in 'West Europe' and is therefore a regional bot, we use the directline endpoint https://europe.directline.botframework.com to generate the token accordingly to the documentation https://learn.microsoft.com/de-de/azure/bot-service/rest-api/bot-framework-rest-direct-line-3-0-api-reference?view=azure-bot-service-4.0. We haven't found a solution to this problem and hope you can help us.

Best regards and thanks in advance

Azure AI Bot Service
Azure AI Bot Service
An Azure service that provides an integrated environment for bot development.
907 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Chakaravarthi Rangarajan Bhargavi 1,030 Reputation points MVP
    2025-03-03T17:40:27.53+00:00

    Hi Andreas Lange,

    Welcome to the Microsoft Q&A forum! Thanks for your question.

    The 403 Forbidden - "RegionNotAllowed" error typically occurs when there is a mismatch between the region where your bot is deployed and the region from which the request is being made.

    Possible Causes & Solutions:

    Ensure You're Using the Correct Direct Line Endpoint

    • Since your bot is deployed in West Europe, ensure that you are using the correct Direct Line endpoint:
        https://europe.directline.botframework.com
      
    • Double-check that your token generation request (/v3/directline/tokens/generate) is also pointing to the same Europe endpoint.

    Force Region in Webchat Configuration

    • If the bot is hosted in West Europe, but some requests are received in France, try explicitly setting the region when initializing WebChat.
    • Example:
        window.WebChat.renderWebChat(
        {
          directLine: window.WebChat.createDirectLine({
            token: 'YOUR_DIRECTLINE_TOKEN',
            domain: 'https://europe.directline.botframework.com/'
          })
        },
        document.getElementById('webchat')
      

    );

      
    **Check for Intermittent Network Routing Issues**
    
    - Since this error occurs **sporadically**, it might be due to **network routing** issues where some requests are incorrectly routed to a different region.
    
    - **Try testing from different network locations** and see if the issue persists.
    
    **Validate the Azure Bot Channel Registration**
    
    - Ensure that your **Bot Channel Registration** resource is correctly mapped to the **Direct Line** endpoint in **Europe**.
    
    - **Go to Azure Portal > Bot Services > Your Bot > Channels > Direct Line**
    
    - Check if the service URL is correct.
    
    **Regenerate Direct Line Secrets**
    
    If the issue persists, **try regenerating the Direct Line secret** from the Azure portal and update your token request with the new key.
    
    **Go to Azure Portal > Bot Services > Your Bot > Channels > Direct Line > Manage Keys**
    
    Regenerate the **Primary and Secondary Keys** and update your requests accordingly.
    
    References for Further Troubleshooting if you still face the same problem
    
    [Bot Framework REST API (Direct Line)](https://learn.microsoft.com/en-us/azure/bot-service/rest-api/bot-framework-rest-direct-line-3-0-api-reference?view=azure-bot-service-4.0) 
    
    [WebChat Configuration Docs](https://learn.microsoft.com/en-us/azure/bot-service/bot-service-channel-connect-webchat?view=azure-bot-service-4.0)
    
    Please try these steps and check if the issue persists. If you need further assistance, feel free to comment below, and I’d be happy to help! 😊
    
    **Regards,** 
    
    *Chakravarthi Rangarajan Bhargavi*
    
    **- Please accept the answer and vote 'Yes' if you found it helpful to support the community. Thanks a lot!**
    
    

Your answer

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