0

I am new to botpress and working on a project where I want to disable the user input and send button. so is this possible in the current botpress version? if anyone can help me with this?

JJ_Wailes
  • 2,207
  • 1
  • 9
  • 17

1 Answers1

-1

In file /data/assets/ui-studio/public/js/lite.7df1ba548a26568689c1.js copy the following script at the end.

var ua = window.navigator.userAgent;
var trident = ua.indexOf('Trident/');
var edge = ua.indexOf('Edge/');
var msie = ua.indexOf('MSIE ');
var intIE = 0 ;
var intcnt = 0 ;
if (trident > 0 || edge > 0 || msie > 0 ){      
    intIE = 1 ; 
}

// target element that we will observe
const target = document.getElementById("app");
// config object
const config = {  
    childList: true,
    subtree: true       
};

function trackchange(mutations) {

        var iframe = document.getElementById("app");                        
        var str = iframe.outerHTML ;            
        var n = str.search("bpw-keyboard-quick_reply");     
        if (n > 1){ 
            if (intIE < 1){
                document.getElementById("input-message").placeholder = "Select from above options";
            }
            document.getElementById("btn-send").style.display = "none" ;    
            document.getElementById("input-message").disabled = true;                               
        }else{      
            if (intIE < 1){
                document.getElementById("input-message").placeholder = "Type here";
            }

            if (intcnt < 1){
                intcnt = 0 ;

                //document.getElementById("input-message").value = "Hi";                

            }
            document.getElementById("btn-send").style.display = "" ;    
            document.getElementById("input-message").disabled = false;              
        }   

}

// instantiating observer
const observer = new MutationObserver(trackchange);

// observing target
observer.observe(target, config);
  • Can you explain the process and how you got to the answer? I am not familiar with botpress but it seems unlikely this will be the valid path for future versions or different systems, and it also seem this this could be included from a standalone location. – Sebi Jun 09 '20 at 13:05
  • Yes, file path may not valid for the future version. The intention is to add the attached java script in chat window page. So you can use any file that are available to add custom JavaScript in your version of Botpress. The script is not a part of Botpress code or Botpress framework. I have added additional event to track a change in bot response and identify if quick responses are displayed. Based on quick response displayed disabled or enabled the input box. – Sumeet Zade Jun 10 '20 at 11:19