diff --git a/README.md b/README.md index 51ece9202..fc22cab6d 100644 --- a/README.md +++ b/README.md @@ -167,6 +167,10 @@ warelay supports running on the same phone number you message fromβ€”you chat wi | Key | Type & default | Notes | | --- | --- | --- | | `inbound.allowFrom` | `string[]` (default: empty) | E.164 numbers allowed to trigger auto-reply (no `whatsapp:`); `"*"` allows any sender. | +| `inbound.messagePrefix` | `string` (default: `"[warelay]"` if no allowFrom, else `""`) | Prefix added to all inbound messages before passing to command. | +| `inbound.responsePrefix` | `string` (default: β€”) | Prefix auto-added to all outbound replies (e.g., `"🦞"`). | +| `inbound.timestampPrefix` | `boolean` (default: `false`) | Prepend compact timestamp `[Nov 29 06:30]` to messages. | +| `inbound.timestampTimezone` | `string` (default: `"UTC"`) | IANA timezone for timestamp (e.g., `"Europe/Vienna"`). | | `inbound.reply.mode` | `"text"` \| `"command"` (default: β€”) | Reply style. | | `inbound.reply.text` | `string` (default: β€”) | Used when `mode=text`; templating supported. | | `inbound.reply.command` | `string[]` (default: β€”) | Argv for `mode=command`; each element templated. Stdout (trimmed) is sent. | diff --git a/src/config/config.ts b/src/config/config.ts index 4964d21ef..fbadf4cab 100644 --- a/src/config/config.ts +++ b/src/config/config.ts @@ -46,8 +46,8 @@ export type WarelayConfig = { logging?: LoggingConfig; inbound?: { allowFrom?: string[]; // E.164 numbers allowed to trigger auto-reply (without whatsapp:) - samePhoneMarker?: string; // Prefix for same-phone mode messages (default: "[same-phone]") - samePhoneResponsePrefix?: string; // Prefix auto-added to replies in same-phone mode (e.g., "🦞") + messagePrefix?: string; // Prefix added to all inbound messages (default: "[warelay]" if no allowFrom, else "") + responsePrefix?: string; // Prefix auto-added to all outbound replies (e.g., "🦞") timestampPrefix?: boolean; // Prepend compact timestamp to messages (default: false) timestampTimezone?: string; // IANA timezone for timestamp (default: UTC), e.g., "Europe/Vienna" transcribeAudio?: { @@ -143,8 +143,8 @@ const WarelaySchema = z.object({ inbound: z .object({ allowFrom: z.array(z.string()).optional(), - samePhoneMarker: z.string().optional(), - samePhoneResponsePrefix: z.string().optional(), + messagePrefix: z.string().optional(), + responsePrefix: z.string().optional(), timestampPrefix: z.boolean().optional(), timestampTimezone: z.string().optional(), transcribeAudio: z diff --git a/src/web/auto-reply.ts b/src/web/auto-reply.ts index 8ea4bda43..f67053b44 100644 --- a/src/web/auto-reply.ts +++ b/src/web/auto-reply.ts @@ -576,12 +576,16 @@ export async function monitorWebProvider( } } - // Prefix body with marker in same-phone mode so the assistant knows to prefix replies - // The marker can be customized via config (default: "[same-phone]") - const samePhoneMarker = cfg.inbound?.samePhoneMarker ?? "[same-phone]"; - const bodyForCommand = isSamePhoneMode - ? `${timestampStr}${samePhoneMarker} ${msg.body}` - : `${timestampStr}${msg.body}`; + // Build message prefix: explicit config > default based on allowFrom + // If allowFrom is configured, user likely has a specific setup - no default prefix + // If no allowFrom, add "[warelay]" so AI knows it's coming through warelay + let messagePrefix = cfg.inbound?.messagePrefix; + if (messagePrefix === undefined) { + const hasAllowFrom = (cfg.inbound?.allowFrom?.length ?? 0) > 0; + messagePrefix = hasAllowFrom ? "" : "[warelay]"; + } + const prefixStr = messagePrefix ? `${messagePrefix} ` : ""; + const bodyForCommand = `${timestampStr}${prefixStr}${msg.body}`; const replyResult = await (replyResolver ?? getReplyFromConfig)( { @@ -608,12 +612,12 @@ export async function monitorWebProvider( ); return; } - // Apply same-phone response prefix if configured and in same-phone mode - const samePhoneResponsePrefix = cfg.inbound?.samePhoneResponsePrefix; - if (isSamePhoneMode && samePhoneResponsePrefix && replyResult.text) { + // Apply response prefix if configured (for all messages) + const responsePrefix = cfg.inbound?.responsePrefix; + if (responsePrefix && replyResult.text) { // Only add prefix if not already present - if (!replyResult.text.startsWith(samePhoneResponsePrefix)) { - replyResult.text = `${samePhoneResponsePrefix} ${replyResult.text}`; + if (!replyResult.text.startsWith(responsePrefix)) { + replyResult.text = `${responsePrefix} ${replyResult.text}`; } }