Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/builder/messages/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -1781,7 +1781,8 @@
"date": "التاريخ",
"datetime": "التاريخ والوقت",
"location": "الموقع",
"anyInput": "أي إدخال"
"anyInput": "أي إدخال",
"locationDescription": "On WhatsApp this sends Meta's native Send location button and waits for the pin. Other channels send the prompt as text; a shared pin or typed lat,lng still completes the step."
},
"workspaceMember": {
"label": "عضو مساحة العمل"
Expand Down
3 changes: 2 additions & 1 deletion apps/builder/messages/da.json
Original file line number Diff line number Diff line change
Expand Up @@ -1644,7 +1644,8 @@
"date": "Dato",
"datetime": "Datetime",
"location": "Placering",
"anyInput": "Vilkårlig Input"
"anyInput": "Vilkårlig Input",
"locationDescription": "On WhatsApp this sends Meta's native Send location button and waits for the pin. Other channels send the prompt as text; a shared pin or typed lat,lng still completes the step."
},
"workspaceMember": {
"label": "Arbejdsområde Member"
Expand Down
3 changes: 2 additions & 1 deletion apps/builder/messages/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -1644,7 +1644,8 @@
"date": "Datum",
"datetime": "Datum und Uhrzeit",
"location": "Standort",
"anyInput": "Beliebige Eingabe"
"anyInput": "Beliebige Eingabe",
"locationDescription": "On WhatsApp this sends Meta's native Send location button and waits for the pin. Other channels send the prompt as text; a shared pin or typed lat,lng still completes the step."
},
"workspaceMember": {
"label": "Arbeitsbereichsmitglied"
Expand Down
3 changes: 2 additions & 1 deletion apps/builder/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1790,7 +1790,8 @@
"date": "Date",
"datetime": "Datetime",
"location": "Location",
"anyInput": "Any Input"
"anyInput": "Any Input",
"locationDescription": "On WhatsApp this sends Meta's native Send location button and waits for the pin. Other channels send the prompt as text; a shared pin or typed lat,lng still completes the step."
},
"workspaceMember": {
"label": "Workspace Member"
Expand Down
3 changes: 2 additions & 1 deletion apps/builder/messages/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -1781,7 +1781,8 @@
"date": "Fecha",
"datetime": "Fechahora",
"location": "Ubicación",
"anyInput": "Any Entrada"
"anyInput": "Any Entrada",
"locationDescription": "En WhatsApp envía el botón nativo Enviar ubicación de Meta y espera el pin. En otros canales envía el texto; un pin compartido o lat,lng escrito también completa el paso."
},
"workspaceMember": {
"label": "Espacio de trabajo Miembro"
Expand Down
3 changes: 2 additions & 1 deletion apps/builder/messages/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1644,7 +1644,8 @@
"date": "Päivämäärä",
"datetime": "Päivämäärä ja aika",
"location": "Sijainti",
"anyInput": "Mikä tahansa syöte"
"anyInput": "Mikä tahansa syöte",
"locationDescription": "On WhatsApp this sends Meta's native Send location button and waits for the pin. Other channels send the prompt as text; a shared pin or typed lat,lng still completes the step."
},
"workspaceMember": {
"label": "Työtilan jäsen"
Expand Down
3 changes: 2 additions & 1 deletion apps/builder/messages/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -1644,7 +1644,8 @@
"date": "Date",
"datetime": "Date et heure",
"location": "Localisation",
"anyInput": "Toute saisie"
"anyInput": "Toute saisie",
"locationDescription": "On WhatsApp this sends Meta's native Send location button and waits for the pin. Other channels send the prompt as text; a shared pin or typed lat,lng still completes the step."
},
"workspaceMember": {
"label": "Membre de l’espace de travail"
Expand Down
3 changes: 2 additions & 1 deletion apps/builder/messages/he.json
Original file line number Diff line number Diff line change
Expand Up @@ -4336,7 +4336,8 @@
"date": "תאריך",
"datetime": "תאריך ושעה",
"location": "מיקום",
"anyInput": "כל קלט"
"anyInput": "כל קלט",
"locationDescription": "On WhatsApp this sends Meta's native Send location button and waits for the pin. Other channels send the prompt as text; a shared pin or typed lat,lng still completes the step."
},
"workspaceMember": {
"label": "חבר בסביבת העבודה"
Expand Down
3 changes: 2 additions & 1 deletion apps/builder/messages/id.json
Original file line number Diff line number Diff line change
Expand Up @@ -1644,7 +1644,8 @@
"date": "Tanggal",
"datetime": "Tanggal dan waktu",
"location": "Lokasi",
"anyInput": "Input Apa Pun"
"anyInput": "Input Apa Pun",
"locationDescription": "On WhatsApp this sends Meta's native Send location button and waits for the pin. Other channels send the prompt as text; a shared pin or typed lat,lng still completes the step."
},
"workspaceMember": {
"label": "Anggota Workspace"
Expand Down
3 changes: 2 additions & 1 deletion apps/builder/messages/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,8 @@
"date": "Data",
"datetime": "Data e ora",
"location": "Posizione",
"anyInput": "Qualsiasi input"
"anyInput": "Qualsiasi input",
"locationDescription": "On WhatsApp this sends Meta's native Send location button and waits for the pin. Other channels send the prompt as text; a shared pin or typed lat,lng still completes the step."
},
"workspaceMember": {
"label": "Membro dell'area di lavoro"
Expand Down
3 changes: 2 additions & 1 deletion apps/builder/messages/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -1644,7 +1644,8 @@
"date": "日付",
"datetime": "日時",
"location": "位置情報",
"anyInput": "任意の入力"
"anyInput": "任意の入力",
"locationDescription": "On WhatsApp this sends Meta's native Send location button and waits for the pin. Other channels send the prompt as text; a shared pin or typed lat,lng still completes the step."
},
"workspaceMember": {
"label": "ワークスペースメンバー"
Expand Down
3 changes: 2 additions & 1 deletion apps/builder/messages/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -1457,7 +1457,8 @@
"date": "Datum",
"datetime": "Datum en tijd",
"location": "Locatie",
"anyInput": "Elke invoer"
"anyInput": "Elke invoer",
"locationDescription": "On WhatsApp this sends Meta's native Send location button and waits for the pin. Other channels send the prompt as text; a shared pin or typed lat,lng still completes the step."
},
"workspaceMember": {
"label": "Werkruimtelid"
Expand Down
3 changes: 2 additions & 1 deletion apps/builder/messages/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -1644,7 +1644,8 @@
"date": "Data",
"datetime": "Data e hora",
"location": "Localização",
"anyInput": "Qualquer entrada"
"anyInput": "Qualquer entrada",
"locationDescription": "On WhatsApp this sends Meta's native Send location button and waits for the pin. Other channels send the prompt as text; a shared pin or typed lat,lng still completes the step."
},
"workspaceMember": {
"label": "Membro do espaço de trabalho"
Expand Down
3 changes: 2 additions & 1 deletion apps/builder/messages/pt-PT.json
Original file line number Diff line number Diff line change
Expand Up @@ -1644,7 +1644,8 @@
"date": "Data",
"datetime": "Data e hora",
"location": "Localização",
"anyInput": "Qualquer entrada"
"anyInput": "Qualquer entrada",
"locationDescription": "On WhatsApp this sends Meta's native Send location button and waits for the pin. Other channels send the prompt as text; a shared pin or typed lat,lng still completes the step."
},
"workspaceMember": {
"label": "Membro do espaço de trabalho"
Expand Down
3 changes: 2 additions & 1 deletion apps/builder/messages/ro.json
Original file line number Diff line number Diff line change
Expand Up @@ -2428,7 +2428,8 @@
"date": "Dată",
"datetime": "Dată și oră",
"location": "Locație",
"anyInput": "Orice intrare"
"anyInput": "Orice intrare",
"locationDescription": "On WhatsApp this sends Meta's native Send location button and waits for the pin. Other channels send the prompt as text; a shared pin or typed lat,lng still completes the step."
},
"workspaceMember": {
"label": "Membru al spațiului de lucru"
Expand Down
3 changes: 2 additions & 1 deletion apps/builder/messages/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -2528,7 +2528,8 @@
"location": "Plats",
"number": "Nummer",
"phone": "Telefon",
"text": "Text"
"text": "Text",
"locationDescription": "On WhatsApp this sends Meta's native Send location button and waits for the pin. Other channels send the prompt as text; a shared pin or typed lat,lng still completes the step."
},
"requestBody": {
"keyPlaceholder": "Fält",
Expand Down
3 changes: 2 additions & 1 deletion apps/builder/messages/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -1781,7 +1781,8 @@
"date": "Tarih",
"datetime": "Tarih ve Saat",
"location": "Konum",
"anyInput": "Herhangi Bir Girdi"
"anyInput": "Herhangi Bir Girdi",
"locationDescription": "On WhatsApp this sends Meta's native Send location button and waits for the pin. Other channels send the prompt as text; a shared pin or typed lat,lng still completes the step."
},
"workspaceMember": {
"label": "Çalışma Alanı Üyesi"
Expand Down
3 changes: 2 additions & 1 deletion apps/builder/messages/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1748,7 +1748,8 @@
"date": "Ngày",
"datetime": "Ngày giờ",
"location": "Vị trí",
"anyInput": "Mọi định dạng"
"anyInput": "Mọi định dạng",
"locationDescription": "Trên WhatsApp, bước này gửi nút Gửi vị trí gốc của Meta và chờ ghim. Kênh khác gửi lời nhắc dạng chữ; ghim hoặc lat,lng vẫn hoàn tất bước."
},
"workspaceMember": {
"label": "Thành viên workspace"
Expand Down
3 changes: 2 additions & 1 deletion apps/builder/messages/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -2531,7 +2531,8 @@
"location": "位置",
"number": "号码",
"phone": "电话",
"text": "文本"
"text": "文本",
"locationDescription": "On WhatsApp this sends Meta's native Send location button and waits for the pin. Other channels send the prompt as text; a shared pin or typed lat,lng still completes the step."
},
"requestBody": {
"keyPlaceholder": "字段",
Expand Down
3 changes: 2 additions & 1 deletion apps/builder/messages/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,8 @@
"date": "日期",
"datetime": "日期時間",
"location": "位置",
"anyInput": "任何輸入"
"anyInput": "任何輸入",
"locationDescription": "On WhatsApp this sends Meta's native Send location button and waits for the pin. Other channels send the prompt as text; a shared pin or typed lat,lng still completes the step."
},
"workspaceMember": {
"label": "工作區成員"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ const GetUserDataStepForm = ({
onSubmit={form.handleSubmit(onSubmit)}
>
<SelectField
description={
replyFormat === ReplyFormat.location
? t("fields.replyFormat.locationDescription")
: undefined
}
label={t("fields.replyFormat.label")}
name="replyFormat"
options={replyFormatOptions}
Expand Down
105 changes: 105 additions & 0 deletions apps/worker/__tests__/get-user-data.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,41 @@ describe("getUserData — validation logic", () => {
})
})

describe("location format", () => {
test("location pin → returns success with lat,lng", async () => {
lastMessage.current = makeIncomingMessage({
contentType: "location",
text: "Received location",
contentAttributes: { latitude: 10.5, longitude: 106.75 },
})

const result = await getUserData(makeProps(ReplyFormat.location))

expect(result.status).toBe("success")
expectCustomFieldWrite("10.5,106.75")
})

test("typed coordinate pair → returns success", async () => {
lastMessage.current = makeIncomingMessage({
text: "10.5, 106.75",
})

const result = await getUserData(makeProps(ReplyFormat.location))

expect(result.status).toBe("success")
expectCustomFieldWrite("10.5,106.75")
})

test("plain text without coordinates → returns retry", async () => {
lastMessage.current = makeIncomingMessage({ text: "Received location" })

const result = await getUserData(makeProps(ReplyFormat.location))

expect(result.status).toBe("retry")
expect(contactCustomFieldSetValueByKey).not.toHaveBeenCalled()
})
})

describe("no message", () => {
test("no last message → returns retry", async () => {
lastMessage.current = null
Expand Down Expand Up @@ -853,12 +888,14 @@ function findChatJobCall(action: string) {
return call[1] as {
type: string
data: {
text?: string
quickReplies?: {
id: string
label: string
buttonType: string
url?: string
messengerExtensions?: boolean
postback?: string
}[]
}
}
Expand Down Expand Up @@ -1327,3 +1364,71 @@ describe("getUserData — non-date replyFormats keep the text prompt path (regre
)
})
})

describe("getUserData — WhatsApp native location request (RF08)", () => {
beforeEach(() => {
chatQueueAdd.mockClear()
})

test("whatsapp location format sends the reserved native location-request marker", async () => {
const props = makeProps(ReplyFormat.location, {
message: "Please share your location",
})
props.ctx = { variables: { conversation: {} } }
props.contactInbox = { ...props.contactInbox, channel: "whatsapp" }

const result = await getUserData(props)

expect(result.status).toBe("wait")
const job = findChatJobCall("sendChatMessage")
expect(job.data).toMatchObject({
text: "Please share your location",
quickReplies: [
{
id: "whatsapp:native:location_request",
label: "Send location",
buttonType: "postback",
postback: "whatsapp:native:location_request",
},
],
})
expect(chatQueueAdd).not.toHaveBeenCalledWith(
"sendFlowMessage",
expect.anything(),
)
expect(waitForChatJobCompletion).toHaveBeenCalledWith(
expect.objectContaining({ id: "job-1" }),
{ conversationId: "conv-1", stepId: "step-1" },
)
})

test("uses the Vietnamese inbox label when workspace.language is vi", async () => {
workspaceFindById.mockResolvedValueOnce({ language: "vi" })
const props = makeProps(ReplyFormat.location)
props.ctx = { variables: { conversation: {} } }
props.contactInbox = { ...props.contactInbox, channel: "whatsapp" }

await getUserData(props)

const job = findChatJobCall("sendChatMessage")
expect(job.data.quickReplies?.[0]?.label).toBe("Gửi vị trí")
})

test("non-whatsapp location format keeps the text prompt path", async () => {
const props = makeProps(ReplyFormat.location)
props.ctx = { variables: { conversation: {} } }
props.contactInbox = { ...props.contactInbox, channel: "messenger" }

const result = await getUserData(props)

expect(result.status).toBe("wait")
expect(chatQueueAdd).toHaveBeenCalledWith(
"sendFlowMessage",
expect.objectContaining({ type: "sendFlowMessage" }),
)
expect(chatQueueAdd).not.toHaveBeenCalledWith(
"sendChatMessage",
expect.anything(),
)
})
})
Loading