BotFramework-WebChat icon indicating copy to clipboard operation
BotFramework-WebChat copied to clipboard

Embed Bot into Sharepoint 2013 on prem with directline inte

Open videepthMSFT opened this issue 7 years ago • 9 comments

Hi,

I am developing a Bot for a customer using v4 SDK. My end goal is to deploy this BOT on to a sharepoint 2013 environment.

I get this wierd error when I try to deploy stuff into a sharepoint site.

image

This works on a normal web application but fails when deployed on a sharepoint site.

Error : As per the screenshot it says its failing at fillOpacity which is a method from botchat.js

Note : I have tried botchat-es5.js webchat-es5.js but have no luck

Can I get any help on this? Thanks for all the good work.

videepthMSFT avatar Feb 13 '19 14:02 videepthMSFT

Hi @vishnu2017 - I had this issue transferred over from BotBuilder since this is a Web Chat question. Could you clarify a few questions for me?

  • It looks like you are using v4 syntax, but you mention that you are using botchat.js (and have tried botchat-es5 and webchat-es5). webchat.js indicates use of the v4 CDN - could you let me know which version of Web Chat you intend to use? We might need to do a pass to verify you are using the correct CDN of your intended version.
    • If you are using v4, we have a bunch of samples that can help you get started.
  • What version of IE is being used? Web Chat only supports IE11.
  • Could you let me know what your console errors say? I see in your screencap that there are 2.

it looks like fillOpacity is from one of our dependencies, cssstyle. Hopefully this will help us track down the problem.

corinagum avatar Feb 13 '19 17:02 corinagum

Hey @corinagum ,

Thanks for the quick response.

Firstly, here's my code just for reference.

<link rel="stylesheet" href="~/css/botchat.css" /> --- **I have a local copy of the cdn latest versions**
<script src="~/js/botchat.js"></script> --- **I have a local copy of the cdn latest versions**
<script src="~/js/CognitiveServices.js"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>
<!-- Bot Div -->
<div id="chatWindow">
    <div id="bot"></div>
</div>

<!-- Script for DirectLine -->
<script>
    var botConnection = new BotChat.DirectLine({
        token: '------------Passing the token--------------',
    });

    BotChat.App({
        botConnection: botConnection,
        user: { id: 'userid', name: 'User' },
        bot: { id: 'botid' },
        resize: 'detect'
    }, document.getElementById("bot"));

    $('.BOTHEADER).replaceWith('<img src="/images/Logo.png" style="width: 20px;height: 20px;background: none;margin-right: 5px;margin-bottom: 3px"/><span style="display:inline-block; width:"30" ;"></span><b>NAME</b>');

</script>

So I use the same logic in a MVC application and everything works as expected.

When I move the same to embed it on a web page of sharepoint 2013 on prem environment, it pops out with an error.

So just wanted to understand, Is botchat.js compatible with SP2013?

Answering your questions :

  1. Latest version of botchat.js file targeting v4.

  2. I am on IE 11. image

  3. console error image

Here is the bot UI on a MVC application image

videepthMSFT avatar Feb 13 '19 22:02 videepthMSFT

It looks like your intent is to use v3 of Web Chat, not v4. Your screencap of the MVC application and your code indicate that to me. First, I would make sure that your copy of the CDN is the correct file -- if you are using webchat.js, you are likely using the incorrect file. You should be using a botchat.js file, unless you have renamed it. (There are significant differences between v4 and v3, and the CDN's are not interchangeable)

I suspect this will resolve the error of 'BotChat' being undefined, since the BotChat object is from v3 and no longer used in v4.

Please see the index.html of our v3 sample. Hopefully this will help you get set up.

Unfortunately I am not sure about Web Chat working on SharePoint -- as far as I know it should, and looking through our repo didn't reveal any issues between v3 and SharePoint. Please let us know what you find out!

corinagum avatar Feb 13 '19 23:02 corinagum

Hi Corinagum,

I actually bumped into this link https://github.com/Microsoft/BotFramework-WebChat/issues/1326

I have used v4 logic and here's my code-

<html lang="en-US">
  <head>
    <title>Web Chat: Full-featured bundle with ES5 polyfills</title>
    <!--
      For demonstration purposes, we are using the development branch of Web Chat at "/master/webchat.js".
      When you are using Web Chat for production, you should use the latest stable release at "/latest/webchat.js",
      or lock down on a specific version with the following format: "/4.1.0/webchat.js".
    -->
    <script src="https://cdn.botframework.com/botframework-webchat/master/webchat-es5.js"></script>
    <style>
      html, body { height: 100% }
      body { margin: 0 }

      #webchat {
        height: 100%;
        width: 100%;
      }
    </style>
  </head>
  <body>
    <div id="webchat" role="main"></div>
    <script>
       function () {
       
		var tokenval = 'kyTrsRHi3xs.dAA.T---DummyToken-----EQAWABpAGIAZwBsAGIATQBWAEMAbgA.xxYslFvE1AE.4lmzSR4yEhg.cKV3VMUX2uUm7jY2DqzQJxhrLj6WagjEng7PL97vG98';
		
		
		window.WebChat.renderWebChat({directLine:window.WebChat.createDirectLine({token:tokenval})},document.getElementById('webchat'));
        document.querySelector('#webchat > *').focus();
      }
        
    </script>
  </body>
</html>

Got this error -

image

Some compatibility issue with IE 11. I suspect its the same Fileopacity undefined error which I have mentioned in my first comment.

videepthMSFT avatar Feb 14 '19 11:02 videepthMSFT

n.n=function(e){var t=e&&e.__esModule?function(){return e.default} --- Column 1028 as per the above screenshot.

@corinagum

It is breaking at this return statement, not sure what's going wrong.

videepthMSFT avatar Feb 14 '19 11:02 videepthMSFT

@vishnu2017 it looks like you have errors in your script. the Expected identifier error appears to be related to line 23 of your code.

corinagum avatar Feb 14 '19 18:02 corinagum

@corinagum my bad. Thanks for pointing it out, I forgot to paste in the function name while I was moving stuff.

image

image

image

videepthMSFT avatar Feb 14 '19 20:02 videepthMSFT

@vishnu2017 I just messaged you on Teams -- let's meet over a screen share and chat in real time. I think this issue would be more quickly solved that way. :)

corinagum avatar Feb 14 '19 21:02 corinagum

@vishnu2017 Hi Vishnu, I'm going to close this issue since we have it figured out offline. :)

To summarize our offline findings: after making sure the project was using the es-5 version of Web Chat, we added a prettified version of the .js file to debug. Sharepoint was breaking when hitting Adaptive Cards, related to https://github.com/Microsoft/BotFramework-WebChat/issues/1510, which is a fix that will be available in /latest/ bits on our 4.3 release. Our temporary workaround in the meantime is to use /master/ bits until our next release.

corinagum avatar Feb 20 '19 18:02 corinagum