Skip to main content

Notifications

Copilot Studio - Publish & Channel Management
Answered

Using custom canvas for PVA doesn't start conversation

(0) ShareShare
ReportReport
Posted on by 18

Greetings!

I am building a custom web canvas for the the PVA (preview model) using the instructions here: Automatically start a chatbot conversation - Power Virtual Agents | Microsoft Learn

 

When I load the page, PVA doesn't seem to start the conversation by default. I have to use a trigger word to initiate any topic. 

 

I've verified these:

  • There is a system topic that's configured correctly
  • The iframe embed approach works and the bot starts the conversation

Any idea what I might be doing wrong? Is there something specific I need to do to start the conversation? 

  • Speekins Profile Picture
    Speekins 18 on at
    Re: Using custom canvas for PVA doesn't start conversation

    Thank you! Your post saved me a ton of time trying to figure this out.

  • compulim Profile Picture
    compulim on at
    Re: Using custom canvas for PVA doesn't start conversation

    The documentation has been updated, https://learn.microsoft.com/en-us/microsoft-copilot-studio/customize-default-canvas?tabs=web.

     

    It now contains JavaScript code that would send a greeting message to the copilot to start the conversation.

     

    Thanks.

  • Verified answer
    Dynamotion Profile Picture
    Dynamotion 18 on at
    Re: Using custom canvas for PVA doesn't start conversation

    Figured it out. Now it works with the Bot initiating the conversation.

     

    Replaced this:

    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,
     }),
     styleOptions
     },
     document.getElementById('webchat')
     );
     })
     .catch(err => console.error("An error occurred: " + err));

     

     with this:

    const store = window.WebChat.createStore(
     {},
     ({ dispatch }) => next => action => {
     if (action.type === "DIRECT_LINE/CONNECT_FULFILLED") {
     dispatch({
     meta: {
     method: "keyboard",
     },
     payload: {
     activity: {
     channelData: {
     postBack: true,
     },
     //Web Chat will show the 'Greeting' System Topic message which has a trigger-phrase 'hello'
     name: 'startConversation',
     type: "event"
     },
     },
     type: "DIRECT_LINE/POST_ACTIVITY",
     });
     }
     return next(action);
     }
     );
     fetch(theURL)
     .then(response => response.json())
     .then(conversationInfo => {
     window.WebChat.renderWebChat(
     {
     directLine: window.WebChat.createDirectLine({
     token: conversationInfo.token,
     }),
     store: store,
     styleOptions: styleOptions
     },
     document.getElementById('webchat')
     );
     })
     .catch(err => console.error("An error occurred: " + err));

     

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,434

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,722

Leaderboard

Featured topics