傳送聯絡人和地點訊息

使用 messages 節點向顧客傳送其他類型的訊息,例如聯絡人或地點訊息。

準備工作

您需要準備以下事項:

只有顧客在「顧客服務期限」內傳入訊息時,您才能傳送這些訊息作為回覆。目前不支援在訊息範本中傳送此類訊息。

聯絡人訊息

第 1 步:向 /messages 發出 POST 要求

POST /v1/messages
{
    "to": "recipient-wa-id",
    "type": "contacts",
    "contacts": [
                {
                    "addresses": [
                        {
                            "city": "Menlo Park",
                            "country": "United States",
                            "country_code": "us",
                            "state": "CA",
                            "street": "1 Hacker Way",
                            "type": "HOME",
                            "zip": "94025"
                        },
                        {
                            "city": "Menlo Park",
                            "country": "United States",
                            "country_code": "us",
                            "state": "CA",
                            "street": "200 Jefferson Dr",
                            "type": "WORK",
                            "zip": "94025"
                        }
                    ],
                    "birthday": "2012-08-18",
                    "emails": [
                        {
                            "email": "test@fb.com",
                            "type": "WORK"
                        },
                        {
                            "email": "test@whatsapp.com",
                            "type": "WORK"
                        }
                    ],
                    "name": {
                        "first_name": "John",
                        "formatted_name": "John Smith",
                        "last_name": "Smith"
                    },
                    "org": {
                        "company": "WhatsApp",
                        "department": "Design",
                        "title": "Manager"
                    },
                    "phones": [
                        {
                            "phone": "+1 (940) 555-1234",
                            "type": "HOME"
                        },
                        {
                            "phone": "+1 (650) 555-1234",
                            "type": "WORK",
                            "wa_id": "16505551234"
                        }
                    ],
                    "urls": [
                        {
                             "url": "https://www.facebook.com",
                             "type": "WORK"
                        }
                    ]
                }
            ]
}

如需有關參數的更多資訊,請參閱:

第 2 步:檢查回應

成功的回應如下所示:

{
    "messages": [{
       "id": "message-id"
    }]
}

地點訊息

第 1 步:向 /messages 發出 POST 要求

POST /v1/messages

{
    "to": "recipient-wa-id",
    "type": "location",
    "location": {
        "longitude": -122.425332,
        "latitude": 37.758056,
        "name": "Facebook HQ",
        "address": "1 Hacker Way, Menlo Park, CA 94025"
    }
}

如需有關參數的更多資訊,請參閱:

第 2 步:檢查回應

成功的回應如下所示:

{
    "messages": [{
       "id": "message-id"
    }]
}