Online Chat Integration (Intercom) on Website
Intercom is a product messenger for B2B and SaaS products. Combines support chat, knowledge base, proactive messaging, and product usage analytics. Oriented at SaaS and B2B — for e-commerce there are cheaper alternatives.
Messenger Installation
<script>
window.intercomSettings = {
api_base: "https://api-iam.intercom.io",
app_id: "YOUR_APP_ID",
// For authorized users:
user_id: "<?= $user->id ?>",
name: "<?= $user->name ?>",
email: "<?= $user->email ?>",
created_at: <?= $user->created_at->timestamp ?>,
user_hash: "<?= $userHash ?>" // HMAC for verification
};
</script>
<script>
(function(){var w=window;var ic=w.Intercom;/* snippet */})();
</script>
HMAC Verification
$userHash = hash_hmac('sha256', (string)$user->id, env('INTERCOM_SECRET_KEY'));
Custom Attributes
window.Intercom('update', {
plan: 'pro',
monthly_spend: 150,
is_paying: true,
last_product_used: 'dashboard'
});
Event Tracking
window.Intercom('trackEvent', 'feature-used', {
feature: 'export',
format: 'csv',
record_count: 1250
});
REST API: Creating Notes and Tasks
Http::withToken(env('INTERCOM_ACCESS_TOKEN'))
->post('https://api.intercom.io/notes', [
'user' => ['user_id' => $userId],
'body' => "Placed order #{$orderId} for {$total} ₽"
]);
Messenger API (Inbox)
To create conversation programmatically (e.g., at registration):
Http::withToken($token)
->post('https://api.intercom.io/conversations', [
'from' => ['type' => 'user', 'id' => $intercomUserId],
'body' => "Hello! I have a question about order #{$orderId}"
]);
Setup timeframe: 1 day with custom attributes and events.







