4

We have developed chatbot functionality for our on-premise ERP using Recast.AI.

Basically, we have deployed a plugin on the On-Premise Fiori launchpad using the following code; However the Fiori launchpad freezes after the chatbot launches and we cannot execute anything on the Fiori Launchpad. The options in SAP Note 2544600 haven't helped us. Any idea, what could be the issue?

Regards,

Karan

sap.ui.define([
"sap/ui/core/UIComponent",

], function (UIComponent) {
"use strict";


return UIComponent.extend("com.abc.chatbot.Component", {

    /**
     * The component is initialized by UI5 automatically during the startup of the app and calls the init method once.
     * @public
     * @override
     */
    init: function () {
        // call the base component's init function
        UIComponent.prototype.init.apply(this, arguments);
        var renderer = sap.ushell.Container.getRenderer("fiori2");
        if (!document.getElementById("recast-webchat")) {


            var s = document.createElement("script");
            s.setAttribute("id", "recast-webchat");
            s.setAttribute("src", "https://cdn.recast.ai/webchat/webchat.js");
            //document.body.appendChild(s);
            if (document.body != null) {
                document.body.appendChild(s);
            }
        }
        s.setAttribute("channelId", "abc");
        s.setAttribute("token", "xyz");
    }
});

});

The issue is with appendChild; which makes the launchpad unresponsive. Not sure what could be the alternative as I have tried various ways such as creating div, fragments as well.

achedeuzot
  • 4,164
  • 4
  • 41
  • 56
Karan Bahl
  • 41
  • 4
  • please provide the brower's console messages. – n01dea Aug 24 '18 at 12:01
  • Can you see, if there are any other plugins involved? Any error messages in the console? Any error messages in the Network Tab of debugger? Is the URL _cdn.recast.ai/webchat/webchat.js_ available from your system? –  Aug 24 '18 at 19:09
  • @n01dea :The following message is observed: Failed to load https://api.recast.ai/connect/v1/webhook/90a1804d-dd20-499c-9709-a9108b6616aa/conversations//poll?last_message_id: Response for preflight does not have HTTP ok status. – Karan Bahl Aug 27 '18 at 03:41
  • @SAPFioriCrew - The problem is that this chatbot plugin is working; but nothing works on the Fiori launchpad; When I click anything there is no response; it is in a disconnected state. The chatbot works. What has made the Fiori launchpad unresponsive; I am sure it is appendChild of the chatbot script; but what could be the solution to get both of them working. – Karan Bahl Aug 27 '18 at 03:44
  • @SAPFioriCrew - any inputs on this? – Karan Bahl Aug 29 '18 at 09:24
  • the issue is not necessarily `appendChild` but the things the bot script does to insert the chatboxes etc. `webchat.js` does a lot of `createElement` of it's own that might interfere with the launchpad. What happens when you append a script that does a simple alert or something? The solutions to your problem will depend on what is actually breaking. UI5 does the `appendChild` thing for component-preloads for example – Jorg Aug 29 '18 at 23:13
  • We recommend using CoPilot to make the bot available in the Fiori Launchpad. SAP CoPilot is integrated in the Fiori Launchpad today (and for Fiori Cloud in 1902). With our 1808 release, we offer the ability to integrate Recast bots into SAP CoPilot. The [official docu](https://help.sap.com/viewer/d53713f5264b49578cd3215ccefc22ae/1808/en-US) might be helpful. –  Sep 05 '18 at 13:15
  • The webchat has been updated at recast.ai end and the chatbot loads fine now on Fiori Launchpad. – Karan Bahl Sep 11 '18 at 17:45

1 Answers1

0

the webchat has been updated since with a fix for Fiori. It should now work

plieb
  • 1,130
  • 1
  • 9
  • 23