Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(engine): add missing location data to incoming webhook messages (#202)

robtrejo6ffd26de8506
diff --git a/src/engine/adapters/whatsapp-web-js.adapter.ts b/src/engine/adapters/whatsapp-web-js.adapter.ts
index 6e2156779..992ce987f 100644
--- a/src/engine/adapters/whatsapp-web-js.adapter.ts
+++ b/src/engine/adapters/whatsapp-web-js.adapter.ts
@@ -155,6 +155,17 @@ export class WhatsAppWebJsAdapter extends EventEmitter implements IWhatsAppEngin
isGroup: msg.from.endsWith('@g.us'),
};
+ // Handle location
+ if (msg.type === 'location' && msg.location) {
+ incomingMessage.location = {
+ latitude: Number(msg.location.latitude),
+ longitude: Number(msg.location.longitude),
+ description: msg.location.description || undefined,
+ address: msg.location.address || undefined,
+ url: msg.location.url || undefined,
+ };
+ }
+
// Handle media
if (msg.hasMedia) {
try {
diff --git a/src/engine/interfaces/whatsapp-engine.interface.ts b/src/engine/interfaces/whatsapp-engine.interface.ts
index f3e5de621..4dd6f6eff 100644
--- a/src/engine/interfaces/whatsapp-engine.interface.ts
+++ b/src/engine/interfaces/whatsapp-engine.interface.ts
@@ -41,6 +41,13 @@ export interface IncomingMessage {
id: string;
body: string;
};
+ location?: {
+ latitude: number;
+ longitude: number;
+ description?: string;
+ address?: string;
+ url?: string;
+ };
}
export interface Contact {