Pesan Permintaan Lokasi

Pesan permintaan lokasi menampilkan teks isi dan tombol kirim lokasi. Saat pengguna WhatsApp mengetuk tombol ini, layar bagikan lokasi akan muncul yang kemudian dapat digunakan pengguna untuk membagikan lokasi mereka.


Setelah pengguna membagikan lokasi mereka, pesan webhook akan dipicu, yang berisi detail lokasi pengguna.

Mengirim Pesan Permintaan Lokasi

Gunakan endpoint POST /<WHATSAPP_BUSINESS_PHONE_NUMBER_ID>/messages untuk mengirim pesan permintaan lokasi ke pengguna WhatsApp.

Sintaksis Permintaan

POST /<WHATSAPP_BUSINESS_PHONE_NUMBER_ID>/messages

Isi Posting

{
  "messaging_product": "whatsapp",
  "recipient_type": "individual",
  "type": "interactive",
  "to": "<WHATSAPP_USER_PHONE_NUMBER>",
  "interactive": {
    "type": "location_request_message",
    "body": {
      "text": "<BODY_TEXT>"
    },
    "action": {
      "name": "send_location"
    }
  }
}

Parameter Isi Posting

PlaceholderDeskripsiNilai Contoh

<BODY_TEXT>

String

Wajib.

Teks isi pesan. Mendukung URL.

Maksimal 1.024 karakter.

Let's start with your pickup. You can either manually *enter an address* or *share your current location*.

<WHATSAPP_USER_PHONE_NUMBER>

String

Required.

WhatsApp user phone number.

+16505551234

Tanggapan

Setelah sukses:

{
  "messaging_product": "whatsapp",
  "contacts": [
    {
      "input": "<WHATSAPP_USER_PHONE_NUMBER>",
      "wa_id": "<WHATSAPP_USER_ID>"
    }
  ],
  "messages": [
    {
      "id": "<WHATSAPP_MESSAGE_ID>",
      "message_status": "<PACING_STATUS>"
    }
  ]
}

Konten Tanggapan

PlaceholderDescriptionSample Value

<WHATSAPP_USER_PHONE_NUMBER>

String

WhatsApp user's WhatsApp phone number. May not match wa_id value.

+16505551234

<WHATSAPP_USER_ID>

String

WhatsApp user's WhatsApp ID. May not match input value.

16505551234

<WHATSAPP_MESSAGE_ID>

String

WhatsApp Message ID. This ID appears in associated messages webhooks, such as sent, read, and delivered webhooks.

wamid.HBgLMTY0NjcwNDM1OTUVAgARGBI4MjZGRDA0OUE2OTQ3RkEyMzcA

<PACING_STATUS>

String

Indicates template pacing status. The message_status property is only included in responses when sending a template message that uses a template that is being paced.

wamid.HBgLMTY0NjcwNDM1OTUVAgARGBI4MjZGRDA0OUE2OTQ3RkEyMzcA

Webhook

Ketika pengguna WhatsApp membagikan lokasi mereka sebagai tanggapan atas pesan Anda, pesan webhook akan dipicu, yang berisi detail lokasi pengguna.

{
  "object": "whatsapp_business_account",
  "entry": [
    {
      "id": "<WHATSAPP_BUSINESS_ACCOUNT_ID>",
      "changes": [
        {
          "value": {
            "messaging_product": "whatsapp",
            "metadata": {
              "display_phone_number": "<WHATSAPP_BUSINESS_DISPLAY_PHONE_NUMBER>",
              "phone_number_id": "<WHATSAPP_BUSINESS_PHONE_NUMBER_ID>"
            },
            "contacts": [
              {
                "profile": {
                  "name": "<WHATSAPP_USER_NAME>"
                },
                "wa_id": "<WHATSAPP_USER_ID>"
              }
            ],
            "messages": [
              {
                "context": {
                  "from": "<WHATSAPP_BUSINESS_PHONE_NUMBER>",
                  "id": "<WHATSAPP_CONTEXT_MESSAGE_ID>"
                },
                "from": "<WHATSAPP_USER_ID>",
                "id": "<WHATSAPP_MESSAGE_ID>",
                "timestamp": "<TIMESTAMP>",
                "location": {
                  "address": "<LOCATION_ADDRESS>",
                  "latitude": <LOCATION_LATITUDE>,
                  "longitude": <LOCATION_LONGITUDE>,
                  "name": "<LOCATION_NAME>"
                },
                "type": "location"
              }
            ]
          },
          "field": "messages"
        }
      ]
    }
  ]
}

