// Farvision Smatbot Webhook
add_action('rest_api_init', function() {
    register_rest_route('farvision/v1', '/smatbot', array(
        'methods'  => 'POST',
        'callback' => 'handle_smatbot_webhook',
        'permission_callback' => '__return_true'
    ));
});

function handle_smatbot_webhook($request) {
    $body = $request->get_json_params();
    $data = $body['data'] ?? [];

    $name  = '';
    $phone = '';
    $email = '';

    foreach ($data as $item) {
        $q = strtolower($item['question_text'] ?? '');
        $a = $item['answer'] ?? '';

        if (strpos($q, 'name') !== false)  $name  = sanitize_text_field($a);
        if (strpos($q, 'mobile') !== false || strpos($q, 'phone') !== false) $phone = sanitize_text_field($a);
        if (strpos($q, 'email') !== false) $email = sanitize_email($a);
    }

    if (empty($phone)) return new WP_REST_Response(['status' => 'skipped'], 200);

    $name_parts = explode(' ', $name, 2);
    $first_name = $name_parts[0] ?? '';
    $last_name  = $name_parts[1] ?? '';

    $payload = array(
        'firstName'           => $first_name,
        'lastName'            => $last_name,
        'email'               => $email,
        'countryCode1'        => '91',
        'mobilePhone'         => $phone,
        'comments'            => 'Lead from Smatbot',
        'originFrom'          => 'Website',
        'product'             => 'ANANTAM',
        'campaign'            => 'SmatBot',
        'externalAPIObjectId' => 'Website',
        'DumpdataObjectId'    => date('YmdHis'),
        'tenantId'            => '996'
    );

    wp_remote_post('https://fvintegration.farvisioncloud.com/LeadSync/api/SyncLeadsV2/RawLeads', array(
        'method'  => 'POST',
        'headers' => array('Content-Type' => 'application/json'),
        'body'    => json_encode($payload),
        'timeout' => 15
    ));

    return new WP_REST_Response(['status' => 'success'], 200);
}<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="//motwaniconstructions.com/main-sitemap.xsl"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
	<sitemap>
		<loc>https://motwaniconstructions.com/post-sitemap.xml</loc>
		<lastmod>2026-04-30T08:53:02+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://motwaniconstructions.com/page-sitemap.xml</loc>
		<lastmod>2026-04-24T05:51:11+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://motwaniconstructions.com/job-sitemap.xml</loc>
		<lastmod>2026-02-26T19:10:07+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://motwaniconstructions.com/category-sitemap.xml</loc>
		<lastmod>2026-02-25T11:18:23+00:00</lastmod>
	</sitemap>
</sitemapindex>
<!-- XML Sitemap generated by Rank Math SEO Plugin (c) Rank Math - rankmath.com -->