From 61bfe1bb96f61e1c37532e533134b5a73edeb50f Mon Sep 17 00:00:00 2001 From: memarius <14908727+memarius@users.noreply.github.com> Date: Thu, 18 Jan 2024 14:01:22 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Receive=20WhatsApp=20locat?= =?UTF-8?q?ion=20(#1158)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Enable Typebot to recieve location messages via Whatsapp and parse them into a string. Returns a string "Location: [LAT],[LON]" for the text input block As per https://discord.com/channels/1155799591220953138/1193858969102450748 ## Summary by CodeRabbit - **New Features** - Introduced support for receiving and handling location messages in WhatsApp integration. --------- Co-authored-by: memarius Co-authored-by: Baptiste Arnaud --- packages/bot-engine/whatsapp/resumeWhatsAppFlow.ts | 2 ++ packages/schemas/features/whatsapp.ts | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/packages/bot-engine/whatsapp/resumeWhatsAppFlow.ts b/packages/bot-engine/whatsapp/resumeWhatsAppFlow.ts index ba87ab179..0b00827c5 100644 --- a/packages/bot-engine/whatsapp/resumeWhatsAppFlow.ts +++ b/packages/bot-engine/whatsapp/resumeWhatsAppFlow.ts @@ -153,6 +153,8 @@ const getIncomingMessageContent = async ({ env.NEXTAUTH_URL + `/api/typebots/${typebotId}/whatsapp/media/${mediaId}` ) + case 'location': + return `${message.location.latitude}, ${message.location.longitude}` } } diff --git a/packages/schemas/features/whatsapp.ts b/packages/schemas/features/whatsapp.ts index a01777e9b..8acf6ff39 100644 --- a/packages/schemas/features/whatsapp.ts +++ b/packages/schemas/features/whatsapp.ts @@ -137,6 +137,15 @@ export const incomingMessageSchema = z.discriminatedUnion('type', [ document: z.object({ id: z.string() }), timestamp: z.string(), }), + z.object({ + from: z.string(), + type: z.literal('location'), + location: z.object({ + latitude: z.number(), + longitude: z.number() + }), + timestamp: z.string(), + }), ]) export const whatsAppWebhookRequestBodySchema = z.object({