发送联系人和位置消息

使用 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"
    }]
}