NostrNEW
Connect Sophon to the Nostr protocol via relays.
Sophon connects to Nostr using the relay protocol (NIP-01). The adapter opens a WebSocket connection to a relay, subscribes to encrypted direct messages (kind-4 events) addressed to your public key, and publishes replies back through the same relay. You supply a private key and one or more relay URLs — there is no app or bot to register on a central platform.
Nostr is decentralized: your identity is a key pair, not an account. The same key works across every relay, so anyone who can message your public key can reach Sophon.
Prerequisites
- A Nostr key pair (a 64-character hex private key). If you only have an
nsec...key, convert it to hex first. - The WebSocket URL of at least one Nostr relay (for example,
wss://relay.damus.io).
Step-by-Step Setup
1. Get a Hex Private Key
Sophon signs and publishes events as your Nostr identity, so it needs the private key for that identity.
- Create or pick a key pair in any Nostr client.
- Export the private key. Most clients show it in bech32 form (
nsec1...). - Convert the
nsecto its raw 64-character hex form (the nostr.com/keys tool can do this).
Use a dedicated key for the assistant rather than your personal one — anyone messaging that key reaches Sophon.
2. Choose Your Relays
Pick one or more public relays where Sophon should listen and post. Common choices include wss://relay.damus.io and wss://nos.lol. Listing several relays improves delivery, since not every client publishes to the same one.
3. Configure in Sophon Dashboard
- Go to Channels and click Add Channel.
- Select Nostr.
- Paste the Private Key (hex) into the secret field.
- Enter the Relay URLs as a comma-separated list (for example,
wss://relay.damus.io,wss://nos.lol). - Click Test Connection — Sophon confirms the relay WebSocket is open.
- Click Activate.
4. Test It
From any Nostr client, send an encrypted direct message to the assistant's public key. Sophon receives the kind-4 event and replies through the relay.
Configuration Reference
The dashboard collects the fields below. Internally the adapter reads relayUrl and privateKeyHex from the channel settings, and derives the public key from the private key.
| Field | Type | Required | Description |
|---|---|---|---|
privateKeyHex | secret | Yes | 64-character hex private key for the assistant's Nostr identity |
relayUrls | text | Yes | Comma-separated list of relay WebSocket URLs (wss://...) |
pubkey | text | No | Public key (hex); derived from the private key when omitted |
channels.json Example
{
"id": "nostr-relay",
"type": "nostr",
"name": "Sophon Nostr Bot",
"enabled": true,
"config": {
"privateKeyHex": "<encrypted>",
"relayUrls": "wss://relay.damus.io,wss://nos.lol"
},
"routing": {
"agentId": "default",
"dmBehavior": "main-session",
"groupBehavior": "mention-only"
},
"status": "connected"
}Media Support
The Nostr adapter is text-first. Inbound it processes encrypted direct messages (kind-4); other event kinds are ignored. Outbound, image messages are sent as their caption text rather than as attached media.
| Type | Inbound | Outbound |
|---|---|---|
| Text | Yes | Yes |
| Images | No | Caption text only |
| Audio | No | No |
| Video | No | No |
| Documents | No | No |
Troubleshooting
- "Nostr WebSocket not connected" — Test Connection failed because the relay socket was not open. Verify the relay URL is reachable and uses the
wss://scheme, then retry. - No incoming messages — Sophon only subscribes to kind-4 (encrypted DM) events tagged to your public key. Make sure the sender is direct-messaging the correct pubkey, not posting a public note.
- Replies never arrive — The recipient must be addressable by a 64-character hex pubkey; Sophon rejects any recipient that is not exactly 64 hex characters. Confirm the relay you replied through is one the recipient also reads.
- Wrong identity — If
privateKeyHexis not the 64-character hex form (for example, annsec...value was pasted), convert it to hex before saving. - Intermittent drops — The adapter reconnects automatically after a short delay when a relay disconnects. If drops persist, configure additional relays so listening does not depend on a single host.