ai newsFr., 4. Dez.
EilmeldungAlibaba Releases Qwen4-35B-A3B: Open-Weight MoE Model With 1M Context

WhatsApp-Widget für React und HTML ohne Abhängigkeiten mit optionaler KI-Anbindung

Ein Entwickler hat ein eigenständiges WhatsApp-Widget veröffentlicht, das formbasierte Anfragen mit Kontext zur besuchten Seite anstelle leerer Chat-Nachrichten bietet. Optionale Funktionen umfassen BYO-AI, Live-Chat und Lead-Erfassung.

dev.toMittwoch 16:50 · 02.12.DE2 Min. Lesezeit
Bild: dev.to

Die meisten WhatsApp-Widgets auf npm sind lediglich ein schwebendes Icon, das Besucher in eine leere Chat-Box fallen lässt. Unternehmen erhalten am Ende vage „Hi“-Nachrichten, keinerlei Kontext darüber, welche Seite der Besucher gerade angesehen hat, und keine Aufzeichnung von Leads, die auf die Schaltfläche geklickt, WhatsApp aber geschlossen haben, bevor sie auf Senden drückten.

Ich habe whatsapp-chat-widget-react entwickelt (jetzt in Version v0.8.0 und bereits in den ersten Tagen über 320 wöchentliche Downloads!), um dieses Problem mit einer formularzentrierten, abhängigkeitsfreien und datenschutzfreundlichen Architektur zu lösen, plus einem eigenständigen <script>-Tag-Build für Websites, die kein React verwenden.

👉 Probiere das interaktive Live-Playground aus | ⭐ GitHub-Repository | 📦 npm-Paket

Formularzentrierte Vorqualifizierung (standardmäßig ohne Backend erforderlich) Besucher füllen ein sauberes, barrierefreies Kontaktformular aus (Name, Betreff, Nachricht) und übergeben einen formatierten Entwurf direkt an https://wa.me.... Kein API-Schlüssel, kein Server und kein Konto sind direkt nach der Installation nötig.

Datenschutzsicherer Seitenkontext und UTM-Attribution ( includePageContext ) Hängt automatisch den Seitentitel, die URL und UTM-Tags an ( utm_source, utm_medium, utm_campaign ), entfernt dabei aber standardmäßig Query-Strings und URL-Hashes, damit sensible Authentifizierungstokens in URLs niemals in Chat-Protokolle gelangen. (Tipp: Klicke auf den Playground-Link oben und sende eine Testnachricht, um die utm_source=devto-Attribution in Aktion zu sehen!)

Teams, Zeitzonen-Geschäftszeiten und intelligente Standardwerte

Optionaler Live-Chat im Widget und Webhook-Transport ( v0.8.0 ) Möchtest du, dass Besucher auf deiner Website bleiben, statt zur WhatsApp-App zu wechseln? Stelle den Transport auf den Live-Modus um, indem du createWebhookTransport ( whatsapp-chat-widget-react/adapters ) verwendest, um n8n, Make, Zapier oder einen WhatsApp-Cloud-API-Proxy anzubinden, komplett mit sessionStorage-Persistenz, Zustellungsstatus, Retry-Handling und einer „In WhatsApp fortfahren“-Ausweichoption.

Bring-Your-Own-AI ( v0.8.0, ohne SDK-Bloat) Verbinde jeden beliebigen /v1/chat/completions-Endpunkt (OpenAI, Claude über OpenRouter/LiteLLM, Cloudflare AI Gateway, Groq, Ollama) über createOpenAICompatibleAI:

Popup-Blocker-sichere Lead-Erfassung ( webhookUrl ) Versendet nicht-blockierende JSON-Lead-Payloads über navigator.sendBeacon (mit fetch-keepalive-Fallback) genau in dem Moment, in dem der Nutzer das Formular absendet. Falls ein asynchroner AI- oder Webhook-Schritt die Klick-Aktivierung des Browsers verbraucht, rendert das Widget automatisch eine „WhatsApp öffnen“-Schaltfläche, anstatt von einem Popup-Blocker verschluckt zu werden.

Programmatische Steuerung ( useWhatsAppWidget() ) Löse das Widget über einen beliebigen Preisrechner, Navbar-CTA oder Seiten-Button mit openWithDraft({ subject: 'Enterprise Plan', message: '...' }) aus.

npm install whatsapp-chat-widget-react Enter fullscreen mode Exit fullscreen mode import { WhatsAppChat } from 'whatsapp-chat-widget-react'; export function App ( ) { return ( < WhatsAppChat phoneNumber = "+2348000000000" title = "Support Team" includePageContext theme = "auto" /> ); } Enter fullscreen mode Exit fullscreen mode Schnellstart: Reines HTML / ohne React ( dist/standalone.global.js ) Du verwendest reines HTML, Webflow, Shopify oder Squarespace? Binde das abhängigkeitsfreie Script-Tag über jsDelivr oder unpkg ein (komplett mit Shadow-DOM-Isolation und Subresource Integrity):

