web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Copilot Studio / Using custom canvas fo...
Copilot Studio
Unanswered

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? 

I have the same question (0)
  • Verified answer
    Dynamotion Profile Picture
    18 on at

    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));

     

  • compulim Profile Picture
    Microsoft Employee on at

    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.

  • Speekins Profile Picture
    18 on at

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

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Copilot Studio

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 273 Super User 2025 Season 2

#2
Romain The Low-Code Bearded Bear Profile Picture

Romain The Low-Code... 271 Super User 2025 Season 2

#3
S-Venkadesh Profile Picture

S-Venkadesh 101 Moderator

Last 30 days Overall leaderboard