Filter uncanny-automator

uap_fl_support_agent_tokens

Filters the tokens available for support agent notifications when ticket events occur.

add_filter( 'uap_fl_support_agent_tokens', $callback, 10, 1 );

Description

This filter hook `uap_fl_support_agent_tokens` allows developers to modify the list of Fluent Support event slugs that trigger agent-specific tokens. Use it to add or remove event types from the default set ('fluent_support/response_added_by_customer', 'fluent_support/ticket_closed_by_customer', 'fluent_support/response_added_by_agent') based on your integration needs.


Usage

add_filter( 'uap_fl_support_agent_tokens', 'your_function_name', 10, 1 );

Parameters

$args (mixed)
This parameter contains an array of strings representing the event types within Fluent Support that an agent token might be associated with.

Return Value

The filtered value.


Examples

/**
 * Example of how to hook into 'uap_fl_support_agent_tokens' to add or modify
 * the list of Fluent Support actions that trigger agent token generation.
 *
 * In this example, we'll add a new action ('fluent_support/new_ticket_assigned')
 * and remove an existing one ('fluent_support/ticket_closed_by_customer')
 * if a specific condition is met (e.g., if the current user is an administrator).
 *
 * @param array $agent_token_actions The array of Fluent Support action slugs.
 * @param mixed $args The additional arguments passed to the apply_filters call.
 * @return array The modified array of Fluent Support action slugs.
 */
add_filter( 'uap_fl_support_agent_tokens', function( $agent_token_actions, $args ) {

	// Check if the current user is an administrator.
	if ( current_user_can( 'manage_options' ) ) {
		// Add a new action if the user is an admin.
		$agent_token_actions[] = 'fluent_support/new_ticket_assigned';

		// Remove 'fluent_support/ticket_closed_by_customer' if it exists.
		if ( ( $key = array_search( 'fluent_support/ticket_closed_by_customer', $agent_token_actions ) ) !== false ) {
			unset( $agent_token_actions[ $key ] );
		}
	}

	// Return the potentially modified array of actions.
	return $agent_token_actions;
}, 10, 2 ); // Priority 10, accepts 2 arguments ($agent_token_actions, $args)

Placement

This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.


Source Code

src/integrations/fluent-support/tokens/flsupport-tokens.php:54

'fluent_support/response_added_by_customer',
					'fluent_support/ticket_closed_by_customer',
					'fluent_support/response_added_by_agent',
				),
				$args
			);

			$agent_token_actions = apply_filters(
				'uap_fl_support_agent_tokens',
				array(
					'fluent_support/response_added_by_customer',
					'fluent_support/ticket_closed_by_customer',
					'fluent_support/response_added_by_agent',
				),
				$args


Scroll to Top