• Resolved saeidnaseri

    (@saeidnaseri)


    Hi,

    I’m using the latest Pro version of AI Engine with a valid license, and I’m trying to register a custom PHP function so that it can be called via chatbot using Function Calling. 🔍 My Goal:

    I want to call a PHP function (e.g. fetch_order_info) from a chatbot. I followed the official documentation and used the mwai_functions_list filter along with Meow_MWAI_Query_Function::fromJson() to define and register the function. ✅ What I tried:

    1. I added this code inside the Code Engine → PHP Snippet:

    phpCopy

    Edit

    add_filter('mwai_functions_list', function($functions) { $functions[] = Meow_MWAI_Query_Function::fromJson([ 'id' => 'fetch_order_info', 'type' => 'manual', 'name' => 'fetch_order_info', 'desc' => 'Fetch order data from Airtable', 'args' => [ [ 'name' => 'order_id', 'type' => 'string', 'required' => true, 'desc' => 'Order ID', ], ], ]); return $functions; });

    But I constantly get:

    javascriptCopy

    Edit

    ⚠️ Invalid PHP Function

    Even when trying just the filter line alone. 🧪 Notes:

    • I’ve tested and confirmed that the function body (call_fetch_order_info) works independently.
    • I’m using a Cloudflare Worker as a proxy to fetch data from Airtable.
    • The real issue seems to be the Code Engine not allowing Meow_MWAI_Query_Function::fromJson() or filters like mwai_functions_list.

    ❓What I Need:

    1. Is Function Calling supposed to work inside Code Engine PHP snippets, or must it be registered from theme/plugin only?
    2. Can you please confirm if there’s another way to declare functions for Function Calling entirely within the UI (like Snippet Vault)?
    3. If not, can we at least get a toggle to allow fromJson() inside Code Engine?

    Thank you so much — I’d love to integrate this properly without relying on external plugins if possible.

Viewing 1 replies (of 1 total)
  • Plugin Support Val Meow

    (@valwa)

    Hey @saeidnaseri! 👋

    The forum is reserved for users of the free version of the plugin. If you’re using the PRO version of AI Engine, please log in to your MeowApps account and reach out to us directly through the support there.

    But your issue is related to Code Engine (which is a free plugin), so let me clarify that for you.

    You’re trying to add a filter inside a Callable type snippet, but a filter is not a PHP function declaration. That is why you get an error message. To declare tools for function calling, you can do it in one of two ways:

    1. Using a filter: This should be added in a regular Global scope snippet, and you’ll need to manually handle the tool’s behavior using custom code.
    2. Using a Callable snippet: This is the simpler approach. Just declare your function directly in the snippet, and use the right-side menus in Code Engine to define its arguments. Code Engine will then take care of registering and handling everything automatically.

    Everything is explained in these two documentation pages:

    Hope this helps!

Viewing 1 replies (of 1 total)

The topic ‘[Function Calling Not Working] mwai_functions_list + Meow_MWAI_Query_Function::f’ is closed to new replies.