<script src = "https://jsdelivr.net" data-phone = "+2348000000000" data-title = "Support Team" data-include-context = "true" defer ></script> Enter fullscreen mode Exit fullscreen mode Links und Dokumentation Interaktives Playground: https://mcdavidobioha.github.io/whatsapp-chat-widget-react-typescript GitHub-Repository: https://github.com/mcdavidobioha/whatsapp-chat-widget-react-typescript Vollständige Feature-Übersicht: FEATURES.md npm-Paket: https://www.npmjs.com/package/whatsapp-chat-widget-react Feedback, Sterne, Issues und PRs sind willkommen!

Automatisch übersetzt. Das Original auf Englisch ist unten aufklappbar.

Original (Englisch) anzeigen

Most WhatsApp widgets on npm are just a floating icon that drops visitors into an empty chat box. Businesses end up with vague "Hi" messages, zero context on what page the visitor was viewing, and no record of leads who clicked the button but closed WhatsApp before hitting send.

I built whatsapp-chat-widget-react (now at v0.8.0 and already crossing 320+ weekly downloads in its first few days!) to solve this with a form-first, zero-dependency, privacy-aware architecture—plus a standalone <script> tag build for sites that don't use React.

👉 Try the Interactive Live Playground | ⭐ GitHub Repository | 📦 npm Package

Form-First Pre-Qualification (Zero Backend Required by Default) Visitors fill out a clean, accessible contact form (Name, Subject, Message) and hand off a formatted draft straight to https://wa.me.... No API key, server, or account required out of the box.

Privacy-Safe Page Context & UTM Attribution ( includePageContext ) Automatically appends the page title, URL, and UTM tags ( utm_source, utm_medium, utm_campaign )—while stripping query strings and URL hashes by default so sensitive auth tokens in URLs never leak into chat logs. (Tip: Click the playground link above and submit a test message to see the utm_source=devto attribution in action!)

Teams, Timezone Business Hours & Smart Defaults

Optional Live In-Widget Chat & Webhook Transport ( v0.8.0 ) Want visitors to stay on your site instead of leaving for the WhatsApp app? Switch transport to live mode using createWebhookTransport ( whatsapp-chat-widget-react/adapters ) to connect n8n, Make, Zapier, or a WhatsApp Cloud API proxy—complete with sessionStorage persistence, delivery statuses, retry handling, and a "Continue on WhatsApp" escape hatch.

Bring-Your-Own-AI ( v0.8.0 — Zero SDK Bloat) Connect any /v1/chat/completions endpoint (OpenAI, Claude via OpenRouter/LiteLLM, Cloudflare AI Gateway, Groq, Ollama) via createOpenAICompatibleAI:

Popup-Blocker Safe Lead Capture ( webhookUrl ) Fires non-blocking JSON lead payloads via navigator.sendBeacon (with fetch keepalive fallback) right as the user submits. If an async AI or webhook step consumes the browser's click activation, the widget automatically renders an "Open WhatsApp" button instead of getting swallowed by a popup blocker.

Programmatic Control ( useWhatsAppWidget() ) Trigger the widget from any pricing calculator, navbar CTA, or page button using openWithDraft({ subject: 'Enterprise Plan', message: '...' }).

npm install whatsapp-chat-widget-react Enter fullscreen mode Exit fullscreen mode import { WhatsAppChat } from 'whatsapp-chat-widget-react'; export function App ( ) { return ( < WhatsAppChat phoneNumber = "+2348000000000" title = "Support Team" includePageContext theme = "auto" /> ); } Enter fullscreen mode Exit fullscreen mode Quick Start: Plain HTML / No-React ( dist/standalone.global.js ) Using plain HTML, Webflow, Shopify, or Squarespace? Drop in the zero-dependency script tag via jsDelivr or unpkg (complete with Shadow DOM isolation and Subresource Integrity):

<script src = "https://jsdelivr.net" data-phone = "+2348000000000" data-title = "Support Team" data-include-context = "true" defer ></script> Enter fullscreen mode Exit fullscreen mode Links & Docs Interactive Playground: https://mcdavidobioha.github.io/whatsapp-chat-widget-react-typescript GitHub Repository: https://github.com/mcdavidobioha/whatsapp-chat-widget-react-typescript Full Feature Breakdown: FEATURES.md npm Package: https://www.npmjs.com/package/whatsapp-chat-widget-react Feedback, stars, issues, and PRs are welcome!

Originaltitel: I built a zero-dependency, form-first WhatsApp widget for React & plain HTML (with optional BYO-AI, live chat, and lead capture)Quelle: dev.to (dev.to). Original öffnen