• Resolved samymsa

    (@samymsa)


    Hi Maxwell,

    It would be great to be able to provide dynamic data into the chatbot prompt.

    For example, I would need to inject today’s date in order for the user to ask “Tell me about the events of this month.”

    It could be either by allowing wordpress shortcodes into the system prompt, or by providing developers with a custom hook.

    Thanks again for all the good work!

    Samy

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter samymsa

    (@samymsa)

    I see there is mxchat_prepare_context filter I could maybe use

    Plugin Support m4xw3ll

    (@m4xw3ll)

    Hi @samymsa,

    Yes you can pass dynamic data via that filter. Here is an example you can add to your functions.php file:

    add_filter('mxchat_prepare_context', function($context, $session_id) {
    $today = date('F j, Y');
    $time = date('g:i A');
    $timezone = wp_timezone_string(); // WordPress configured timezone

    $dynamic_info = "The current date/time is {$today} at {$time} ({$timezone}). Note: This is the server time, not necessarily the user's local time.\n\n";

    return $dynamic_info . $context;
    }, 10, 2);

    This filter was actually meant for this exact purpose! I never did fully roll it out publicly, it’s somewhat of a hidden gem. I will work on getting an entire page up for it within the next week or two and update the readme, but I did make this page a few months back which talks about it some.

    Thread Starter samymsa

    (@samymsa)

    I’ll try this, thanks for your quick answer!

    Thread Starter samymsa

    (@samymsa)

    Hi Maxwell,

    Following up our conversation, would it be possible for you to add a hook that allows to alter the system_prompt_instructions, or maybe simpler to allow shortcodes inside the system prompt (not into the current message context)?

    This way we would be able to add dynamic data into the system prompt. I’m currently forced to use a mu-plugin and hook into the get_options, which is not ideal.

    Best,
    Samy

    Thread Starter samymsa

    (@samymsa)

    Closing this topic and opening a dedicated one about dynamic data / shortcodes inside system prompt.

    Thanks again for you support @m4xw3ll !

Viewing 5 replies - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.