VAT
Your cart

Your cart is empty.

Tools hooks

This page lists the 8 hooks of this group. Each entry shows its type, the version it arrived in, where it runs, its arguments and a starting point.

addochat_account_data

FilterSince 0.2.0 Runs in src/Tools/MyAccount.php.

Filters what the assistant gets about the account of the logged-in visitor. Remove fields you do not want sent to the AI or webhook (for example phone or addresses), or add your own.

ArgumentTypeDescription
$dataarray<string, mixed>Account: name, email, phone, billing, shipping, orders, customer_since.
$user\WP_UserThe logged-in customer.
add_filter( 'addochat_account_data', function ( $data, $user ) {
	return $data;
}, 10, 2 );

addochat_order_by_number

FilterSince 0.1.0 Runs in src/Tools/LookupOrder.php.

Filters the order for an order number. Return a WC_Order when the shop uses its own numbering; return false when the number is not an order of this shop, so AddoChat does not try it as an order id (own numbers can overlap with the ids of other orders); leave null to use the order id.

ArgumentTypeDescription
$order\WC_Order|false|nullOrder found so far.
$numberstringOrder number as the visitor gave it.
add_filter( 'addochat_order_by_number', function ( $order, $number ) {
	return $order;
}, 10, 2 );

addochat_order_tracking

FilterSince 0.1.0 Runs in src/Tools/LookupOrder.php.

Filters the tracking of an order. WooCommerce has no standard place for it; return a list of carrier, code and url from your shipping plugin.

ArgumentTypeDescription
$trackingarray<int, array{carrier: string, code: string, url: string}>Tracking, empty by default.
$order\WC_OrderThe order.
add_filter( 'addochat_order_tracking', function ( $tracking, $order ) {
	return $tracking;
}, 10, 2 );

addochat_page_context

FilterSince 0.2.0 Runs in src/Tools/PageText.php.

Filters the text of a page the assistant or a colleague reads, for example to add custom fields or leave out a part. Return '' to give nothing.

ArgumentTypeDescription
$textstringPlain text of the content, paragraphs separated by a blank line.
$post\WP_PostThe post.
$urlstringAddress the visitor is on.
add_filter( 'addochat_page_context', function ( $text, $post, $url ) {
	return $text;
}, 10, 3 );

addochat_product_query_args

FilterSince 0.1.0 Runs in src/Tools/SearchProducts.php.

Filters the wc_get_products() arguments of the product search tool.

ArgumentTypeDescription
$argsarray<string, mixed>Query arguments.
$querystringSearch words.
$context\Addochat\Tools\ContextWho the call is for.
add_filter( 'addochat_product_query_args', function ( $args, $query, $context ) {
	return $args;
}, 10, 3 );

addochat_tool_called

ActionSince 0.1.0 Runs in src/Tools/Registry.php.

Fires after a tool ran. No input or result: use addochat_tool_result for those.

ArgumentTypeDescription
$namestringTool name.
$context\Addochat\Tools\ContextWho the call is for.
$okboolWhether it worked.
$durationintMilliseconds.
add_action( 'addochat_tool_called', function ( $name, $context, $ok, $duration ) {
	// ...
}, 10, 4 );

addochat_tool_result

FilterSince 0.1.0 Runs in src/Tools/Registry.php.

Filters the result of a tool before the assistant sees it.

ArgumentTypeDescription
$resultarray<string, mixed>content (text for the model), data, is_error, and maybe cards, handoff and refs (since 0.2.0: what it used, as type order|product|customer|page and id) and cart (since 0.2.0: products offered for the cart).
$namestringTool name.
$context\Addochat\Tools\ContextWho the call is for.
add_filter( 'addochat_tool_result', function ( $result, $name, $context ) {
	return $result;
}, 10, 3 );

addochat_tools

FilterSince 0.1.0 Runs in src/Tools/Registry.php.

Filters the tools of AddoChat. Add an object that implements \Addochat\Tools\Tool; it shows in the allowed tools setting, the MCP server and the Direct backend.

ArgumentTypeDescription
$toolsarray<int, \Addochat\Tools\Tool>Tools.
add_filter( 'addochat_tools', function ( $tools ) {
	return $tools;
} );

Ready to connect your AI to real tools?

Start free trial