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

Function getWhatsAppChanges

apps/sim/lib/webhooks/providers/whatsapp.ts:21–48  ·  view source on GitHub ↗
(
  body: unknown
)

Source from the content-addressed store, hash-verified

19}
20
21function getWhatsAppChanges(
22 body: unknown
23): Array<{ field?: string; value: Record<string, unknown> }> {
24 if (!isRecord(body) || !Array.isArray(body.entry)) {
25 return []
26 }
27
28 const changes: Array<{ field?: string; value: Record<string, unknown> }> = []
29
30 for (const entry of body.entry) {
31 if (!isRecord(entry) || !Array.isArray(entry.changes)) {
32 continue
33 }
34
35 for (const change of entry.changes) {
36 if (!isRecord(change) || !isRecord(change.value)) {
37 continue
38 }
39
40 changes.push({
41 field: typeof change.field === 'string' ? change.field : undefined,
42 value: change.value,
43 })
44 }
45 }
46
47 return changes
48}
49
50function normalizeWhatsAppContact(contact: Record<string, unknown>) {
51 const profile = isRecord(contact.profile) ? contact.profile : undefined

Callers 2

extractIdempotencyIdFunction · 0.85
formatInputFunction · 0.85

Calls 2

isRecordFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected