WordPress Plugin for the BotMan Web Widget

I recently was working on a chatbot for a website and wound up using a great PHP library for the task, BotMan. With BotMan, you can follow the really well-done documentation to set up a BotMan endpoint. This is where any client would call to send requests and where logic would be placed to respond to the request. Once it is up and running, you can interface with the BotMan endpoint with something like Postman or Paw. Of course, for your site, you will want some kind of web interface that can send messages to and display responses from BotMan.

BotMan actually provides a chat widget that you can install on your site. It is as simple as adding HTML as an iFrame and two JavaScript files. The iFrame calls in one of the JavaScript files and the other JavaScript file needs to be placed in the main HTML of your page. Finally there is a list of configuration options you can use when calling the Web Widget. In is a pretty easy process but I wanted to make it a little easier and create a plugin.

The WordPress plugin just sets up the Web Widget for use on a site. It will not create a BotMan endpoint for the widget to interact with. That is done separately. But this plugin will add the HTML iFrame to your pages and include the needed JavaScript files. Additionally, instead of editing the configuration options in code, you can use an admin in the WordPress Dashboard under “Settings > BotMan Widget Options.”

BotMan widget

The only setting that you will need to have correctly set for the widget to work is the Chat Server which will be the URL of the BotMan endpoint. You can download the plugin at GitHub:

https://github.com/stirrell/scc-botman-for-wp

If you see any problems please let me know.

3 comments

  1. Great plugin! I was just wondering, which chat.js and widget.js files can replace if we have modified the front end and recompiled those two files? Will it be the min files within dist folder or the js folder? Thank you! I am also running into issues that it’s not generating a random userId per user. hence all my users are using the same chat session. :S Thank you Scott!

    1. Hello Vince!

      The JavaScript being loaded in are the minified versions inside the dist directory.

      In scc-chatbot.php, you will see an enqueue of the widget file at line 23:


      wp_enqueue_script( 'pma-chatbot-widget', plugins_url( 'dist/js/widget-min.js', __FILE__ ), null, null, true );

      And chatbot-iframe.php calls in chat-min.js.

      Sorry, I don’t have an answer about userId. According to the BotMan docs it should be generating an ID on each page-view:

      https://botman.io/2.0/web-widget#configuration

      Are you using any kind of cacheing on the page where the widget is being used?

  2. hello scott tirrell good day, I would like to know if the “BotMan Web Widget” plugin is still working, I installed it in WordPress and I made the corresponding configurations but it still doesn’t work for me. That’s why I was asking if the whole thing still worked or if it had suddenly gone through some modification, I hope you can help me, I thank you in advance.
    (LATAM)

Leave a comment

Your email address will not be published. Required fields are marked *