Add timestampPrefix config for datetime awareness
New config options: - timestampPrefix: boolean - prepend timestamp to messages - timestampTimezone: string - IANA timezone (default: UTC) Format: [Nov 29 06:30] - compact but informative Helps AI assistants stay aware of current date/time.
This commit is contained in:
@@ -48,6 +48,8 @@ export type WarelayConfig = {
|
||||
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., "🦞")
|
||||
timestampPrefix?: boolean; // Prepend compact timestamp to messages (default: false)
|
||||
timestampTimezone?: string; // IANA timezone for timestamp (default: UTC), e.g., "Europe/Vienna"
|
||||
transcribeAudio?: {
|
||||
// Optional CLI to turn inbound audio into text; templated args, must output transcript to stdout.
|
||||
command: string[];
|
||||
@@ -143,6 +145,8 @@ const WarelaySchema = z.object({
|
||||
allowFrom: z.array(z.string()).optional(),
|
||||
samePhoneMarker: z.string().optional(),
|
||||
samePhoneResponsePrefix: z.string().optional(),
|
||||
timestampPrefix: z.boolean().optional(),
|
||||
timestampTimezone: z.string().optional(),
|
||||
transcribeAudio: z
|
||||
.object({
|
||||
command: z.array(z.string()),
|
||||
|
||||
@@ -562,12 +562,26 @@ export async function monitorWebProvider(
|
||||
|
||||
lastInboundMsg = msg;
|
||||
|
||||
// Build timestamp prefix if enabled
|
||||
let timestampStr = "";
|
||||
if (cfg.inbound?.timestampPrefix) {
|
||||
const tz = cfg.inbound?.timestampTimezone ?? "UTC";
|
||||
const now = new Date();
|
||||
try {
|
||||
// Format: "Nov 29 06:30" - compact but informative
|
||||
timestampStr = `[${now.toLocaleDateString("en-US", { month: "short", day: "numeric", timeZone: tz })} ${now.toLocaleTimeString("en-US", { hour: "2-digit", minute: "2-digit", hour12: false, timeZone: tz })}] `;
|
||||
} catch {
|
||||
// Fallback to UTC if timezone invalid
|
||||
timestampStr = `[${now.toISOString().slice(5, 16).replace("T", " ")}] `;
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
? `${samePhoneMarker} ${msg.body}`
|
||||
: msg.body;
|
||||
? `${timestampStr}${samePhoneMarker} ${msg.body}`
|
||||
: `${timestampStr}${msg.body}`;
|
||||
|
||||
const replyResult = await (replyResolver ?? getReplyFromConfig)(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user