Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with Power Virtual Agent Bot: Site Missing code 403 from https://directline.botframework.com/v3/directline/conversations #4625

Closed
alessiodecastro opened this issue Jan 24, 2023 · 6 comments
Assignees
Labels
Bot Services Required for internal Azure reporting. Do not delete. Do not change color. bug Indicates an unexpected problem or an unintended behavior. customer-reported Required for internal Azure reporting. Do not delete.

Comments

@alessiodecastro
Copy link

Is it an issue related to Adaptive Cards?

No

Is this an accessibility issue?

No

What version of Web Chat are you using?

Latest production

Which distribution are you using Web Chat from?

Bundle (webchat.js)

Which hosting environment does this issue primarily affect?

Web apps

Which browsers and platforms do the issue happened?

No response

Which area does this issue affect?

Protocol or service

What is the public URL for the website?

No response

Please describe the bug

Hello, the following piece of code was working fine up to last week, from yesterday we are getting the following 403 error after successfully retrieve the token and then performing request to: https://directline.botframework.com/v3/directline/conversations

response body from https://directline.botframework.com/v3/directline/conversations:

"error": {
    "code": "BadArgument",
    "message": "Site missing. Learn more about sites  https://docs.microsoft.com/azure/bot-service/bot-service-channel-connect-directline?view=azure-bot-service-4.0#add-new-site."
  }

image

The webchat is using a Power Virtual Agent Bot and the relative token issuer, by the way from the power platform side there is no way to define sites as usually happen in the Azure Bot Service Resource.
Here is the full testing code running in localhost env:

<!DOCTYPE html>
<html lang="en-US">
  <head>
    <title>Web Chat</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <script crossorigin="anonymous" src="https://cdn.botframework.com/botframework-webchat/latest/webchat.js"></script>
    <style>
      html,
      body {
        height: 100%;
      }

      body {
        margin: 0;
      }

      #webchat {
        height: 100%;
        width: 100%;
      }
    </style>
  </head>
  <body>
    <div id="webchat" role="main"></div>
    <script>
      (async function() {
        const res = await fetch('https://ced36af1b92ee6ae99db50a8734a78.5a.environment.api.powerplatform.com/powervirtualagents/bots/b8ab704c-8d06-417e-b2b5-fc65a0abf77f/directline/token?api-version=2022-03-01-preview', { method: 'GET' });
        const { token } = await res.json();

        window.WebChat.renderWebChat(
          {
            directLine: window.WebChat.createDirectLine({ token })
          },
          document.getElementById('webchat')
        );

        document.querySelector('#webchat > *').focus();
      })().catch(err => console.error(err));
    </script>
  </body>
</html>

Thanks for the support.

Do you see any errors in console log?

response body from https://directline.botframework.com/v3/directline/conversations: 

    "error": {
        "code": "BadArgument",
        "message": "Site missing. Learn more about sites  https://docs.microsoft.com/azure/bot-service/bot-service-channel-connect-directline?view=azure-bot-service-4.0#add-new-site."
      }

How to reproduce the issue?

<!DOCTYPE html>
<html lang="en-US">
  <head>
    <title>Web Chat</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <script crossorigin="anonymous" src="https://cdn.botframework.com/botframework-webchat/latest/webchat.js"></script>
    <style>
      html,
      body {
        height: 100%;
      }

      body {
        margin: 0;
      }

      #webchat {
        height: 100%;
        width: 100%;
      }
    </style>
  </head>
  <body>
    <div id="webchat" role="main"></div>
    <script>
      (async function() {
        const res = await fetch('https://ced36af1b92ee6ae99db50a8734a78.5a.environment.api.powerplatform.com/powervirtualagents/bots/b8ab704c-8d06-417e-b2b5-fc65a0abf77f/directline/token?api-version=2022-03-01-preview', { method: 'GET' });
        const { token } = await res.json();

        window.WebChat.renderWebChat(
          {
            directLine: window.WebChat.createDirectLine({ token })
          },
          document.getElementById('webchat')
        );

        document.querySelector('#webchat > *').focus();
      })().catch(err => console.error(err));
    </script>
  </body>
</html>

What do you expect?

200 OK response from https://directline.botframework.com/v3/directline/conversations:

What actually happened?

403 Site Missing

Do you have any screenshots or recordings to repro the issue?

No response

Adaptive Card JSON

No response

Additional context

No response

@alessiodecastro alessiodecastro added Bot Services Required for internal Azure reporting. Do not delete. Do not change color. bug Indicates an unexpected problem or an unintended behavior. customer-reported Required for internal Azure reporting. Do not delete. labels Jan 24, 2023
@stevkan
Copy link
Contributor

stevkan commented Jan 25, 2023

@alessiodecastro, I've been testing this since yesterday by making a request using Postman directly to the https://directline.botframework.com/v3/directline/conversations endpoint. I received this error only once while using what I thought was perhaps a bad setup. I encountered this prior to seeing this issue. So, I created a new, clean setup and it has worked fine since that first instance.

Can you verify if you are still experiencing the issue? If you make a similar request in Postman (or a similar service), do you get the same or does the error go away?

Here's the code snippet from Postman interpreted as a JavaScript fetch request. You can reference this for easy setup in Postman or place this in a project and try running.

var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", "Bearer <<YOUR DIRECTLINE SECRET>>");

var raw = JSON.stringify({
  "user": {
    "id": "dl_abc123",
    "name": "user1"
  }
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://directline.botframework.com/v3/directline/conversations", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

@stevkan
Copy link
Contributor

stevkan commented Jan 25, 2023

@alessiodecastro, I forgot that you don't have access to the DirectLine secret in PVA as you would in an SDK bot. Let me research how you could test this and I'll get back to you.

Are you still experiencing this issue, though?

@alessiodecastro
Copy link
Author

alessiodecastro commented Jan 25, 2023

@stevkan yesterday, after spending two days on this, I opened a support ticket to MSFT. They investigated in first instance and replicated the same problem, even with the official git repo samples, without finding the reason so they escaleted to the PVA product team engineers. As temporary workaround they said to specify in the renderWebChat the domain as https://europe.directline.botframework.com/v3/directline/conversations instead of the standard one. In the meanwhile they are still investigating, much probably is something depending on their side about networking propagation matter. By the way even in postman I got the same issue till yesterday, now that token endpoint url is no more available from my dev environment. Waiting responses from the product team, you can close this issue. Thanks

@mrk1989
Copy link

mrk1989 commented Oct 6, 2023

@alessiodecastro, you solved this problem?
I have to contact Microsoft? I worked for 5 months and now I can't restore the chat

@alessiodecastro
Copy link
Author

@mrk1989 at the end I seem to remember that I left the workaround endpoint as mentioned in the last comment but it was for PoC/Dev purposes so no need to restore any conversation at that time. If your issue impacts production workloads I suggest to open a ticket. https://europe.directline.botframework.com/v3/directline/conversations

@mrk1989
Copy link

mrk1989 commented Oct 6, 2023

This solution not worked for me...

directLine: window.WebChat.createDirectLine({ token,domain:"https://europe.directline.botframework.com/v3/directline/conversations" }) .

@alessiodecastro How you solved the problem ??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bot Services Required for internal Azure reporting. Do not delete. Do not change color. bug Indicates an unexpected problem or an unintended behavior. customer-reported Required for internal Azure reporting. Do not delete.
Projects
None yet
Development

No branches or pull requests

3 participants