Şablonla ilk mesaj ve müşterinin cevabı
Onaylı bir şablonla müşteriye ilk mesajı gönderir, müşterinin cevabını iletim adresinizde alır ve yanıt ucuyla cevap verirsiniz.
Adımlar
-
Anahtar üretin Panel
API altyapısı › Sunulan sekmesi › Anahtar üret. Anahtarda WhatsApp uygulaması işaretli olmalı. Anahtar her isteğin
Authorizationbaşlığında gider: Kimlik doğrulama ve imza. -
İletim adresinizi tanımlayın Panel
Müşterinin cevabı size mesaj kopyası olarak gelir. Adresi API altyapısı › Gönderdiğimiz sekmesinde bir bağlantının İletim adresi alanına yazın ve paylaşılan sırrı bağlantının Sırlar bölümünden alın: Olaylar › İletim adresi, İmzalar › Paylaşılan sır.
-
Şablonla ilk mesajı gönderin Sizin sisteminiz
POST/v1/whatsapp/conversationsŞablonun adını ve gönderebileceği hatları şablon listesinden alın; liste yalnız bilgilendirme şablonlarını içerir, pazarlama ya da doğrulama şablonuyla konuşma başlatılamaz (
404 NOT_FOUND). Gönderimde kendi işlem numaranızıIdempotency-Keybaşlığına yazın; yanıt alamayıp yeniden denediğinizde ikinci mesaj gönderilmez. Müşteriye yanıtı yazacak personeliagentalanında verin: kendi sisteminizdeki kimliğiexternal_id, adıname. Konuşma bu personele bağlanır; yanıt ucu konuşmanın sahibini ister (6. adım). Yanıttakiidkonuşmanın kimliğidir, saklayın. Alanlar ve ret durumları: Şablonla gönderim › Gönderim, Tekrar anahtarı.Sonraki adımda kullanılan alan:
id. Ucun alanları, kuralları ve hataları: Yazışması olmayan bir numaraya onaylı şablonla ilk mesajı gönderir ve konuşmayı açar.İstek
curl -X POST "https://api.veritakibi.com/v1/whatsapp/conversations" \ -H "Authorization: Bearer <YOUR_API_KEY>" \ -H "Idempotency-Key: <IDEMPOTENCY_KEY>" \ -H "Content-Type: application/json" \ -d '{ "to": "<VALUE>", "line": "<VALUE>", "template": "<VALUE>", "language": "<VALUE>", "variables": [], "media": { "kind": "<VALUE>", "link": "<VALUE>", "filename": "<VALUE>" }, "agent": { "external_id": "<VALUE>", "name": "<VALUE>" }, "place": "<VALUE>", "expected": "<VALUE>" }'
// The key is read from an environment variable, never written into the code $apiKey = getenv('VERITAKIBI_API_KEY'); $body = '{ "to": "<VALUE>", "line": "<VALUE>", "template": "<VALUE>", "language": "<VALUE>", "variables": [], "media": { "kind": "<VALUE>", "link": "<VALUE>", "filename": "<VALUE>" }, "agent": { "external_id": "<VALUE>", "name": "<VALUE>" }, "place": "<VALUE>", "expected": "<VALUE>" }'; $ch = curl_init('https://api.veritakibi.com/v1/whatsapp/conversations'); curl_setopt_array($ch, [ CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => $body, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [ 'Authorization: Bearer ' . $apiKey, 'Idempotency-Key: <IDEMPOTENCY_KEY>', 'Content-Type: application/json', ], ]); $response = json_decode(curl_exec($ch), true); $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// Node 18+: built-in fetch; save as .mjs (import syntax) // The key is read from an environment variable, never written into the code const apiKey = process.env.VERITAKIBI_API_KEY; const res = await fetch('https://api.veritakibi.com/v1/whatsapp/conversations', { method: 'POST', headers: { 'Authorization': `Bearer ${apiKey}`, 'Idempotency-Key': '<IDEMPOTENCY_KEY>', 'Content-Type': 'application/json', }, body: JSON.stringify({ "to": "<VALUE>", "line": "<VALUE>", "template": "<VALUE>", "language": "<VALUE>", "variables": [], "media": { "kind": "<VALUE>", "link": "<VALUE>", "filename": "<VALUE>" }, "agent": { "external_id": "<VALUE>", "name": "<VALUE>" }, "place": "<VALUE>", "expected": "<VALUE>" }), }); const response = await res.json(); const status = res.status;
# Python 3.6+: standard library only (urllib, json) # The key is read from an environment variable, never written into the code import json, os, urllib.request api_key = os.environ['VERITAKIBI_API_KEY'] body = '''{ "to": "<VALUE>", "line": "<VALUE>", "template": "<VALUE>", "language": "<VALUE>", "variables": [], "media": { "kind": "<VALUE>", "link": "<VALUE>", "filename": "<VALUE>" }, "agent": { "external_id": "<VALUE>", "name": "<VALUE>" }, "place": "<VALUE>", "expected": "<VALUE>" }'''.encode() req = urllib.request.Request( 'https://api.veritakibi.com/v1/whatsapp/conversations', data=body, method='POST', headers={ 'Authorization': f'Bearer {api_key}', 'Idempotency-Key': '<IDEMPOTENCY_KEY>', 'Content-Type': 'application/json', }, ) with urllib.request.urlopen(req) as res: status = res.status response = json.load(res)
// Go 1.18+: standard library only (net/http, encoding/json) // The key is read from an environment variable, never written into the code package main import ( "encoding/json" "net/http" "os" "strings" ) func main() { apiKey := os.Getenv("VERITAKIBI_API_KEY") body := `{ "to": "<VALUE>", "line": "<VALUE>", "template": "<VALUE>", "language": "<VALUE>", "variables": [], "media": { "kind": "<VALUE>", "link": "<VALUE>", "filename": "<VALUE>" }, "agent": { "external_id": "<VALUE>", "name": "<VALUE>" }, "place": "<VALUE>", "expected": "<VALUE>" }` req, err := http.NewRequest("POST", "https://api.veritakibi.com/v1/whatsapp/conversations", strings.NewReader(body)) if err != nil { panic(err) } req.Header.Set("Authorization", "Bearer "+apiKey) req.Header.Set("Idempotency-Key", "<IDEMPOTENCY_KEY>") req.Header.Set("Content-Type", "application/json") res, err := http.DefaultClient.Do(req) if err != nil { panic(err) } defer res.Body.Close() status := res.StatusCode var response map[string]any json.NewDecoder(res.Body).Decode(&response) _, _ = status, response }
// Java 11+: built-in java.net.http; file name Example.java // The key is read from an environment variable, never written into the code import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; public class Example { public static void main(String[] args) throws Exception { String apiKey = System.getenv("VERITAKIBI_API_KEY"); String body = "{\"to\": \"<VALUE>\", \"line\": \"<VALUE>\", \"template\": \"<VALUE>\", \"language\": \"<VALUE>\", \"variables\": [], \"media\": {\"kind\": \"<VALUE>\", \"link\": \"<VALUE>\", \"filename\": \"<VALUE>\"}, \"agent\": {\"external_id\": \"<VALUE>\", \"name\": \"<VALUE>\"}, \"place\": \"<VALUE>\", \"expected\": \"<VALUE>\"}"; HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://api.veritakibi.com/v1/whatsapp/conversations")) .header("Authorization", "Bearer " + apiKey) .header("Idempotency-Key", "<IDEMPOTENCY_KEY>") .header("Content-Type", "application/json") .method("POST", HttpRequest.BodyPublishers.ofString(body)) .build(); HttpResponse<String> res = HttpClient.newHttpClient() .send(request, HttpResponse.BodyHandlers.ofString()); // JSON text; Java has no built-in JSON parser, use a JSON library String response = res.body(); int status = res.statusCode(); } }
// .NET 6+: top-level statements; default console template (implicit usings on) // The key is read from an environment variable, never written into the code using System.Net.Http.Headers; using System.Text; using System.Text.Json; var apiKey = Environment.GetEnvironmentVariable("VERITAKIBI_API_KEY"); var body = "{\"to\": \"<VALUE>\", \"line\": \"<VALUE>\", \"template\": \"<VALUE>\", \"language\": \"<VALUE>\", \"variables\": [], \"media\": {\"kind\": \"<VALUE>\", \"link\": \"<VALUE>\", \"filename\": \"<VALUE>\"}, \"agent\": {\"external_id\": \"<VALUE>\", \"name\": \"<VALUE>\"}, \"place\": \"<VALUE>\", \"expected\": \"<VALUE>\"}"; using var http = new HttpClient(); var request = new HttpRequestMessage(new HttpMethod("POST"), "https://api.veritakibi.com/v1/whatsapp/conversations"); request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", apiKey); request.Headers.Add("Idempotency-Key", "<IDEMPOTENCY_KEY>"); request.Content = new StringContent(body, Encoding.UTF8); request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var res = await http.SendAsync(request); var response = JsonDocument.Parse(await res.Content.ReadAsStringAsync()); var status = (int)res.StatusCode;
// C++11+: requires libcurl (link with -lcurl) // The key is read from an environment variable, never written into the code #include <curl/curl.h> #include <cstdlib> #include <string> // Collects the response body into a string static size_t write_body(char* data, size_t size, size_t nmemb, void* out) { static_cast<std::string*>(out)->append(data, size * nmemb); return size * nmemb; } int main() { const char* api_key = std::getenv("VERITAKIBI_API_KEY"); std::string auth = std::string("Authorization: Bearer ") + (api_key ? api_key : ""); std::string body = R"({ "to": "<VALUE>", "line": "<VALUE>", "template": "<VALUE>", "language": "<VALUE>", "variables": [], "media": { "kind": "<VALUE>", "link": "<VALUE>", "filename": "<VALUE>" }, "agent": { "external_id": "<VALUE>", "name": "<VALUE>" }, "place": "<VALUE>", "expected": "<VALUE>" })"; std::string response; long status = 0; curl_global_init(CURL_GLOBAL_DEFAULT); CURL* ch = curl_easy_init(); curl_slist* headers = nullptr; headers = curl_slist_append(headers, auth.c_str()); headers = curl_slist_append(headers, "Idempotency-Key: <IDEMPOTENCY_KEY>"); headers = curl_slist_append(headers, "Content-Type: application/json"); curl_easy_setopt(ch, CURLOPT_URL, "https://api.veritakibi.com/v1/whatsapp/conversations"); curl_easy_setopt(ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_easy_setopt(ch, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(ch, CURLOPT_POSTFIELDS, body.c_str()); curl_easy_setopt(ch, CURLOPT_WRITEFUNCTION, write_body); curl_easy_setopt(ch, CURLOPT_WRITEDATA, &response); curl_easy_perform(ch); curl_easy_getinfo(ch, CURLINFO_RESPONSE_CODE, &status); curl_slist_free_all(headers); curl_easy_cleanup(ch); curl_global_cleanup(); }
Yanıt · 200 · değerler yer tutucudur
{ "id": 0, "group": "<VALUE>", "status": "<VALUE>", "customer": "<VALUE>", "owner_agent_id": 0, "owner_bot": false, "assignee_agent_id": 0, "owner": { "id": 0, "name": "<VALUE>", "external": false, "bot": false }, "assignee": { "id": 0, "name": "<VALUE>", "external": false, "bot": false }, "assistant_active": false, "claimed_at": "<VALUE>", "last_message_at": "<VALUE>", "created_at": "<VALUE>", "line": { "key": "<VALUE>", "number": "<VALUE>", "label": "<VALUE>" }, "source": { "kind": "<VALUE>", "source_id": "<VALUE>", "title": "<VALUE>", "body": "<VALUE>", "url": "<VALUE>", "message_id": 0, "created_at": "<VALUE>" }, "blocked": false, "name": "<VALUE>", "box": "<VALUE>", "unread": 0, "labels": [ { "id": 0, "name": "<VALUE>", "color": "<VALUE>", "group": "<VALUE>", "position": 0, "tab": false, "show_in_head": false } ], "summary": [ { "label": "<VALUE>", "value": "<VALUE>" } ], "summary_enabled": false } -
Mesaj kopyaları adresinize gelir VeriTakibi
Müşteri yazdığında onun mesajının kopyası (
directionIN) iletim adresinizePOSTile gelir. Şablonla gönderdiğiniz ilk mesajın kopyası gelmez; başlattığınız konuşmayı başlatma ucunun yanıtından kaydedin.conversation_idkonuşmanın kimliğidir,message_idmesajın kimliğidir. Aynı kopya birden çok kez gelebilir;message_idile tekilleştirin. Gövde alanları: Olaylar › Mesaj kopyası. -
İmzayı doğrulayın Sizin sisteminiz
Gövdeyi ayrıştırmadan önce
X-Vt-Signaturebaşlığını paylaşılan sırla hesapladığınız değerle karşılaştırın; tutmazsa isteği reddedin. Adımlar ve örnek kod: İmzalar › Doğrulama. İstek başarılı sayılsın diye2xxile yanıt verin: Olaylar › Yanıtınız. -
Müşteriye cevap verin Sizin sisteminiz
POST/v1/whatsapp/conversations/{id}/messagesKopyadaki
conversation_idile yanıt ucunu çağırın; metintextalanında, konuşmanın sahibi olan personelagentalanında gider (3. adımda verdiğinizexternal_id).agent.external_idboşsa ya da konuşmanın sahibi bu personel değilse (sahibi olmayan konuşma dahil) istek reddedilir; ret kodları uç listesindedir. İlk mesajıagentvermeden gönderdiyseniz konuşmayı önce devralma ucuyla personelin üzerine alın. Müşterinin size yazdığı andan sonraki sınırlı süre geçtiyse serbest metin gönderilemez; konuşmaya yeniden şablonla yazın. Yanıt ucuyla gönderdiğiniz mesajın kopyası adresinize geri gönderilmez; gönderdiğiniz mesajı ucun yanıtından kaydedin. Alanlar: Alan sözlüğü.Ucun alanları, kuralları ve hataları: Konuşmaya metin yanıtı gönderir.
İstek
curl -X POST "https://api.veritakibi.com/v1/whatsapp/conversations/<id>/messages" \ -H "Authorization: Bearer <YOUR_API_KEY>" \ -H "Content-Type: application/json" \ -d '{ "agent": { "external_id": "<VALUE>", "name": "<VALUE>" }, "text": "<VALUE>", "reply_to_id": 0 }'
// The key is read from an environment variable, never written into the code $apiKey = getenv('VERITAKIBI_API_KEY'); $body = '{ "agent": { "external_id": "<VALUE>", "name": "<VALUE>" }, "text": "<VALUE>", "reply_to_id": 0 }'; $ch = curl_init('https://api.veritakibi.com/v1/whatsapp/conversations/<id>/messages'); curl_setopt_array($ch, [ CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => $body, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [ 'Authorization: Bearer ' . $apiKey, 'Content-Type: application/json', ], ]); $response = json_decode(curl_exec($ch), true); $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// Node 18+: built-in fetch; save as .mjs (import syntax) // The key is read from an environment variable, never written into the code const apiKey = process.env.VERITAKIBI_API_KEY; const res = await fetch('https://api.veritakibi.com/v1/whatsapp/conversations/<id>/messages', { method: 'POST', headers: { 'Authorization': `Bearer ${apiKey}`, 'Content-Type': 'application/json', }, body: JSON.stringify({ "agent": { "external_id": "<VALUE>", "name": "<VALUE>" }, "text": "<VALUE>", "reply_to_id": 0 }), }); const response = await res.json(); const status = res.status;
# Python 3.6+: standard library only (urllib, json) # The key is read from an environment variable, never written into the code import json, os, urllib.request api_key = os.environ['VERITAKIBI_API_KEY'] body = '''{ "agent": { "external_id": "<VALUE>", "name": "<VALUE>" }, "text": "<VALUE>", "reply_to_id": 0 }'''.encode() req = urllib.request.Request( 'https://api.veritakibi.com/v1/whatsapp/conversations/<id>/messages', data=body, method='POST', headers={ 'Authorization': f'Bearer {api_key}', 'Content-Type': 'application/json', }, ) with urllib.request.urlopen(req) as res: status = res.status response = json.load(res)
// Go 1.18+: standard library only (net/http, encoding/json) // The key is read from an environment variable, never written into the code package main import ( "encoding/json" "net/http" "os" "strings" ) func main() { apiKey := os.Getenv("VERITAKIBI_API_KEY") body := `{ "agent": { "external_id": "<VALUE>", "name": "<VALUE>" }, "text": "<VALUE>", "reply_to_id": 0 }` req, err := http.NewRequest("POST", "https://api.veritakibi.com/v1/whatsapp/conversations/<id>/messages", strings.NewReader(body)) if err != nil { panic(err) } req.Header.Set("Authorization", "Bearer "+apiKey) req.Header.Set("Content-Type", "application/json") res, err := http.DefaultClient.Do(req) if err != nil { panic(err) } defer res.Body.Close() status := res.StatusCode var response map[string]any json.NewDecoder(res.Body).Decode(&response) _, _ = status, response }
// Java 11+: built-in java.net.http; file name Example.java // The key is read from an environment variable, never written into the code import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; public class Example { public static void main(String[] args) throws Exception { String apiKey = System.getenv("VERITAKIBI_API_KEY"); String body = "{\"agent\": {\"external_id\": \"<VALUE>\", \"name\": \"<VALUE>\"}, \"text\": \"<VALUE>\", \"reply_to_id\": 0}"; HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://api.veritakibi.com/v1/whatsapp/conversations/<id>/messages")) .header("Authorization", "Bearer " + apiKey) .header("Content-Type", "application/json") .method("POST", HttpRequest.BodyPublishers.ofString(body)) .build(); HttpResponse<String> res = HttpClient.newHttpClient() .send(request, HttpResponse.BodyHandlers.ofString()); // JSON text; Java has no built-in JSON parser, use a JSON library String response = res.body(); int status = res.statusCode(); } }
// .NET 6+: top-level statements; default console template (implicit usings on) // The key is read from an environment variable, never written into the code using System.Net.Http.Headers; using System.Text; using System.Text.Json; var apiKey = Environment.GetEnvironmentVariable("VERITAKIBI_API_KEY"); var body = "{\"agent\": {\"external_id\": \"<VALUE>\", \"name\": \"<VALUE>\"}, \"text\": \"<VALUE>\", \"reply_to_id\": 0}"; using var http = new HttpClient(); var request = new HttpRequestMessage(new HttpMethod("POST"), "https://api.veritakibi.com/v1/whatsapp/conversations/<id>/messages"); request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", apiKey); request.Content = new StringContent(body, Encoding.UTF8); request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var res = await http.SendAsync(request); var response = JsonDocument.Parse(await res.Content.ReadAsStringAsync()); var status = (int)res.StatusCode;
// C++11+: requires libcurl (link with -lcurl) // The key is read from an environment variable, never written into the code #include <curl/curl.h> #include <cstdlib> #include <string> // Collects the response body into a string static size_t write_body(char* data, size_t size, size_t nmemb, void* out) { static_cast<std::string*>(out)->append(data, size * nmemb); return size * nmemb; } int main() { const char* api_key = std::getenv("VERITAKIBI_API_KEY"); std::string auth = std::string("Authorization: Bearer ") + (api_key ? api_key : ""); std::string body = R"({ "agent": { "external_id": "<VALUE>", "name": "<VALUE>" }, "text": "<VALUE>", "reply_to_id": 0 })"; std::string response; long status = 0; curl_global_init(CURL_GLOBAL_DEFAULT); CURL* ch = curl_easy_init(); curl_slist* headers = nullptr; headers = curl_slist_append(headers, auth.c_str()); headers = curl_slist_append(headers, "Content-Type: application/json"); curl_easy_setopt(ch, CURLOPT_URL, "https://api.veritakibi.com/v1/whatsapp/conversations/<id>/messages"); curl_easy_setopt(ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_easy_setopt(ch, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(ch, CURLOPT_POSTFIELDS, body.c_str()); curl_easy_setopt(ch, CURLOPT_WRITEFUNCTION, write_body); curl_easy_setopt(ch, CURLOPT_WRITEDATA, &response); curl_easy_perform(ch); curl_easy_getinfo(ch, CURLINFO_RESPONSE_CODE, &status); curl_slist_free_all(headers); curl_easy_cleanup(ch); curl_global_cleanup(); }
Yanıt · 200 · değerler yer tutucudur
{ "id": 0, "direction": "<VALUE>", "kind": "<VALUE>", "body": "<VALUE>", "agent_id": 0, "sent_at": "<VALUE>", "media_state": "<VALUE>", "media_mime": "<VALUE>", "media_size": 0, "location": { "latitude": 0, "longitude": 0, "name": "<VALUE>", "address": "<VALUE>" }, "contacts": [ { "name": "<VALUE>", "phones": [ { "phone": "<VALUE>", "wa_id": "<VALUE>" } ] } ], "reply_to_id": 0, "delivered_at": "<VALUE>", "read_at": "<VALUE>", "reactions": [ { "emoji": "<VALUE>", "direction": "<VALUE>", "author": { "id": 0, "name": "<VALUE>", "external": false, "bot": false } } ], "delivery_state": "<VALUE>", "delivery_error_code": "<VALUE>", "resendable": false, "resend_of": 0, "payload": {}, "header_media": { "kind": "<VALUE>", "link": "<VALUE>", "filename": "<VALUE>" }, "quotable": false, "reactable": false, "author": { "id": 0, "name": "<VALUE>", "external": false, "bot": false } }
Sürüm öneki, sayfalama, zaman biçimi ve hata gövdesi: Sürümleme, sayfalama, limitler →