開始之前,建議您先看過我們的開發人員文件和 Postman 文件集。這有助於您瞭解雲端 API 的運作方式,包括如何開始使用以及移轉電話號碼。
您必須使用「內嵌註冊」將新顧客設置到雲端 API。如果尚未設置,請整合並啟用內嵌註冊。「內嵌註冊」是註冊顧客最快、最簡單的方式,五分鐘內就能夠讓顧客開始傳送訊息。
接著,請想想您要先將哪些用戶端移轉到雲端 API。一般我們會建議將所有用戶端從內部部署移轉到雲端 API,但每個用戶端的需求可能有所不同。當您思考要移轉哪些用戶端時,請考量:
考量 | 更多背景資訊 |
---|---|
雲端 API 是否支援用戶端的傳輸量和訊息量? | 雲端 API 以每秒 250 則訊息的累加峰值傳輸量支援大多數商家,包括文字/影音素材和傳入/傳出。 |
雲端 API 是否符合用戶端的合規性需求? | 雲端 API 符合 GDPR 並具有 SOC 2 認證。伺服器主機設在北美和歐洲。 |
用戶端是否使用雲端 API 支援的功能? | 支援大多數主要功能。在這裡查看完整清單。 |
您只要知道哪個用戶端需要移轉,就可以制訂移轉計畫和時間表。
在您建立計畫時,請記得針對兩種情境設計您的系統:設置新顧客,以及將既有顧客從內部部署移轉到雲端 API。針對移轉情境,請納入備份現有內部部署實例,以及將這些電話號碼移轉到雲端 API 的計畫。
首先,您需要決定是否通知現有用戶端有關移轉的事項。然後,您應該判斷是否需要建立或更新任何文件,以支援雲端 API 設定。
由於 Meta 已承擔雲端 API 的託管成本,您應該決定是否要因此更新價格。
若要使用雲端 API,解決方案合作夥伴需要擁有下列資產:
資產 | 特定的指示 |
---|---|
企業管理平台 | 您可以使用現有的企業管理平台,也可以設定新的企業管理平台。儲存企業管理平台編號。 |
WhatsApp Business 帳號(WABA) | |
如果您沒有應用程式,請務必建立一個「商務」類型的應用程式。別忘了新增應用程式的顯示名稱和聯絡電子郵件。 做為(解決方案合作夥伴),您的應用程式必須通過應用程式審查,並要求下列權限的進階存取權限:
解決方案合作夥伴也可以視需要為不同的用戶端和 WABA 使用同一個 Meta 應用程式。但請注意,每個應用程式只能有一個 Webhook 端點,且必須分別進行應用程式審查。 | |
系統用戶 | 如需相關說明,請參閱新增系統用戶至企業管理平台。 目前擁有
進行生產部署時,建議您使用管理員系統用戶。如需更多資訊,請參閱關於企業管理平台的角色和權限。 |
商家電話號碼 | 這是商家用來傳送訊息的電話號碼。請務必透過簡訊/語音通話驗證電話號碼。 適用於解決方案合作夥伴和直接商家的指示:如果您想要使用自己的電話號碼,就應該在 WhatsApp 管理工具中新增電話號碼,並透過圖形 API 使用驗證端點來完成驗證程序。 適用於使用解決方案合作夥伴之商家的指示:如果您想要使用自己的電話號碼,就應該透過該解決方案合作夥伴的內嵌註冊流程新增對方的電話號碼,並完成驗證程序。 電話號碼的驗證狀態並不會影響內部部署和雲端 API 之間的移轉。如果您無法使用內嵌註冊流程來驗證電話號碼,建議您透過內部部署解決方案來進行驗證,再將這些電話號碼移轉至雲端 API。 可以採用雲端 API 的商家電話號碼數量沒有限制。 |
消費者電話號碼 | 這是目前正在使用 WhatsApp 消費者應用程式的電話號碼。系統會將您透過商家電話號碼發送的訊息傳送到這組電話號碼。 |
若要使用 WhatsApp Business 訊息雲端 API,您必須先代表商家接受《WhatsApp Business 平台服務條款》。
方法是前往 WhatsApp 管理工具,然後在資訊橫幅中接受服務條款。
如果您是雲端 API 的既有測試版合作夥伴,則有 90 天的寬限期。也就是說,您必須在 2022 年 7 月 5 日前接受條款,否則就會失去使用權限。
如果是初次使用雲端 API的商家(包括從內部部署 API 移轉過來的商家),請務必先接受服務條款,才能開始使用雲端 API。在您接受服務條款之前,都無法接聽註冊通話。
如果您是開發人員,一律須接受服務條款;如果您是解決方案合作夥伴,則不需要顧客接受相關條款。
圖形 API 呼叫會使用存取權杖進行驗證。如需詳細資訊,請參閱存取權杖。我們建議您以系統用戶的角色產生權杖。
產生系統用戶存取權杖的方法如下:
whatsapp_business_management
和 whatsapp_business_messaging
。點擊產生權杖。設定 Webhook 後,您就能接收來自 WhatsApp Business 平台的即時 HTTP 通知。舉例來說,如果您收到顧客的訊息,或是 WhatsApp Business 帳號(WABA)有異動,系統就會傳送通知。
若要設定 Webhook,您必須使用符合 Meta 和 WhatsApp 要求的網址來建立連結網際網路的網路伺服器。如需相關操作指示,請參閱建立端點。如果您需要端點以供測試之用,則可產生測試 Webhooks 端點。
端點準備就緒後,請按照下列步驟完成相關設定,方便 Meta 應用程式使用:
在應用程式主控板中,找到 WhatsApp 產品,然後點擊設定。接著找到 Webhooks 區塊,然後點擊設定 Webhook。點擊後,畫面上會出現對話方塊,要求您輸入兩個項目:
新增資訊後,請點擊驗證和儲存。
返回應用程式主控板,點擊左側面板中的 WhatsApp > 設定。點擊 Webhooks 下方的管理,隨即出現一個對話方塊,顯示您可以收到通知的所有物件。若要接收用戶的訊息,請點擊訂閱訊息。
您只需要針對每個應用程式設定 Webhooks 一次即可。您可以使用相同的 Webhook 接收來自多個 WhatsApp Business 帳號的多種事件類型。如需更多資訊,請參閱 Webhooks 一節。
每個 Meta 應用程式在任何時候都只能設定一個端點。如果您需要將 Webhook 更新傳送到多個端點,則需要多個 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'
如果要求成功,回應會包含所有連結至您 WABA 的電話號碼:
{ "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 小時內都可以免費回傳訊息,這段時間稱為「顧客服務時段」。為了進行測試,我們會啟用這個時段,您要傳送多少訊息都可以。
如果是使用個人的 iOS 版/Android 版 WhatsApp 應用程式,請傳送訊息至剛才註冊的電話號碼。發送訊息後,您應該會收到傳送至 Webhook 的傳入訊息和通知,格式如下所示。
{ "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,而其條款將提供此服務之用途限制為僅供投遞訊息。WhatsApp 無法存取金鑰或訊息。