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.main
parent
25ec133574
commit
26e02a9b8b
|
|
@ -48,6 +48,8 @@ export type WarelayConfig = {
|
||||||
allowFrom?: string[]; // E.164 numbers allowed to trigger auto-reply (without whatsapp:)
|
allowFrom?: string[]; // E.164 numbers allowed to trigger auto-reply (without whatsapp:)
|
||||||
samePhoneMarker?: string; // Prefix for same-phone mode messages (default: "[same-phone]")
|
samePhoneMarker?: string; // Prefix for same-phone mode messages (default: "[same-phone]")
|
||||||
samePhoneResponsePrefix?: string; // Prefix auto-added to replies in same-phone mode (e.g., "🦞")
|
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?: {
|
transcribeAudio?: {
|
||||||
// Optional CLI to turn inbound audio into text; templated args, must output transcript to stdout.
|
// Optional CLI to turn inbound audio into text; templated args, must output transcript to stdout.
|
||||||
command: string[];
|
command: string[];
|
||||||
|
|
@ -143,6 +145,8 @@ const WarelaySchema = z.object({
|
||||||
allowFrom: z.array(z.string()).optional(),
|
allowFrom: z.array(z.string()).optional(),
|
||||||
samePhoneMarker: z.string().optional(),
|
samePhoneMarker: z.string().optional(),
|
||||||
samePhoneResponsePrefix: z.string().optional(),
|
samePhoneResponsePrefix: z.string().optional(),
|
||||||
|
timestampPrefix: z.boolean().optional(),
|
||||||
|
timestampTimezone: z.string().optional(),
|
||||||
transcribeAudio: z
|
transcribeAudio: z
|
||||||
.object({
|
.object({
|
||||||
command: z.array(z.string()),
|
command: z.array(z.string()),
|
||||||
|
|
|
||||||
|
|
@ -562,12 +562,26 @@ export async function monitorWebProvider(
|
||||||
|
|
||||||
lastInboundMsg = msg;
|
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
|
// 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]")
|
// The marker can be customized via config (default: "[same-phone]")
|
||||||
const samePhoneMarker = cfg.inbound?.samePhoneMarker ?? "[same-phone]";
|
const samePhoneMarker = cfg.inbound?.samePhoneMarker ?? "[same-phone]";
|
||||||
const bodyForCommand = isSamePhoneMode
|
const bodyForCommand = isSamePhoneMode
|
||||||
? `${samePhoneMarker} ${msg.body}`
|
? `${timestampStr}${samePhoneMarker} ${msg.body}`
|
||||||
: msg.body;
|
: `${timestampStr}${msg.body}`;
|
||||||
|
|
||||||
const replyResult = await (replyResolver ?? getReplyFromConfig)(
|
const replyResult = await (replyResolver ?? getReplyFromConfig)(
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue