3

Im using botman.io package for chatboot widget. Everything works perfectly but problem is that i can't change default background color of chat widget. On inspect console it shown that boman widget calls ( https://cdn.jsdelivr.net/npm/botman-web-widget@0.0.20/build/assets/css/chat.css ) link, but i cant find that call on my localhost project. If anyone know solution i would appreciate.

<script src="{{ asset('/js/webflow.js') }}"></script>
<script> 
        var botmanWidget = {
        title:'Scarletbot',
        introMessage: 'Hello, I am a Scarlet! I am here to assist you and answer all your questions about our products and services!',
        mainColor:'#c02026',
        aboutText:'',
        bubbleBackground:'#c02026',
        headerTextColor: '#fff',
    };

</script>
<script id="botmanWidget" src="{{ asset('/js/widget.js') }}"></script>

enter image description here

Nenad
  • 323
  • 2
  • 6
  • 21

3 Answers3

4

You may add frameEndpoint in

var botmanWidget = {
    frameEndpoint: '<?php echo base_url('botdemo/chatserver1');?>',
    title:'Scarletbot',
    introMessage: 'Hello, I am a Scarlet! I am here to assist you and answer all your questions about our products and services!',
    mainColor:'#c02026',
    aboutText:'',
    bubbleBackground:'#c02026',
    headerTextColor: '#fff',
};

frameEndpoint is nothing but source of iframe loaded by botman-widget

frameEndpoint source is like :

<!doctype html>
<html>
<head>
    <title>BotMan Widget</title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/botman-web-widget@0/build/assets/css/chat.min.css">
</head>
<body>
    <script id="botmanWidget" src='https://cdn.jsdelivr.net/npm/botman-web-widget@0/build/js/chat.js'></script>
</body>
</html>

Here you may use own css as well.

Rajeev Ranjan
  • 4,152
  • 3
  • 28
  • 41
2

I quickly checked out the web widget on the botman github.

There is a simple link to the chat.css in the head of chat.html located in the src folder. This points to assets/css/chat.css, which you can edit freely and add a background-color to.

  • 1
    Thanks for answer, i already upload and call chat.css on my local project within head section . But problem is that botman always use css rules from external css script ( https://cdn.jsdelivr.net/npm/botman-web-widget@0.0.20/build/assets/css/chat.css ). And i can not find exactly from where he calls mentioded script. – Nenad Dec 12 '19 at 08:55
1

I use brute force in the iframe to change background with jquery

$(document).on('click', '.desktop-closed-message-avatar img', function() {
    var iframe = document.getElementById("chatBotManFrame");
    iframe.addEventListener('load', function () {
        var htmlFrame = this.contentWindow.document.getElementsByTagName("html")[0];
        var bodyFrame = this.contentWindow.document.getElementsByTagName("body")[0];
        var headFrame = this.contentWindow.document.getElementsByTagName("head")[0];

        var image = "https://images.unsplash.com/photo-1501597301489-8b75b675ba0a?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1349&q=80"

        htmlFrame.style.backgroundImage = "url("+image+")";
        bodyFrame.style.backgroundImage = "url("+image+")";
    });
});
luisenricke
  • 159
  • 10