Konten Webhook

PlaceholderDeskripsiNilai Contoh

<LOCATION_ADDRESS>

String

Alamat lokasi.

Parameter ini hanya akan muncul jika pengguna WhatsApp memilih untuk membagikannya.

1071 5th Ave, New York, NY 10128

<LOCATION_LATITUDE>

Nomor

Lokasi lintang dalam derajat desimal.

40.782910059774

<LOCATION_LONGITUDE>

Nomor

Lokasi bujur dalam derajat desimal.

-73.959075808525

<LOCATION_NAME>

String

Nama lokasi.

Parameter ini hanya akan muncul jika pengguna WhatsApp memilih untuk membagikannya.

Solomon R. Guggenheim Museum

<TIMESTAMP>

String

Cap waktu UNIX yang menunjukkan kapan server kami memproses pesan pengguna WhatsApp.

1702920965

<WHATSAPP_BUSINESS_ACCOUNT_ID>

String

ID Akun WhatsApp Business.

102290129340398

<WHATSAPP_BUSINESS_DISPLAY_PHONE_NUMBER>

String

Nomor tampilan nomor telepon WhatsApp Business.

15550783881

<WHATSAPP_BUSINESS_PHONE_NUMBER>

String

Nomor telepon WhatsApp Business.

15550783881

<WHATSAPP_BUSINESS_PHONE_NUMBER_ID>

String

ID nomor telepon WhatsApp Business.

106540352242922

<WHATSAPP_CONTEXT_MESSAGE_ID>

String

ID pesan WhatsApp dari pesan yang ditanggapi pengguna.

wamid.HBgLMTY0NjcwNDM1OTUVAgARGBI1QjJGRjI1RDY0RkE4Nzg4QzcA

<WHATSAPP_MESSAGE_ID>

String

ID pesan WhatsApp dari pesan pengguna.

wamid.HBgLMTY0NjcwNDM1OTUVAgASGBQzQTRCRDcwNzgzMTRDNTAwRTgwRQA=

<WHATSAPP_USER_ID>

String

ID WhatsApp pengguna WhatsApp.

16505551234

<WHATSAPP_USER_NAME>

String

Nama pengguna WhatsApp.

Pablo Morales

Contoh Permintaan

curl 'https://graph.facebook.com/v21.0/106540352242922/messages' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer EAAJB...' \
-d '
{
  "messaging_product": "whatsapp",
  "recipient_type": "individual",
  "type": "interactive",
  "to": "+16505551234",
  "interactive": {
    "type": "location_request_message",
    "body": {
      "text": "Let us start with your pickup. You can either manually *enter an address* or *share your current location*."
    },
    "action": {
      "name": "send_location"
    }
  }
}'

Contoh Tanggapan

{
  "messaging_product": "whatsapp",
  "contacts": [
    {
      "input": "+16505551234",
      "wa_id": "16505551234"
    }
  ],
  "messages": [
    {
      "id": "wamid.HBgLMTY0NjcwNDM1OTUVAgARGBJCNUQ5RUNBNTk3OEQ2M0ZEQzgA"
    }
  ]
}

Contoh Webhook

{
  "object": "whatsapp_business_account",
  "entry": [
    {
      "id": "102290129340398",
      "changes": [
        {
          "value": {
            "messaging_product": "whatsapp",
            "metadata": {
              "display_phone_number": "15550783881",
              "phone_number_id": "106540352242922"
            },
            "contacts": [
              {
                "profile": {
                  "name": "Pablo Morales"
                },
                "wa_id": "16505551234"
              }
            ],
            "messages": [
              {
                "context": {
                  "from": "15550783881",
                  "id": "wamid.HBgLMTY0NjcwNDM1OTUVAgARGBI1QjJGRjI1RDY0RkE4Nzg4QzcA"
                },
                "from": "16505551234",
                "id": "wamid.HBgLMTY0NjcwNDM1OTUVAgASGBQzQTRCRDcwNzgzMTRDNTAwRTgwRQA=",
                "timestamp": "1702920965",
                "location": {
                  "address": "1071 5th Ave, New York, NY 10128",
                  "latitude": 40.782910059774,
                  "longitude": -73.959075808525,
                  "name": "Solomon R. Guggenheim Museum"
                },
                "type": "location"
              }
            ]
          },
          "field": "messages"
        }
      ]
    }
  ]
}