'ailig_knowflow_chatbot_sanitize_settings']
);
add_settings_section(
'ailig_knowflow_chatbot_ailig_section',
'Ailig KnowFlow Settings',
'ailig_section_cb',
'ailig-knowflow-ai-chatbot-settings'
);
add_settings_section(
'ailig_knowflow_chatbot_main_section',
'Widget Customizations',
null,
'ailig-knowflow-ai-chatbot-settings'
);
$fields = [
'api_key' => [
'label' => 'Ailig KnowFlow API Key',
'section' => 'ailig_knowflow_chatbot_ailig_section',
'description' => 'Your API key from Ailig KnowFlow to your website assistant to the service.'
],
'tenant_id' => [
'label' => 'Ailig KnowFlow Tenant ID',
'section' => 'ailig_knowflow_chatbot_ailig_section',
'description' => 'Your Tenant ID identifies your account within Ailig KnowFlow.'
],
'chatbot_id' => [
'label' => 'Ailig KnowFlow ChatBot ID',
'section' => 'ailig_knowflow_chatbot_ailig_section',
'description' => 'The ID of the chatbot you created in Ailig KnowFlow.'
],
'recaptcha_site_key' => [
'label' => 'Google Recaptcha V3 Site Key (optional)',
'section' => 'ailig_knowflow_chatbot_ailig_section',
'description' => 'Use your existing Recaptcha key if present, for spam protection in the chatbot form.'
],
'background_color' => [
'label' => 'Widget Primary Color',
'section' => 'ailig_knowflow_chatbot_main_section',
'description' => 'Main widget color (used for Button-Background, Headline, and Buttons).',
'is_color_picker' => true
],
'color' => [
'label' => 'Widget Secondary Color',
'section' => 'ailig_knowflow_chatbot_main_section',
'description' => 'Color for Icon, Header-Background and Text.',
'is_color_picker' => true
],
'start_message' => [
'label' => 'Start Message',
'section' => 'ailig_knowflow_chatbot_main_section',
'description' => 'The first message that appears in the chat when the assistant opens.'
],
'headline' => [
'label' => 'Widget Headline',
'section' => 'ailig_knowflow_chatbot_main_section',
'description' => 'The headline/title displayed at the top of the chatbot window.'
],
];
foreach ( $fields as $key => $props ) {
add_settings_field(
$key,
$props['label'],
function( $args ) {
$opts = get_option( 'ailig_knowflow_chatbot_settings' );
$key = $args['key'];
$value = $opts[ $key ] ?? '';
$description = $args['description'] ?? '';
$is_color_picker = !empty( $args['is_color_picker'] );
printf(
'
%3$s',
esc_attr( $key ),
esc_attr( $opts[ $key ] ?? '' ),
esc_attr( $description )
);
},
'ailig-knowflow-ai-chatbot-settings',
$props['section'],
[
'key' => $key,
'description' => $props['description'] ?? '',
'is_color_picker' => $props['is_color_picker'] ?? false,
]
);
}
}
function ailig_section_cb(){
echo "";
}
function ailig_knowflow_chatbot_sanitize_settings( $input ) {
return array_map( 'sanitize_text_field', (array) $input );
}
function ailig_knowflow_chatbot_render_settings_page() {
?>
Welcome to the Ailig KnowFlow Website Assistant / Chatbot settings page.
To use the chatbot, you need to create your API credentials at Ailig KnowFlow.
Once you have your API Key, Tenant ID, and Chatbot ID, enter them below.