Skip to main content

Notifications

Announcements

No record found.

Publish & Channel Management
Answered

Using custom canvas for PVA doesn't start conversation

Posted on by 14

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

     

Helpful resources

Quick Links

Exciting News for Copilot Studio Communi…

Get ready to experience a whole new level of engagement with the Copilot Studio…

Celebrating the May Super User of the…

LaurensM is an exceptional contributor to the Power Platform Community…

Check out the Copilot Studio Cookbook…

We are excited to announce our new Copilot Cookbook Gallery in the Community…

Leaderboard

#1
renatoromao Profile Picture

renatoromao 6,459

#2
Pstork1 Profile Picture

Pstork1 1,954

#3
Expiscornovus Profile Picture

Expiscornovus 1,648

Featured topics