Support » Plugin: IBM Watson Assistant » Bot stop working ERROR 404

Viewing 1 replies (of 1 total)
  • It seems like you set up force redirect from to exactly the same address with code 301. It’s a problem with your server configuration and there are two issues with it:

    • It forces redirect to https version for this address even if https address is already requested
    • Redirect with code 301 does not preserve POST method, therefore it redirects to the same address

    You can reproduce that behaviour by going on any of your site’s pages (for example, front page, not error pages or nonexistent ones). Open developer console and execute Javascript code below (copy there, paste in cosole and hit Enter) to recreate normal chatbot request from widget. Let’s assume that you use Chrome, but this example won’t be much different in any other modern browser.

    // Simulating normal request from chatbot frontend
    // Creating legal object for sending user input
    // null in session_id tells that there is no session yet and plugin should create one
    var testUserInput = {
        input: {
            message_type: "text",
            text: "test text" 
        session_id: null
    // Serializing test user input to JSON
    var jsonUserInput = JSON.stringify(testUserInput);
    // HTTPS Address to send request to
    var testAddress = "";
    // Object representing server request
    var testRequest = new XMLHttpRequest();
    // Setting parameters for request
    // "POST" - method
    // testAddress - variable with address
    // true - making request asynchronous"POST", testAddress, true);
    // Setting header with nonce for WordPress REST API authorization
    // WP REST API nonces are stored in JS global variable wpApiSettings.nonce
    testRequest.setRequestHeader("X-WP-Nonce", wpApiSettings.nonce);
    // Setting Content-Type to application/json
    testRequest.setRequestHeader("Content-Type", "application/json");
    // Sending request to server with JSON

    After executing this request you can go to “Network” tab and see that there are two requests: first is the POST with 301 (redirect), second is the GET with 404 (not found).

    In the plugin’s server side code there isn’t any code that responds with 301 code and redirects, therefore it’s your server’s redirect misconfiguration. It’s even more likely after previously found issues with the lack of redirect to HTTPS on your website.

    If we will change our taget address from example code to alternate one with REST API root provided by WordPress itself on its pages with wpApiSettings.root + “watsonconv/v1/message” (variable testAddress in the code above), on the Network tab we would see that request goes to and fails with 404 because of nonexistent REST route (explained futher) and doesn’t have any redirects. It means that you have improperly configured 301 redirect for one exact address: (/index.php?rest_route=/watsonconv/v1/message).

    Bot’s REST route may be be nonexistent in only two cases: ether chat widget is disabled or it is not called with POST method. Fact that plugin is disabled is proven further by absence of specific plugin related code in the source code of your pages.

    REST API definitely works because request to address responds with the list of the posts on your site. Note that it doesn’t have any redirects.

    Properly reconfigured redirect should solve the problem. If not, we will gladly investigate this issue further.

    Github Gist with normal and alternate address request code

    • This reply was modified 8 months, 1 week ago by  kaneua.
    • This reply was modified 8 months, 1 week ago by  kaneua. Reason: Prettier formatting
    • This reply was modified 8 months, 1 week ago by  kaneua.
Viewing 1 replies (of 1 total)
  • The topic ‘Bot stop working ERROR 404’ is closed to new replies.