Skip to main content

Notifications

Publish & Channel Management
Answered

Using custom canvas for PVA doesn't start conversation

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

     

Helpful resources

Quick Links

Welcome to the Power Platform…

We are thrilled to unveil the newly-launched Power Platform Communities!…

Getting Started…

Welcome to the Power Platform Community! We appreciate your visit…

Welcome to the new Power Platform Community!…

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

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 138,287

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 63,172

Leaderboard

Featured topics