https://discord.gg/botpress logo
In functions.php of your theme (preferably the chi...
# 🌎general
b
In functions.php of your theme (preferably the child theme)
Copy code
function te_script_styles_footer() {
    wp_enqueue_script('bp-inject', 'https://cdn.botpress.cloud/webchat/v0/inject.js', '', '', true); //url 1 of your embedded code
    wp_enqueue_script('bp-config', 'https://mediafiles.botpress.cloud/xxxxxxxxxxxxxxxxxxxxxxxxxxxx/webchat/config.js', '', '', true); //url 2 of your embedded code
    wp_enqueue_script('bp-action', get_stylesheet_directory_uri() . '/js/botpress.js', array('jquery', 'bp-inject', 'bp-config'), '', true); //your custom code
}
add_action( 'wp_enqueue_scripts', 'te_script_styles_footer', 9999,1);
in botpress.js in the js folder of your theme (preferably the child theme)
Copy code
jQuery.noConflict();
jQuery( document ).ready(function( $ ) {
    //console.log('bot actions activated');
    window.botpressWebChat.onEvent(
      function (event) {
        window.botpressWebChat.sendEvent({
          type: 'loadConversation'
        });
      },
      ['LIFECYCLE.LOADED']
    );
    window.addEventListener('message', function (event) {
      //console.log('starting bot actions');
      if (event.data.type === 'LIFECYCLE.READY') {
        window.botpressWebChat.sendEvent({
          type: 'trigger',
          channel: 'web'
        });
      }
    });
});
5 Views