This method allows you to add a tag to a specified chat. Tags are a powerful tool for categorizing and filtering chats, which simplifies navigation and searching for necessary dialogues. Tags help organize chats by topics, priorities, statuses, and other criteria important for your business process.
curl -X GET "https://wamm.chat/api2/contact_tag_set/YOUR_TOKEN/79001234567/VIP%20Client"
function addTagToChat($token, $phone, $tagName) {
// Prepare the request URL with tag encoding
$url = "https://wamm.chat/api2/contact_tag_set/$token/$phone/" . urlencode($tagName);
// Execute the request
$response = file_get_contents($url);
// Process the response
if ($response !== false) {
// Convert the response to an array
$json_response = json_decode($response, true);
// Check for errors
if (isset($json_response['err'])) {
if ($json_response['err'] == 0 && $json_response['result'] == 'success') {
echo "Tag successfully added to chat";
} else {
echo "Error: " . $json_response['err'];
}
} else {
echo "Failed to process server response";
}
} else {
echo "Failed to execute request to server";
}
}
// Use the function to add a tag to a chat
$token = "YOUR_TOKEN";
$phone = "79001234567";
$tagName = "VIP Client";
addTagToChat($token, $phone, $tagName);