# Configuration Guide This guide walks you through configuring the Nostr Chat Widget for your website. ## Table of Contents - [Basic Setup](#basic-setup) - [Getting Your Nostr Keys](#getting-your-nostr-keys) - [Relay Configuration](#relay-configuration) - [Customization](#customization) - [Receiving Messages](#receiving-messages) ## Basic Setup ### Step 1: Include Dependencies Add these to your HTML `
`: ```html ``` ### Step 2: Add the Widget Before your closing `` tag: ```html ``` ### Step 3: Configure Your Public Key Open `chat.js` and locate the `CONFIG` object: ```javascript const CONFIG = { relays: [ 'wss://relay.damus.io', 'wss://relay.primal.net', 'wss://nos.lol', 'wss://relay.btcforplebs.com', 'wss://relay.logemedia.com' ], csPubkey: 'YOUR_PUBLIC_KEY_HERE' // Replace with your hex public key }; ``` ## Getting Your Nostr Keys ### Option 1: Using an Existing Nostr Client If you already use Nostr: 1. Open your Nostr client (Damus, Amethyst, Snort, etc.) 2. Go to Settings → Keys/Security 3. Copy your **public key** (NOT your private key) 4. If it starts with `npub1`, convert it to hex format (see below) ### Option 2: Generate New Keys For a fresh customer support identity: 1. Install a Nostr client: - Desktop: [Nostr.band](https://nostr.band), [Nostrudel](https://nostrudel.ninja) - Mobile: [Damus (iOS)](https://damus.io), [Amethyst (Android)](https://github.com/vitorpamplona/amethyst) 2. Create a new account 3. **IMPORTANT**: Securely save your private key (nsec) 4. Copy your public key for the config ### Converting npub to Hex If your public key starts with `npub1`: **Online Tool:** - Visit [nostr.band/tools](https://nostr.band/tools) - Paste your npub - Copy the hex version **Using JavaScript:** ```javascript import { nip19 } from 'nostr-tools'; const hex = nip19.decode('npub1...').data; console.log(hex); ``` ## Relay Configuration ### Default Relays The widget connects to multiple relays for reliability: ```javascript relays: [ 'wss://relay.damus.io', // General purpose, reliable 'wss://relay.primal.net', // Popular, good uptime 'wss://nos.lol', // Community favorite 'wss://relay.btcforplebs.com', // Bitcoin-focused 'wss://relay.logemedia.com' // Custom relay ] ``` ### Choosing Relays **Good relays have:** - High uptime (99%+) - Good geographic distribution - Support for kind 4 events (DMs) - Read/write permissions **Popular Relay Lists:** - [nostr.watch](https://nostr.watch) - Relay monitoring - [relay.tools](https://relay.tools) - Relay explorer ### Running Your Own Relay For maximum control, run your own Nostr relay: **Quick Setup:** ```bash # Using nostr-rs-relay (Rust) docker run -d -p 8080:8080 scsibug/nostr-rs-relay # Using strfry (C++) # See: https://github.com/hoytech/strfry ``` Then add to your config: ```javascript relays: [ 'wss://your-relay.example.com', // ... plus backup public relays ] ``` ## Customization ### Colors The widget uses Tailwind classes. Change colors by replacing: **Primary gradient** (orange): ```javascript // Find in chat.js: from-[#fdad01] to-[#ff8c00] // Replace with your brand colors: from-[#4F46E5] to-[#7C3AED] // Purple from-[#10B981] to-[#059669] // Green from-[#EF4444] to-[#DC2626] // Red ``` **Connection indicator**: ```javascript // Green dot when connected: bg-green-400 // Change to match your theme: bg-blue-400 bg-purple-400 ``` ### Position Change the widget position in `chat.js`: ```javascript // Bottom-right (default) className="fixed bottom-4 right-4 sm:bottom-6 sm:right-6" // Bottom-left className="fixed bottom-4 left-4 sm:bottom-6 sm:left-6" // Top-right className="fixed top-4 right-4 sm:top-6 sm:right-6" ``` ### Branding **Team Name:** ```javascript // Find in chat.js render function: