Hooks and filters
Reference for every Promptor 2.1.0 action and filter, with arguments, defaults and PHP examples for AI endpoints, chat, handoff, leads and MCP.
Promptor exposes WordPress actions and filters you can use from a small custom plugin (better than a child theme's functions.php, because it survives theme changes). Everything below exists in version 2.1.0. Hooks marked Pro only fire when Promptor Pro is active.
Summary
| Hook | Type | Arguments | Edition |
|---|---|---|---|
promptor/openai_chat_endpoint | filter | $url | Free & Pro |
promptor/openai_embeddings_endpoint | filter | $url | Free & Pro |
promptor/openai_models_endpoint | filter | $url | Free & Pro |
promptor/wp_ai_client_factory | filter | $factory | Free & Pro |
promptor/strict_scope | filter | $strict, $context_name | Free & Pro |
promptor/scope_rules | filter | $rules, $site_name, $language, $context_name | Free & Pro |
promptor/chat_extra_context | filter | $extra, $args | Free & Pro |
promptor/chat_unanswered | filter | $unanswered, $args | Free & Pro |
promptor/chat_actions | filter | $actions, $args | Free & Pro |
promptor/chat_handoff | filter | $handoff, $args | Free & Pro |
promptor/handoff_request_keywords | filter | $keywords | Free & Pro |
promptor/handoff_frontend_config | filter | $config | Free & Pro |
promptor_handoff | action | $event | Free & Pro |
promptor/engagement_should_render | filter | $allowed | Free & Pro |
promptor/engagement_frontend_config | filter | $config | Free & Pro |
promptor/booking_intent_pattern | filter | $pattern | Free & Pro |
promptor/public/ui_settings | filter | $settings | Free & Pro |
promptor/public/example_questions | filter | $questions, $context_key | Free & Pro |
promptor/available_languages | filter | $languages | Free & Pro |
promptor/content_selection_post_types | filter | $post_types | Free & Pro |
promptor/default_content_role | filter | $role, $post_type | Free & Pro |
promptor/item_indexed | action | $post_id, $context_name, $chunks | Free & Pro |
promptor/settings_tabs | filter | $tabs | Free & Pro |
promptor_before_insert_submission | filter | $data | Free & Pro |
promptor_after_insert_submission | action | $submission_id, $data | Free & Pro |
promptor_lead_created | action | $submission_id, $lead | Free & Pro |
promptor_lead_scored | action | $submission_id, $score | Pro |
promptor_webhook_payload | filter | $payload, $event, $data | Pro |
promptor_webhook_headers | filter | $headers, $event | Pro |
promptor_webhook_event_enabled | filter | $enabled, $event | Pro |
promptor_before_update_query_products | filter | $products_csv, $query_id | Pro (WooCommerce) |
promptor_after_update_query_products | action | $query_id, $products_csv | Pro (WooCommerce) |
promptor/mcp_route | filter | $route | Pro |
promptor_fs_loaded | action | none | Free & Pro |
Note the two naming styles: most hooks use slashes (promptor/…); the lead, product and webhook hooks use underscores.
AI endpoints
promptor/openai_chat_endpoint
Filters the chat completions URL. Default: https://api.openai.com/v1/chat/completions. Used for chat answers and for Generate with AI.
promptor/openai_embeddings_endpoint
Filters the embeddings URL. Default: https://api.openai.com/v1/embeddings. Used for indexing, for embedding each question and for the Pro MCP server's knowledge search.
promptor/openai_models_endpoint
Filters the models URL. Default: https://api.openai.com/v1/models. Used by Verify Key and the model list refresh.
Use these to route requests through an OpenAI-compatible proxy or gateway. The endpoint must accept the same request and response format as OpenAI and the same Authorization: Bearer key.
add_filter( 'promptor/openai_chat_endpoint', function ( $url ) {
return 'https://ai-gateway.example.com/v1/chat/completions';
} );
add_filter( 'promptor/openai_embeddings_endpoint', function ( $url ) {
return 'https://ai-gateway.example.com/v1/embeddings';
} );
promptor/wp_ai_client_factory
Filters the callable that builds a prompt when the WordPress AI Client provider is selected. Default: the string 'wp_ai_client_prompt'. Return a callable with the same signature to wrap or replace it, for example for logging in tests.
Answer scope
Since 2.1.0 every prompt includes scope rules: the assistant answers only questions about your business, declines general knowledge, code and homework, never invents facts and ignores prompt-injection attempts. Off-topic questions get a short refusal with no recommendations.
promptor/strict_scope
Return false to drop the scope rules, for example for one knowledge base. Default: true.
add_filter( 'promptor/strict_scope', function ( $strict, $context_name ) {
return 'internal-wiki' === $context_name ? false : $strict;
}, 10, 2 );
promptor/scope_rules
Filters the rule text appended to the system prompt. Arguments: $rules, $site_name, $language (the answer language) and $context_name. Not called when strict scope is off.
Chat answers
These four filters run on every answer, before it is sent to the browser. Each receives an $args array with:
| Key | Contents |
|---|---|
user_query | The visitor's question |
context_name | Knowledge base key |
confidence | Best similarity score of the content found (0–1) |
has_context | true if any knowledge base content was found |
explanation | The answer text |
recommendations | Number of recommended services and products |
off_topic | true if the AI flagged the question as out of scope |
(promptor/chat_extra_context runs earlier, while the prompt is built, and gets user_query, context_name and source_post_ids instead.)
promptor/chat_extra_context
Return plain text to add to the system prompt under "ADDITIONAL CONTEXT". Default: empty string. Pro uses it for operating hours and for a signed-in customer's WooCommerce orders.
add_filter( 'promptor/chat_extra_context', function ( $extra, $args ) {
return trim( $extra . "\nOur showroom is closed on public holidays." );
}, 10, 2 );
promptor/chat_unanswered
Decides whether the question is flagged as unanswered (stored in the unanswered column and listed in the Unanswered view). Default: true when no knowledge base content was found and the question was not off-topic. A thumbs-down vote also flags the question. See Review unanswered questions.
promptor/chat_actions
Filters the action chips shown under the answer. Default: an empty array, which Promptor's own features fill: the "Talk to a human" chip from handoff, and the Pro "Book a call" and coupon chips. Each chip is an array with type and label, plus url for open_url and booking, and payload for custom. Supported types: open_url, booking, quote, handoff, coupon, custom. The widget ignores unknown types. When the answer is off-topic, only handoff chips are kept.
add_filter( 'promptor/chat_actions', function ( $actions, $args ) {
if ( false !== stripos( $args['user_query'], 'warranty' ) ) {
$actions[] = array(
'type' => 'open_url',
'label' => 'Warranty terms',
'url' => home_url( '/warranty/' ),
);
}
return $actions;
}, 10, 2 );
A custom chip fires a promptor:action DOM event on document with detail.action (the chip) and detail.context, so your own JavaScript can react. See Action chips under answers.
promptor/chat_handoff
Filters whether the widget should offer a human. Default: array( 'suggest' => false, 'reason' => '', 'summary' => '' ). Promptor's handoff feature sets suggest to true with reason requested or low_confidence.
Human handoff
promptor/handoff_request_keywords
Filters the phrases that count as "I want a person" (English, Turkish, German, Spanish, French, Italian and Portuguese are built in). Matching is case-insensitive and word-boundary aware. Add your own language or wording here.
add_filter( 'promptor/handoff_request_keywords', function ( $keywords ) {
$keywords[] = 'met een medewerker';
return $keywords;
} );
promptor/handoff_frontend_config
Filters the handoff settings passed to the widget: enabled, channels, show_channel_buttons, include_summary, livechat_launch, livechat_custom_js, hours (enabled, is_open, next_open) and away_message.
promptor_handoff
Fires when a visitor picks a handoff channel or opens the live chat. $event holds time, channel, reason (requested, low_confidence or manual), context, summary, page_url, transcript and user_id. Promptor keeps the last 50 events in the option promptor_handoff_log; on Pro it also sends the transcript to Slack or email if you turned that on. See Hand visitors over to a human.
add_action( 'promptor_handoff', function ( $event ) {
error_log( sprintf( 'Promptor handoff via %s (%s)', $event['channel'], $event['reason'] ) );
} );
Engagement
promptor/engagement_should_render
Filters whether the floating popup is shown on the current page, after the page targeting rules in Settings › Engagement have been applied. Return false to hide it.
promptor/engagement_frontend_config
Filters the engagement settings passed to the widget: trigger, trigger_delay, trigger_scroll, greeting, booking_url and booking_label.
promptor/booking_intent_pattern
Filters the regular expression that decides when a question is about booking, which shows the Pro "Book a call" chip. See Greetings, page targeting and engagement triggers.
Front end and language
promptor/public/ui_settings
Filters the merged UI settings for a chat before Promptor turns them into CSS variables and passes them to the widget. Keys match the option promptor_ui_settings, for example primary_color, user_bubble_color, widget_bg_color, header_title, header_subtitle, input_placeholder, font_size, border_radius.
add_filter( 'promptor/public/ui_settings', function ( $settings ) {
if ( is_page( 'support' ) ) {
$settings['header_title'] = 'Support Assistant';
$settings['primary_color'] = '#0f766e';
}
return $settings;
} );
promptor/public/example_questions
Filters the suggested questions shown when the chat opens. $questions holds the questions; $context_key is the knowledge base key.
Check the type of $questions on your install with error_log( print_r( $questions, true ) ) before you replace it, and return the same type.
promptor/available_languages
Filters the languages offered in Settings › UI Settings › Language, as an array of locale => label. By default it lists English plus every bundled translation found in Promptor's languages folder. See Change the plugin language.
Knowledge base
promptor/content_selection_post_types
Filters the post types offered as tabs in content selection. $post_types is an array of WP_Post_Type objects keyed by name. Remove a type to hide its tab.
add_filter( 'promptor/content_selection_post_types', function ( $post_types ) {
unset( $post_types['attachment'], $post_types['e-landing-page'] );
return $post_types;
} );
promptor/default_content_role
Filters the default Content Role for a post type. Return service, product, blog or faq; any other value becomes blog.
add_filter( 'promptor/default_content_role', function ( $role, $post_type ) {
return 'treatment' === $post_type ? 'service' : $role;
}, 10, 2 );
promptor/item_indexed
Fires after a post, page, product, file or Q&A entry has been indexed or re-indexed, whether by Sync, by automatic re-indexing on publish or update, or by saving a Q&A entry. Pages indexed by URL with the Pro crawler don't fire it. Arguments: the post ID, the knowledge base key and the number of chunks created.
Admin
promptor/settings_tabs
Filters the tabs on Promptor's Settings screen, as slug => tab object. A tab object needs a render() method and may have register_settings() and get_label(). Promptor registers its own 2.1.0 tabs (Handoff & Channels, Engagement, MCP Server, WooCommerce Assistant) through this filter.
Leads
promptor_before_insert_submission
Filters the lead row just before it is saved to {prefix}promptor_submissions. $data contains name, email, phone, recommendations, notes, query_id and submitted_at. recommendations is a string such as Services: Web Design, SEO; Products: Starter Kit.
add_filter( 'promptor_before_insert_submission', function ( $data ) {
$data['notes'] = trim( $data['notes'] . "\n\nSource page: " . wp_get_referer() );
return $data;
} );
promptor_after_insert_submission
Fires after a lead is saved. Receives the new row ID and the same $data.
promptor_lead_created
Fires right after a lead is saved and before email and Slack notifications go out. $lead contains id, name, email, phone, message, services (array of service titles) and products. Pro uses this action for webhooks (priority 10) and lead scoring (priority 20).
add_action( 'promptor_lead_created', function ( $submission_id, $lead ) {
wp_remote_post( 'https://crm.example.com/api/leads', array(
'timeout' => 10,
'headers' => array( 'Content-Type' => 'application/json' ),
'body' => wp_json_encode( array(
'external_id' => $submission_id,
'name' => $lead['name'],
'email' => $lead['email'],
'phone' => $lead['phone'],
'services' => $lead['services'],
) ),
) );
}, 10, 2 );
These lead hooks run while the visitor waits for the form to submit. Keep them fast, or queue the work with wp_schedule_single_event(). With Pro you can use webhooks instead.
promptor_lead_scored (Pro)
Fires after Pro has scored a new lead. $score contains lead_id, email, lead_score (0–105), lead_temperature (hot, warm or cold), confidence_level, scoring_factors, scoring_details, scored_at and score_version. Use it when you need the score, which the webhook payload does not contain. See Lead scoring: Hot, Warm and Cold.
Webhooks (Pro)
promptor_webhook_payload, promptor_webhook_headers and promptor_webhook_event_enabled change what Promptor sends to your webhook URL. They are documented with examples in Webhook payload and signature verification.
WooCommerce products (Pro)
promptor_before_update_query_products
Filters the comma-separated list of product IDs about to be saved in products_added_to_cart for a conversation. Arguments: $products_csv, $query_id.
promptor_after_update_query_products
Fires after that list is saved. Arguments: $query_id, $products_csv.
MCP server (Pro)
promptor/mcp_route
Filters the MCP endpoint path under the promptor/v1 REST namespace. The default comes from Endpoint path in Settings › MCP Server (mcp). Allowed characters: letters, digits, _, - and /; anything else falls back to mcp. The admin screen and the connection snippets always show the filtered value. See Connect Claude, ChatGPT or Cursor with the MCP server.
promptor/mcp_is_pro and promptor/mcp_data_service also exist. They are test seams for Promptor's own test suite; don't use them on a live site.
Licensing
promptor_fs_loaded
Fires after Promptor initialises its Freemius licensing SDK. It takes no arguments.
Constants
Define these in wp-config.php only if you know you need them (free edition):
| Constant | Purpose |
|---|---|
PROMPTOR_TRIAL_API_URL | Overrides the free trial backend URL. |
PROMPTOR_TELEMETRY_HMAC_SECRET | Overrides the key used to sign opt-in telemetry. |
PROMPTOR_VERSION, PROMPTOR_PATH and PROMPTOR_URL are defined by the plugin and can be read in your code.
Related
Still need help?
Our support team answers every ticket. Tell us your WordPress version, Promptor version and what you see.
