LetsBot 菜单
立即开始 简体中文 语言

Meta 商业合作伙伴 英国注册公司

语言

Messages · API 端点

POST /api/v1/button/template

Send buttons template message

You can send buttons Template message to phone number.

You can send buttons Template message to phone number. You need to send the title(optional), footer(optional), body and buttons(array , exp format in body) of the message. Id of the message in the key of the data of the response. In the Message of the data of the response , You can see templateMessage that contain buttons info (hydratedButtons, displayText, url index, etc) , messageTimesamp format and status of the message.

表单字段

字段示例
phone{{phone}}
titlehello title
bodyhello body
footertest footer
buttons[0][id]4
buttons[0][title]:star:Star LetsBot on GitHub!
buttons[0][type]1
buttons[0][extra_data]https://example.com

请求示例

curl -X POST "https://letsbot.net/api/v1/button/template" \
  -H "Authorization: Bearer YOUR_LB_API_KEY" \
  -H "Accept: application/json" \
  -F "phone=9665xxxxxxxx" \
  -F "title=hello title" \
  -F "body=hello body" \
  -F "footer=test footer" \
  -F "buttons[0][id]=4" \
  -F "buttons[0][title]=:star:Star LetsBot on GitHub!" \
  -F "buttons[0][type]=1" \
  -F "buttons[0][extra_data]=https://example.com"
const response = await fetch("https://letsbot.net/api/v1/button/template", {
  method: "POST",
  headers: {
    "Authorization": "Bearer YOUR_LB_API_KEY",
    "Accept": "application/json",
  },
  body: new URLSearchParams({
    "phone": "9665xxxxxxxx",
    "title": "hello title",
    "body": "hello body",
    "footer": "test footer",
    "buttons[0][id]": "4",
    "buttons[0][title]": ":star:Star LetsBot on GitHub!",
    "buttons[0][type]": "1",
    "buttons[0][extra_data]": "https://example.com",
  }),
});

const data = await response.json();
console.log(data);
<?php

$ch = curl_init('https://letsbot.net/api/v1/button/template');

curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer YOUR_LB_API_KEY',
        'Accept: application/json',
    ],
    CURLOPT_POSTFIELDS => http_build_query([
        'phone' => '9665xxxxxxxx',
        'title' => 'hello title',
        'body' => 'hello body',
        'footer' => 'test footer',
        'buttons[0][id]' => '4',
        'buttons[0][title]' => ':star:Star LetsBot on GitHub!',
        'buttons[0][type]' => '1',
        'buttons[0][extra_data]' => 'https://example.com',
    ]),
]);

$data = json_decode(curl_exec($ch), true);
curl_close($ch);

print_r($data);
import requests

response = requests.request(
    "POST",
    "https://letsbot.net/api/v1/button/template",
    headers={
        "Authorization": "Bearer YOUR_LB_API_KEY",
        "Accept": "application/json",
    },
    data={
        "phone": "9665xxxxxxxx",
        "title": "hello title",
        "body": "hello body",
        "footer": "test footer",
        "buttons[0][id]": "4",
        "buttons[0][title]": ":star:Star LetsBot on GitHub!",
        "buttons[0][type]": "1",
        "buttons[0][extra_data]": "https://example.com",
    },
)

print(response.json())

响应

Success Response200
(空响应体)

随时为你准备就绪

用您自己的号码试用此端点

API 在免费试用期间即可使用。创建账户,连接您的 WhatsApp 号码,然后在 API → 认证数据 中复制您的密钥。