Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Copilot Studio - General
Answered

PVA Canvas App Control Unable to connect

(0) ShareShare
ReportReport
Posted on by 26

Hi,

 

I am trying to use the new PVA control in a canvas app. I am able to add the control and select my virtual agent just fine. But when it loads it says "Unable to connect" (See below). I have tried everything I can think of and it doesn't seem to be working. The Bot Schema Name is definitely correct, same with the environment id. I have even tried replicating in different environments and bots with the same issue.

 

Can anyone help me with this? Is anyone able to replicate the issue?

 

Thanks

ElliotF93_0-1694883996137.png

 

Categories:
  • fernandosilva Profile Picture
    Super User 2024 Season 1 on at
    Re: PVA Canvas App Control Unable to connect

    Is this your answer?

  • Verified answer
    ElliotF93 Profile Picture
    26 on at
    Re: PVA Canvas App Control Unable to connect

    Oh I see you are creating this in a HTML text control. I was specifically asking about fixing the new PVA canvas app control that's been added, but I guess this is an alternative approach.

    FYI for anyone else, I created a new environment in the US and it seems to work fine there. I'm guessing there's still a few bugs (it is still in preview) which will get patched in other regions soon

  • fernandosilva Profile Picture
    Super User 2024 Season 1 on at
    Re: PVA Canvas App Control Unable to connect

    Hi @ElliotF93 ,

     

    If you copy that html template I posted, follow the steps from the line below and open the html file, you might be able to connect your bot.

     var theURL = "Get your Token Endpoint from PVA>Settings>Channels>Mobile App and paste here";

     

    Cheers,

     

    Fernando

  • ElliotF93 Profile Picture
    26 on at
    Re: PVA Canvas App Control Unable to connect

    Hi Fernando,

     

    Thanks for this. I'm still a bit confused though, how am I supposed to use this to resolve my issue? Do I need to unpack and modify the solution components directly?

     

    Thanks

  • fernandosilva Profile Picture
    Super User 2024 Season 1 on at
    Re: PVA Canvas App Control Unable to connect

    Hi @ElliotF93 ,

     

    I was struggling as well the other day with the same issue till I find the latest version of the custom html canvas.

     

    See below.

     

    <!DOCTYPE html>
    <html>
    
    <head>
     <title>My bot</title>
     <link rel="stylesheet" href="style.css">
    </head>
    
    <body>
     <div>
     <div id="heading">
     <!-- Change the h1 text to change the bot name -->
     <div class="headingFirst">
     <h1 class="chatboth1header">Let's Chat!</h1>
     </div>
     <div class="headingSecond"></div>
     </div>
     </div>
    
     <div id="webchat" role="main"></div>
     </div>
    
     <script src="https://cdn.botframework.com/botframework-webchat/latest/webchat.js"></script>
    
     <script>
     const styleSet = window.WebChat.createStyleSet({
    
     // Add styleOptions to customize Web Chat canvas
     rootHeight: '100%',
     rootWidth: '100%',
     backgroundColor: 'white',
     hideUploadButton: false,
     userAvatarBackgroundColor: 'white',
     botAvatarBackgroundColor: 'white',
     suggesteActionLayout: 'stacked',
    
     });
     // Set the avatar options. 
     const avatarOptions = {
     backgroundColor: 'white',
     botAvatarBackgroundColor: 'rgba(255, 255, 255, 1)',
     botAvatarInitials: 'Your initials',
     userAvatarInitials: 'User initials',
    
     };
    
    
    
     const store = window.WebChat.createStore({},
     ({
     dispatch
     }) => next => action => {
     if (action.type === "DIRECT_LINE/CONNECT_FULFILLED") {
     dispatch({
     meta: {
     method: "keyboard",
     },
     payload: {
     activity: {
     channelData: {
     postBack: true,
     },
     name: 'startConversation',
     type: "event"
     },
     },
     type: "DIRECT_LINE/POST_ACTIVITY",
     });
     }
     return next(action);
     }
     );
    
     // Add your BOT ID below 
    
     var theURL = "Get your Token Endpoint from PVA>Settings>Channels>Mobile App and paste here";
    
     var environmentEndPoint = theURL.slice(0,theURL.indexOf('/powervirtualagents'));
     var apiVersion = theURL.slice(theURL.indexOf('api-version')).split('=')[1];
     var regionalChannelSettingsURL = `${environmentEndPoint}/powervirtualagents/regionalchannelsettings?api-version=${apiVersion}`; 
    
     var directline;
     fetch(regionalChannelSettingsURL)
     .then((response) => {
     return response.json();
     })
     .then((data) => {
     directline = data.channelUrlsById.directline;
     })
     .catch(err => console.error("An error occurred: " + err));
    
     fetch(theURL)
     .then(response => response.json())
     .then(conversationInfo => {
     window.WebChat.renderWebChat(
     {
     directLine: window.WebChat.createDirectLine({
     domain: `${directline}v3/directline`,
     token: conversationInfo.token,
     }),
     styleSet,
     store: store,
     styleOptions: avatarOptions,
    
     },
     document.getElementById('webchat')
     );
     })
     .catch(err => console.error("An error occurred: " + err));
     </script>
    </body>
    
    </html>

     

     

    I hope it helps.

     

    Cheers,


    Fernando

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Copilot Studio - General

#1
Romain The Low-Code Bearded Bear Profile Picture

Romain The Low-Code... 23

#2
Pablo Roldan Profile Picture

Pablo Roldan 21

#3
stampcoin Profile Picture

stampcoin 10

Overall leaderboard