Skip to content

Commit

Permalink
⚡️ Receive WhatsApp location (#1158)
Browse files Browse the repository at this point in the history
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

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Introduced support for receiving and handling location messages in
WhatsApp integration.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: memarius <me-marius@web.de>
Co-authored-by: Baptiste Arnaud <contact@baptiste-arnaud.fr>
  • Loading branch information
3 people committed Jan 18, 2024
1 parent 8283179 commit 61bfe1b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/bot-engine/whatsapp/resumeWhatsAppFlow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
}
}

Expand Down
9 changes: 9 additions & 0 deletions packages/schemas/features/whatsapp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

2 comments on commit 61bfe1b

@vercel
Copy link

@vercel vercel bot commented on 61bfe1b Jan 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

landing-page-v2 – ./apps/landing-page

landing-page-v2-typebot-io.vercel.app
landing-page-v2-git-main-typebot-io.vercel.app
home.typebot.io

@vercel
Copy link

@vercel vercel bot commented on 61bfe1b Jan 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

builder-v2-typebot-io.vercel.app
app.typebot.io
builder-v2-git-main-typebot-io.vercel.app

Please sign in to comment.