• Resolved djjcnncxn09

    (@djjcnncxn09)


    Hello AI Engine Support Team,

    I am using your plugin for a chatbot on my website and have an important request:

    1. Remove the red error box:
      I want to prevent the red error box from appearing at the bottom of the page when an error occurs from OpenAI or the server.
    2. Display the error as a chatbot message:
      Instead of showing a separate error box, the error should appear as a normal chatbot message within the chat interface, so the user perceives it as part of the bot’s response.
    3. Do not delete the user’s message on error:
      When an error occurs, the user’s message that triggered the error should not be deleted or removed; it must remain visible in the chat history.

    I have tried implementing this using the mwai_ai_exception and mwai_ai_reply filters, as well as overriding the handleError JavaScript function, but I was not successful.

    Please advise how I can best implement these changes in the plugin or if there is a standard solution for this issue.

    Thank you for your cooperation and support.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Jordy Meow

    (@tigroumeow)

    Hi @djjcnncxn09,

    Actually, I totally agree with you! I had a different idea at first, but I’ve now implemented this. Starting from the next release, errors will show up as part of the conversation. They’ll also be deleteable and retryable. If the discussion is reloaded, the errors will reappear too (unless they’ve been deleted, of course). I tried to make it all work more logically and smoothly. Feel free to share any feedback once the next release is out (in 3–4 days max) 👍 Meanwhile, have a nice week-end!

    Thread Starter djjcnncxn09

    (@djjcnncxn09)

    Thank you for your understanding and support. Now I have another problem. I want to use the plugin shortcode in the Elementor popup, but it doesn’t show in the popup and the page remains blank.

    Plugin Support Val Meow

    (@valwa)

    Hey @djjcnncxn09! 👋

    This is probably happening because the pop-up is rendering the shortcode dynamically after the script to initialize the chatbots has already been loaded on your page, so it will appear blank as it is uninitialized. When you’re trying to show the chatbot dynamically, you will need to initialize it at that moment. For this, there is a DOM window-available function you can call anytime: mwaiInitialize(). Hope this helps!

    Thread Starter djjcnncxn09

    (@djjcnncxn09)

    So what solution do you suggest to solve this problem?

    Plugin Support Val Meow

    (@valwa)

    Hey @djjcnncxn09! 👋

    You will need to call the mwaiInitialize() function whenever you’re loading the Chatbot shortcode dynamically (or when the script has already been loaded). In your case, listen for when the popup is opened and then call this function (available directly from window) to properly render the shortcode.

    Thread Starter djjcnncxn09

    (@djjcnncxn09)

    Can you create a code that solves this problem?

    Plugin Support Val Meow

    (@valwa)

    Hey @djjcnncxn09! 👋

    This ultimately depends on your specific setup, so there is no single snippet to handle all use cases. Here is one way you could go about it: add an observer for the display style of your popup, and when it’s visible, call the init method.

    const popup = document.getElementById('my-popup');

    const observer = new MutationObserver(() => {
    const style = window.getComputedStyle(popup);
    if (style.display !== 'none') {
    mwaiInitialize();
    }
    });

    observer.observe(popup, { attributes: true, attributeFilter: ['style', 'class'] });
Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Request: Display API errors as chatbot messages and remove error box’ is closed to new replies.