Code Voorbeelden
Klaar-om-te-gebruiken componenten en hooks voor je Next.js website. Alle voorbeelden integreren met het Venius ERP systeem.
📋 Code Voorbeelden
// app/hooks/useVisitorContext.ts
import { useEffect, useState } from 'react';
interface VisitorContext {
ip: string;
city: string;
region: string;
country: string;
countryCode: string;
org: string;
isLikelyBusinessConnection: boolean;
}
export function useVisitorContext() {
const [context, setContext] = useState<VisitorContext | null>(null);
const [loading, setLoading] = useState(true);
useEffect(() => {
async function fetchContext() {
try {
const response = await fetch('/api/visitor-context', {
method: 'POST',
});
const data = await response.json();
setContext(data.visitorContext);
} catch (error) {
console.error('Failed to fetch visitor context:', error);
} finally {
setLoading(false);
}
}
fetchContext();
}, []);
return { context, loading };
}💡 Tips:
- Gebruik
useVisitorContextop de homepage - Roep
useCompanyLookupaan op blur van emailveld - Confidence > 80% → agressieve suggestie
- Confidence 50-79% → voorzichtig voorstel
- Confidence < 50% → niks invullen
🔌 API Endpoints
POST /functions/leadbotApi
action: visitor_context
Haalt IP-context op: stad, regio, land, organisatie
POST /functions/leadbotApi
action: company_lookup
Zoekt bedrijf: CRM-match, KvK-data, confidence score
POST /functions/publicChatbot
message + visitor_email
AI chatbot met company-context. Auto scheduling + email drafts bij confidence > 80%
⚙️ Automatische Acties (Confidence > 80%)
✅ Google Calendar
Automatisch 30-min kwalificatie-afspraak morgen 10:00 met Google Meet link
✅ Email Concept
AI genereert gepersonaliseerde opvolgings-email op basis van KvK-data
✅ Lead Notes
IP-context, KvK-gegevens en confidence score opgeslagen voor team
