Filter uncanny-automator

uap_fl_support_ticket_response_tokens

Filters support ticket response tokens when a response is added by a customer or agent within Fluent Support.

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

Description

Fires when retrieving tokens for Fluent Support ticket responses. Developers can filter the available tokens to add or remove specific response-related events, such as customer or agent responses, for advanced integrations or custom token logic. This hook allows manipulation of the token array before it's used.


Usage

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

Parameters

$args (mixed)
This parameter contains an array of strings representing specific actions within the FluentSupport integration that can trigger token generation.

Return Value

The filtered value.


Examples

/**
 * Example function to modify the Fluent Support ticket response tokens.
 * This function demonstrates how to add, remove, or alter the available tokens
 * that can be used within the UAP plugin when a new response is added to a support ticket.
 *
 * @param array $tokens The original array of available tokens.
 * @param array $args   Additional arguments passed to the filter.
 * @return array The modified array of tokens.
 */
add_filter( 'uap_fl_support_ticket_response_tokens', function( $tokens, $args ) {
	// Check if $args contains information about the ticket or response context if needed.
	// For this example, we'll assume we want to add a specific token only when
	// a response is added by a customer, and remove a token for agent responses.

	if ( isset( $args['response_type'] ) && $args['response_type'] === 'customer' ) {
		// Add a new custom token for customer responses.
		$tokens[] = 'fluent_support/custom_customer_response_token';
	}

	// Remove the token for agent responses if it exists.
	$key = array_search( 'fluent_support/response_added_by_agent', $tokens );
	if ( $key !== false ) {
		unset( $tokens[ $key ] );
	}

	// Re-index the array after unsetting to ensure clean keys.
	return array_values( $tokens );

}, 10, 2 );

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:64

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

			$ticket_response_token_actions = apply_filters(
				'uap_fl_support_ticket_response_tokens',
				array(
					'fluent_support/response_added_by_customer',
					'fluent_support/response_added_by_agent',
				),
				$args
			);


Scroll to Top