MCPcopy Create free account
hub / github.com/simstudioai/sim / normalizeWhatsAppMessage

Function normalizeWhatsAppMessage

apps/sim/lib/webhooks/providers/whatsapp.ts:63–83  ·  view source on GitHub ↗
(
  message: Record<string, unknown>,
  metadata?: Record<string, unknown>
)

Source from the content-addressed store, hash-verified

61}
62
63function normalizeWhatsAppMessage(
64 message: Record<string, unknown>,
65 metadata?: Record<string, unknown>
66) {
67 const text = isRecord(message.text) ? message.text : undefined
68
69 return {
70 messageId: typeof message.id === 'string' ? message.id : undefined,
71 from: typeof message.from === 'string' ? message.from : undefined,
72 phoneNumberId:
73 typeof metadata?.phone_number_id === 'string' ? metadata.phone_number_id : undefined,
74 displayPhoneNumber:
75 typeof metadata?.display_phone_number === 'string'
76 ? metadata.display_phone_number
77 : undefined,
78 text: typeof text?.body === 'string' ? text.body : undefined,
79 timestamp: typeof message.timestamp === 'string' ? message.timestamp : undefined,
80 messageType: typeof message.type === 'string' ? message.type : undefined,
81 raw: message,
82 }
83}
84
85function normalizeWhatsAppStatus(
86 status: Record<string, unknown>,

Callers 1

formatInputFunction · 0.85

Calls 1

isRecordFunction · 0.70

Tested by

no test coverage detected