開始之前,建議您先詳閱我們的開發人員文件和 Postman 收藏。這樣有助您理解雲端 API 的運作方式,包括如何開始使用和轉移號碼。
您必須使用內嵌註冊功能協助新顧客展開雲端 API 入門流程。如果您未曾使用內嵌註冊,請整合並啟用此功能。內嵌註冊是最快捷簡單的顧客註冊方式,他們可以在五分鐘內完成註冊並開始傳送訊息。
接下來,請考慮您希望首先把哪些客戶轉移至雲端 API。一般來說,我們建議您把所有客戶從內部部署 API 轉移至雲端 API,但每位客戶的需求可能各有不同。在考慮轉移哪些客戶時,請注意以下事項:
考慮因素 | 更多背景資訊 |
---|---|
雲端 API 能否支援我客戶的輸送量和訊息量? | 雲端 API 為大多數商家提供每秒 250 則訊息的峰值訊息輸送量,當中包括文字/媒體,以及傳入/傳出訊息。 |
雲端 API 能否滿足我客戶的合規要求? | 雲端 API 符合 GDPR 規定並具有 SOC 2 認證。伺服器寄存地為北美洲和歐洲。 |
雲端 API 能否支援我客戶使用的功能? | 大部分重要功能均受支援。在此查閱完整清單。 |
當您確定轉移對象後,即可開始制定轉移計劃和時間表。
制定計劃時,請記得系統設計需要符合以下兩種情況:協助新顧客展開入門流程,以及將現有顧客從內部部署 API 轉移至雲端 API。如果是轉移客戶,請加入一些相關的計劃,以將您目前的內部部署實例備份並把相關號碼轉移至雲端 API。
首先,您需要確定是否要通知現有客戶有關轉移的事宜。然後,您應確定是否需要建立或更新任何文件,以支援雲端 API 設定。
雲端 API 的寄存費用由 Meta 承擔,因此您要決定是否對您的定價作出相應更新。
如要使用雲端 API,解決方案合作夥伴必須擁有以下資產:
資產 | 具體指示 |
---|---|
企業管理平台 | 您可以使用現有企業管理平台,亦可以設定新平台。儲存企業管理平台編號。 |
WhatsApp Business 帳戶(WABA) | |
如果您還沒有應用程式,則需建立一個類型為「商業」的應用程式。請記得為應用程式新增顯示名稱和聯絡電郵。 如果您是解決方案合作夥伴,您的應用程式必須通過應用程式審查,以及要求取得以下權限的進階存取權限:
作為解決方案合作夥伴,您還可以透過不同用戶端及不同 WhatsApp Business 帳戶隨意使用同一個 Meta 應用程式。但請注意,每個應用程式都只能有一個 Webhook 端點,而且都要通過應用程式審查。 | |
系統用戶 | 如需協助,請參閱將系統用戶新增至企業管理平台。 目前,擁有
建議在正式部署時使用管理員系統用戶。如需了解更多資訊,請參閱關於企業管理平台角色及權限。 |
商家電話號碼 | 此為商家用來傳送訊息的電話號碼。電話號碼需要通過短訊/語音通話驗證。 解決方案合作夥伴和直接商家:如欲使用自己的號碼,應在 WhatsApp 管理工具新增電話號碼,然後透過 Graph API 的驗證端點驗證電話號碼。 使用解決方案合作夥伴的商家:如欲使用自己的號碼,則應根據解決方案合作夥伴的內嵌註冊流程新增和驗證號碼。 電話號碼的驗證狀態不會影響企業內部 API 與雲端 API 之間的轉移。如果您無法存取內嵌註冊流程以驗證電話號碼,建議您先使用企業內部解決方案驗證電話號碼,然後再將這些號碼轉移至雲端 API。 可以採用雲端 API 的商家電話號碼數量不設限制。 |
消費者電話號碼 | 此為目前使用消費者 WhatsApp 應用程式的電話號碼。這個號碼會接收由您商家電話號碼傳來的訊息。 |
如要存取 WhatsApp Business 訊息雲端 API,您必須先代表商家接受《WhatsApp Business 平台服務條款》。
操作方法如下:前往 WhatsApp 管理工具,在資訊橫額中接受服務條款。
如果您目前是雲端 API 的測試版合作夥伴,則可享有 90 天的寬限期。換言之,您必須在 2022 年 7 月 5 日之前接受條款,否則會失去存取權。
如果您是初次使用雲端 API 的商家(包括從內部部署 API 轉移過來的商家),請務必先接受服務條款,否則無法開始使用雲端 API。如不接受服務條款,您將無法接收註冊通話。
開發人員必須接受服務條款;解決方案合作夥伴不必要求顧客接受服務條款。
Graph API 呼叫會使用存取憑證以作驗證。詳情請參閱存取憑證。建議您以系統用戶的角色產生憑證。
如要產生系統用戶存取憑證:
whatsapp_business_management
和 whatsapp_business_messaging
。點擊產生憑證。設定 Webhooks 後,您可以接收來自 WhatsApp Business 平台的即時 HTTP 通知。這就表示,如果您收到顧客的訊息,或是 WhatsApp Business 帳戶有所變更或發生其他情況,系統就會傳送通知。
如要設定 Webhooks,您必須使用符合 Meta 和 WhatsApp 要求的網址來建立連結互聯網的網絡伺服器。如需具體指示,請參閱建立端點。如果需要端點以供測試之用,您可以產生測試 Webhooks 端點。
準備好端點後,請配置此端點以供 Meta 應用程式使用:
在應用程式管理中心,找出 WhatsApp 產品並點擊配置。然後,找出 Webhooks 區塊並點擊配置 Webhook。點擊之後,螢幕上會顯示一個對話框,要求您提供以下兩項內容:
加入資訊後,點擊驗證並儲存。
返回應用程式管理中心,依次點擊左側面板的 WhatsApp > 配置。在 Webhooks 下方,點擊管理。頁面隨即會開啟一個對話框,其中包含您可收到相關通知的所有物件。如要接收用戶的訊息,請為訊息點擊訂閱。
您只需為每個應用程式設定一次 Webhooks。您可以使用相同的 Webhook 接收來自多個 WhatsApp Business 帳戶的多個事件類型。詳情請參閱我們的 Webhooks 部分。
在任何情況下,您只能為每個 Meta 應用程式配置一個端點。如果您需要將 Webhooks 更新傳送到多個端點,則需要多個 Meta 應用程式。
為確保收到的通知來自正確的帳戶,請訂閱您的應用程式:
curl -X POST \
'https://graph.facebook.com/v19.0
/WHATSAPP_BUSINESS_ACCOUNT_ID/subscribed_apps' \
-H 'Authorization: Bearer ACCESS_TOKEN'
如果收到以下回應,此帳戶下的電話號碼的所有 Webhook 事件都將傳送至您已配置的 Webhooks 端點。
{ "success": true }
如要傳送訊息,您必須註冊要使用的電話號碼,即上文準備工作所提及的商家電話號碼。
繼續進行註冊程序前,您必須找出該電話號碼的編號。如要取得電話號碼編號,請發出以下 API 呼叫:
curl -X GET \
'https://graph.facebook.com/v19.0
/WHATSAPP_BUSINESS_ACCOUNT_ID/phone_numbers' \
-H 'Authorization: Bearer ACCESS_TOKEN'
如果要求成功,回應中將包含與您 WhatsApp Business 帳戶關聯的所有電話號碼:
{ "data": [ { "verified_name": "Jasper's Market", "display_phone_number": "+1 631-555-5555", "id": "1906385232743451", "quality_rating": "GREEN" }, { "verified_name": "Jasper's Ice Cream", "display_phone_number": "+1 631-555-5556", "id": "1913623884432103", "quality_rating": "NA" } ] }
儲存您想註冊的電話號碼之編號。如欲了解此端點的更多資訊,請參閱讀取電話號碼。
如果您要將手機號碼從內部 API 轉移到雲端 API,便需要在經雲端 API 註冊手機號碼前採取一些額外步驟。請參閱內部 API 和雲端 API 之間的轉移以了解完整流程。
取得電話號碼編號後,您便可以註冊號碼。在註冊 API 呼叫中,您需要同時執行以下兩項操作:
必須設定雙重驗證,方能使用雲端 API。如未設定,您會收到入門失敗訊息:
要求範例:
curl -X POST \
'https://graph.facebook.com/v19.0
/FROM_PHONE_NUMBER_ID/register' \
-H 'Authorization: Bearer ACCESS_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"messaging_product": "whatsapp","pin": "6_DIGIT_PIN"}'
回應範例:
{ "success": true }
必須在完成內嵌註冊流程後的 14 天內註冊電話號碼。如果未在此時段內註冊號碼,則您必須再次完成內嵌註冊流程,然後才能重新註冊。
當參與互動的顧客向您的商家傳送訊息時,您可以在 24 小時內免費與其互傳訊息,這段期間稱為「顧客服務時段」。出於測試目的,我們建議您啟用這個時段,這樣您就可以按需要傳送多則訊息,不受限制。
使用個人 WhatsApp iOS/Android 應用程式,向您剛才註冊的電話號碼傳送訊息。傳送訊息後,您應該會收到一則傳送至 Webhooks 且附有通知的傳入訊息,此訊息的格式如下:
{ "object": "whatsapp_business_account", "entry": [ { "id": "WHATSAPP_BUSINESS_ACCOUNT_ID", "changes": [ { "value": { "messaging_product": "whatsapp", "metadata": { "display_phone_number": "16315551234", "phone_number_id": "PHONE_NUMBER_ID" }, "contacts": [ { "profile": { "name": "Kerry Fisher" }, "wa_id": "16315555555" } ], "messages": [ { "from": "16315555555", "id": "wamid.ABGGFlA5FpafAgo6tHcNmNjXmuSf", "timestamp": "1602139392", "text": { "body": "Hello!" }, "type": "text" } ] }, "field": "messages" } ] } ] }
啟用顧客服務時段後,您可以向上一步所用到的消費者號碼傳送測試訊息。如要執行此操作,請發出以下 API 呼叫:
curl -X POST \
'https://graph.facebook.com/v19.0
/FROM_PHONE_NUMBER_ID/messages' \
-H 'Authorization: Bearer ACCESS_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"messaging_product": "whatsapp", "to": "16315555555","text": {"body" : "hello world!"}}'
如果呼叫成功,回應中將包含訊息編號。您可以使用這個編號,透過 Webhooks 追蹤訊息進度。編號的長度上限為 128 個字元。
回應範例:
{ "id":"wamid.gBGGFlaCGg0xcvAdgmZ9plHrf2Mh-o" }
我們會在每個月的第一個星期二發佈雲端 API 更新,其中包括全新功能和改善項目。由於雲端 API 會自動更新,因此您無需採取任何操作都可使用這些新功能。
WhatsApp develops and operates the WhatsApp Business API, which enables businesses to communicate with WhatsApp consumer users on the WhatsApp network. When using the Cloud API, Meta will host the WhatsApp Business API for you and provide an endpoint for the WhatsApp service for your incoming and outgoing WhatsApp communications.
No, there is no difference in messaging prices between the Cloud API and the On-Premises API. Access to Cloud API is free, and we expect it to generate additional cost savings for developers. The two types of cost savings for the Cloud API are 1) set up cost (including server or external cloud provider cost), 2) ongoing cost of maintenance (including engineering time for API upgrades).
A Solution Partner can select which setup a given client should use. We recommend that the majority of clients use the Cloud API for ease of implementation and maintenance. Solution Partners can also continue to maintain integration with the On-Premises API.
We want to make it clear what it means to message with a business on WhatsApp. Some businesses may choose to use Meta or another company to help them manage and store their messages. When a business chooses to manage their messages with another company, we will let consumers know by showing a different system message. Learn more.
We expect Cloud API to provide the same key features as the On-Premises API soon, including user change notifications and sticker pack management. Our goal is for the Cloud API to become the preferred platform for new features.
We will release updates monthly with new features and improvements. There is no work required to access these features - the Cloud API updates automatically.
No, we will continue to provide the On-Premises API for now. See On-Premises API for information.
The Cloud API architecture significantly simplifies the Solution Partner's operational and infrastructure requirements to integrate with WhatsApp Business Platform. First, it removes the infrastructure requirements to run Business API docker containers (CAPEX savings). Second, it obviates the need of operational responsibilities to manage the deployment (OPEX savings). For details, refer to the architecture diagram comparing the On-Premises and Cloud API deployments.
Solution Partners and direct clients do not need the WebApp and CoreApp containers that are used in the On-Premises API. Meta will manage all database data and media data on behalf of the Solution Partner or direct client.
We will have disaster recovery and data replication across multiple regions. The expected downtime would be within our SLA and usually in the order of less than a minute to less than five minutes.
As your on-premises performance depends heavily on your hardware, software, and connectivity to WhatsApp servers, if you wish to understand these differences, you can perform your own load tests on Cloud API as you might have done for your own on-premises installation. You can also refer to our performance comparison to understand more details around how the on-premise and Cloud APIs compare.
雲端 API 會在 Meta 資料中心運作,除非商家選擇使用雲端 API 本機儲存空間。Meta 在北美和歐洲地區設有資料中心。
閒置訊息會經過加密,並於 30 天後自動刪除。
就像所有其他 WhatsApp Business API 解決方案合作夥伴一樣,Meta 可以為商家代管加密和解密金鑰。為了透過雲端 API 收發訊息,雲端 API 會為商家代管加密/解密金鑰。Meta 會負責雲端 API 的營運,其條款也會限制 Meta 僅為了傳送訊息才提供這項服務。WhatsApp 無法存取金鑰和訊息。