Skip to main content

Notifications

Announcements

No record found.

Power Platform Community / Forums / General / Start Bot using button
General
Answered

Start Bot using button

Posted on by 16

Hello - On the 'Demo' sites, you can click buttons/links that will start the bot. Is there a way to do this when publishing to a SharePoint site? Meaning, would I be able to add a set of buttons / links in one section of the page that will kick the bot off without me having to type 'hi' and then a topic?

 

Like, clicking on a button that says 'How do I reset my password?', then having the bot start by saying 'I see you want to reset your password....'

 

Thanks, in advance. ~ lah

Categories:
  • renatoromao Profile Picture
    renatoromao 6,459 on at
    Re: Start Bot using button

    No worries @lahddah !

     

    You're welcome.

    Count on me if you need anything about Power Platform and Office 365! 😉 

  • lahddah Profile Picture
    lahddah 16 on at
    Re: Start Bot using button

    Thank you, Renato! Sorry for the late reply. Our offices were closed last week. I will look at this today. I appreciate you sharing it!

     

    ~ lah

  • Verified answer
    renatoromao Profile Picture
    renatoromao 6,459 on at
    Re: Start Bot using button

    Hi @lahddah ,

     

    Good news!!! 

    I created a web part solution to use chatbots inside SharePoint pages.

    How to use Chatbots inside SharePoint pages (no-co... - Power Platform Community (microsoft.com)

  • lahddah Profile Picture
    lahddah 16 on at
    Re: Start Bot using button

    Merry Christmas and hope you have a great weekend! Thank you!

  • renatoromao Profile Picture
    renatoromao 6,459 on at
    Re: Start Bot using button

    @lahddah ,

     

    Nice!

    See you later and Merry Christmas 🥳🎅🏽

  • lahddah Profile Picture
    lahddah 16 on at
    Re: Start Bot using button

    Thanks, renatoromao!

    I can certainly wait, for sure! I was actually just poking around in the SPFx area, as it looks like that might be the way to go. I'll play with it today and also, if you don't mind sharing, will gladly take a look at what you've already accomplished.

     

    Thank you, again!

    ~ lah

  • renatoromao Profile Picture
    renatoromao 6,459 on at
    Re: Start Bot using button

    Hi @lahddah ,

     

    In SharePoint Modern Pages, you can use SPFx.

    I will do a sample in this weekend because I have the most part of this code that I already did for my client. Can you wait for this sample?

  • lahddah Profile Picture
    lahddah 16 on at
    Re: Start Bot using button

    Thank you, nmk! These are all methods I am trying. I'm working on a localhost thing now to see if I can make it work the say I want (start minimized & maximize on button press). One problem that I've found is that the script webpards that worked in SharePoint 2013 classic pages don't work with SharePoint online modern pages, which is the direction we want to go. So, I'm trying to fit a square peg into a round hole, I guess. I appreciate your input and am looking into the links shared. I've visited all of them prior to posting here, but will go through them more closely to see what I'm missing.

     

    Thank you -

    ~ lah

  • nmk Profile Picture
    nmk 106 on at
    Re: Start Bot using button

    Hi  @lahddah,

     

    Again, you can do multiple things. It's all up to the requirement and creativity you can put into action.

     

    Well, to start the bot on the click on a button, you need to use the custom canvas (I am sure you are already aware of this) -> here's the details.

     

    Secondly, you need to encapsulate the below code into a function and call the function on the button click.

     

     const styleOptions = {
    
     // Add styleOptions to customize Web Chat canvas
     hideUploadButton: true
     };
    
     // Add your BOT ID below 
     var BOT_ID = "<ENTER YOUR BOT ID>"; 
     var theURL = "https://powerva.microsoft.com/api/botmanagement/v1/directline/directlinetoken?botId=" + BOT_ID;
    
     fetch(theURL)
     .then(response => response.json())
     .then(conversationInfo => {
     window.WebChat.renderWebChat(
     {
     directLine: window.WebChat.createDirectLine({
     token: conversationInfo.token,
     }),
     styleOptions
     },
     document.getElementById('webchat')
     );
     })
     .catch(err => console.error("An error occurred: " + err));

     

    Yes it will come as blank. You have two options now.

     

    1- Auto start the chat conversation. This is the route we took. More details here Note: if you don't use a user topic in greeting then it won't be counted as billed session.

     

    2- There are lots of things you can do with the help of HTML+Javascript+CSS combination e.g.

    • Containerized the bot into into a div and put a header/footer with instruction.
    • Put an overlay with instructions and give some effects. You can google for ideas- here

     

     

     

  • lahddah Profile Picture
    lahddah 16 on at
    Re: Start Bot using button

    Thank you, nmk. That is what I'm doing now in SharePoint Online (embedded iframe). I am having difficulty getting it to start minimized with a call to action (click here to chat) or some chat image button. It is just open full height and blank until someone types in it. I can get it to autostart in a test 'index' page, but even if I could figure out how to autostart it w/ brief intro and instructions letting the user know how to interact with it, I know each time someone visits the page, it will be recorded as a 'run', so stats might be wonky. (less important)

     

    Onload, I'd like something like a simple call to action button which, when clicked, opens up the chat window with greetings topic. Like this one:

    2020-12-21_7-03-26.png

     

    There are html and script web parts available in SharePoint, but so far those aren't working for the code and in SharePoint online. I'll keep trying, though.

     

    Thanks, again!

    ~ lah

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