Create Your Business Profile
This will be the knowledge base of your AI. It will use this information to answer questions about your business.
1. Business Snapshot
2. Hours & Location
3. Services & Pricing
4. Frequently Asked Questions
5. Additional Notes
'POST',
'callback' => 'airx_save_prompt',
'permission_callback' => function () { return is_user_logged_in(); },
'args' => [
'prompt' => [
'required' => true,
'sanitize_callback' => 'airx_sanitize_markdown',
],
],
] );
// POST /ai-reception/v1/import-site
register_rest_route( 'ai-reception/v1', '/import-site', [
'methods' => 'POST',
'callback' => 'airx_import_site',
'permission_callback' => function () { return is_user_logged_in(); },
'args' => [
'url' => [
'required' => true,
'sanitize_callback' => 'esc_url_raw',
'validate_callback' => function ( $v ) { return filter_var( $v, FILTER_VALIDATE_URL ); },
],
],
] );
// GET /ai-reception/v1/get-imported-site
register_rest_route( 'ai-reception/v1', '/get-imported-site', [
'methods' => 'GET',
'callback' => 'airx_get_imported_site',
'permission_callback' => function () { return is_user_logged_in(); },
] );
} );
function airx_save_prompt( WP_REST_Request $req ) {
$user_id = get_current_user_id();
$prompt = $req->get_param( 'prompt' );
update_user_meta( $user_id, 'ai_receptionist_prompt', $prompt );
return new WP_REST_Response( [ 'success' => true, 'message' => 'Prompt saved.' ], 200 );
}
function airx_import_site( WP_REST_Request $req ) {
$user_id = get_current_user_id();
$url = $req->get_param( 'url' );
$response = wp_remote_get( $url, [
'timeout' => 20,
'redirection' => 5,
'user-agent' => 'AI-Receptionist/1.0 (+'. home_url() .')',
] );
if ( is_wp_error( $response ) ) {
return new WP_REST_Response( [ 'success' => false, 'message' => $response->get_error_message() ], 400 );
}
$html = wp_remote_retrieve_body( $response );
if ( ! $html ) {
return new WP_REST_Response( [ 'success' => false, 'message' => 'Empty response body.' ], 400 );
}
$text = preg_replace( '/\s+/', ' ', wp_strip_all_tags( $html ) );
$chunks = airx_chunk_text( $text, 2000 );
$summary = array_map( 'airx_summarise_chunk', $chunks );
$prompt = trim( implode( "\n\n", $summary ) );
update_user_meta( $user_id, 'ai_import_url', $url );
update_user_meta( $user_id, 'ai_import_prompt', $prompt );
update_user_meta( $user_id, 'ai_receptionist_prompt', $prompt );
return new WP_REST_Response( [
'success' => true,
'url' => $url,
'prompt' => $prompt,
'len' => strlen( $prompt ),
], 200 );
}
function airx_get_imported_site() {
$user_id = get_current_user_id();
return [
'url' => get_user_meta( $user_id, 'ai_import_url', true ),
'prompt' => get_user_meta( $user_id, 'ai_import_prompt', true ),
];
}
/* Helpers */
function airx_chunk_text( $text, $size = 2000 ) {
$out = [];
$len = strlen( $text );
for ( $i = 0; $i < $len; $i += $size ) {
$out[] = substr( $text, $i, $size );
}
return $out;
}
function airx_summarise_chunk( $text ) {
// Placeholder summariser: first 1–2 sentences, ≤512 chars.
$summary = preg_replace( '/^((?:[^.!?]+[.!?]\s*){1,2}).*/', '$1', $text );
return substr( trim( $summary ), 0, 512 );
}
function airx_sanitize_markdown( $md ) {
return wp_kses_post( $md );
}
/* ───────────────────────────── Shortcode ─────────────────────────── */
add_action( 'init', function () {
add_shortcode( 'ai_receptionist_all', 'airx_render_shortcode' );
} );
function airx_render_shortcode() {
$user_id = get_current_user_id();
$saved_prompt = get_user_meta( $user_id, 'ai_receptionist_prompt', true );
$nonce = wp_create_nonce( 'wp_rest' );
ob_start(); ?>
AI Receptionist: Prompt Manager
Build or import the knowledge base your phone bot will use to answer concisely.
1. Business Snapshot
2. Hours & Location
3. Services & Pricing
4. Frequently Asked Questions
5. Additional Notes
Import From Website
Working…
⚠️ Please log in to edit this section.