. Create an API key under API keys.Guide
Labels, automatic labelling and leads
Labels sort your customers: hot-lead, customer, complaint, anything you like. A chat can carry several labels, they are set by hand or by rules, and the same labels drive segments, broadcasts and the leads board. In the dashboard: Labels & automation, the Labels section of a chat in the inbox, and Leads.
One set of labels per person
For a chat with a person, the labels are the labels (tags) of that person's CRM contact, so they are the same on every device and in GET /v1/crm/segments filters and broadcasts. Labelling someone who is not a contact yet saves them as a contact. Group chats keep their own labels. Names are normalised: "Hot Lead" becomes hot-lead; up to 20 per chat.
curl -X POST "https://api.chatkomodo.com/v1/sessions/YOUR_DEVICE_ID/inbox/447700900123%40s.whatsapp.net/labels" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"add": [
"hot-lead",
"asks-price"
],
"remove": [
"cold"
]
}'const res = await fetch('https://api.chatkomodo.com/v1/sessions/YOUR_DEVICE_ID/inbox/447700900123%40s.whatsapp.net/labels', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.CHATKOMODO_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"add": [
"hot-lead",
"asks-price"
],
"remove": [
"cold"
]
}),
});
const data = await res.json();
if (!res.ok) throw new Error(`${data.code}: ${data.error}`);
console.log(data);import os
import requests
res = requests.post(
"https://api.chatkomodo.com/v1/sessions/YOUR_DEVICE_ID/inbox/447700900123%40s.whatsapp.net/labels",
headers={
"Authorization": f"Bearer {os.environ['CHATKOMODO_API_KEY']}",
},
json={
"add": [
"hot-lead",
"asks-price",
],
"remove": [
"cold",
],
},
timeout=30,
)
res.raise_for_status()
print(res.json())<?php
require 'vendor/autoload.php';
$client = new GuzzleHttp\Client();
$res = $client->request('POST', 'https://api.chatkomodo.com/v1/sessions/YOUR_DEVICE_ID/inbox/447700900123%40s.whatsapp.net/labels', [
'headers' => [
'Authorization' => 'Bearer ' . getenv('CHATKOMODO_API_KEY'),
],
'json' => [
'add' => [
'hot-lead',
'asks-price',
],
'remove' => [
'cold',
],
],
]);
print_r(json_decode((string) $res->getBody(), true));package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{
"add": [
"hot-lead",
"asks-price"
],
"remove": [
"cold"
]
}`)
req, err := http.NewRequest("POST", "https://api.chatkomodo.com/v1/sessions/YOUR_DEVICE_ID/inbox/447700900123%40s.whatsapp.net/labels", body)
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("CHATKOMODO_API_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
if res.StatusCode >= 400 {
panic(fmt.Sprintf("%d: %s", res.StatusCode, data))
}
fmt.Println(string(data))
}{
"labels": [
{
"name": "vip",
"color": "#A2255A"
},
{
"name": "hot-lead",
"color": "#B23A0E"
},
{
"name": "asks-price",
"color": "#0E6A7A"
}
],
"stage": "interested",
"person": true,
"history": [
{
"label": "asks-price",
"action": "add",
"source": "manual",
"rule_id": null,
"rule_name": null,
"actor": "admin",
"at": 1767225600000
}
]
}PUT /v1/sessions/{sid}/inbox/{chatId}/labels replaces all labels at once. Colours and descriptions live in the catalogue, GET /v1/labels; renaming a label with PATCH /v1/labels/{name} renames it everywhere.
Automatic labelling
Rules add or remove labels, and can move the person to a lead stage, by themselves:
keyword: an incoming message contains one (or all) of the words. A word also matches longer forms starting with it (hargafindsharganya); capitals and accents are ignored.first_message: the first message of a new chat.store_event: an order from your connected store (order_created,order_paid,order_shipped,abandoned_checkout).inactive: no message in the chat for N days (checked hourly).ai: the AI reads the conversation and decides whether your instruction fits. All AI rules are checked in one call, at most every 15 minutes per chat, and each check uses 1 AI reply of your plan.label_added: one of the labels inconfig.labelsis put on a chat, by hand, by another rule, the AI or the store. Tagging many contacts at once in the CRM does not start it.
curl -X POST "https://api.chatkomodo.com/v1/labels/rules" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Ready to buy",
"trigger": "ai",
"config": {
"instruction": "The customer clearly wants to buy or order soon"
},
"add_labels": [
"hot-lead"
],
"remove_labels": [
"cold"
],
"set_stage": "interested"
}'const res = await fetch('https://api.chatkomodo.com/v1/labels/rules', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.CHATKOMODO_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"name": "Ready to buy",
"trigger": "ai",
"config": {
"instruction": "The customer clearly wants to buy or order soon"
},
"add_labels": [
"hot-lead"
],
"remove_labels": [
"cold"
],
"set_stage": "interested"
}),
});
const data = await res.json();
if (!res.ok) throw new Error(`${data.code}: ${data.error}`);
console.log(data);import os
import requests
res = requests.post(
"https://api.chatkomodo.com/v1/labels/rules",
headers={
"Authorization": f"Bearer {os.environ['CHATKOMODO_API_KEY']}",
},
json={
"name": "Ready to buy",
"trigger": "ai",
"config": {
"instruction": "The customer clearly wants to buy or order soon",
},
"add_labels": [
"hot-lead",
],
"remove_labels": [
"cold",
],
"set_stage": "interested",
},
timeout=30,
)
res.raise_for_status()
print(res.json())<?php
require 'vendor/autoload.php';
$client = new GuzzleHttp\Client();
$res = $client->request('POST', 'https://api.chatkomodo.com/v1/labels/rules', [
'headers' => [
'Authorization' => 'Bearer ' . getenv('CHATKOMODO_API_KEY'),
],
'json' => [
'name' => 'Ready to buy',
'trigger' => 'ai',
'config' => [
'instruction' => 'The customer clearly wants to buy or order soon',
],
'add_labels' => [
'hot-lead',
],
'remove_labels' => [
'cold',
],
'set_stage' => 'interested',
],
]);
print_r(json_decode((string) $res->getBody(), true));package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{
"name": "Ready to buy",
"trigger": "ai",
"config": {
"instruction": "The customer clearly wants to buy or order soon"
},
"add_labels": [
"hot-lead"
],
"remove_labels": [
"cold"
],
"set_stage": "interested"
}`)
req, err := http.NewRequest("POST", "https://api.chatkomodo.com/v1/labels/rules", body)
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("CHATKOMODO_API_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
if res.StatusCode >= 400 {
panic(fmt.Sprintf("%d: %s", res.StatusCode, data))
}
fmt.Println(string(data))
}Actions: assign and follow up
A rule can also act. actions.assign gives the chat to a CS agent (agent_id: null picks the next agent in turn: online first, fewest open chats); the lead gets that owner when it has none and the agent gets a notification. actions.messages sends up to 5 messages, each delay_minutes after the rule applies (0 to 30 days), with personalisation such as {{first_name|there}}. With stop_on_reply (the default) the messages still waiting are cancelled as soon as the customer writes. Messages go out from the number the customer last wrote to and never to people who opted out; a delayed message that would land outside your sending hours (the send window of broadcasts) waits until they open. Actions run at most once per chat every once_days days (default 30).
curl -X POST "https://api.chatkomodo.com/v1/labels/rules" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Hot lead follow-up",
"trigger": "label_added",
"config": {
"labels": [
"hot-lead"
]
},
"set_stage": "interested",
"actions": {
"assign": {
"agent_id": null
},
"messages": [
{
"delay_minutes": 1440,
"text": "Hi {{first_name|there}}, can I help you complete your order?"
}
],
"stop_on_reply": true,
"once_days": 30
}
}'const res = await fetch('https://api.chatkomodo.com/v1/labels/rules', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.CHATKOMODO_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"name": "Hot lead follow-up",
"trigger": "label_added",
"config": {
"labels": [
"hot-lead"
]
},
"set_stage": "interested",
"actions": {
"assign": {
"agent_id": null
},
"messages": [
{
"delay_minutes": 1440,
"text": "Hi {{first_name|there}}, can I help you complete your order?"
}
],
"stop_on_reply": true,
"once_days": 30
}
}),
});
const data = await res.json();
if (!res.ok) throw new Error(`${data.code}: ${data.error}`);
console.log(data);import os
import requests
res = requests.post(
"https://api.chatkomodo.com/v1/labels/rules",
headers={
"Authorization": f"Bearer {os.environ['CHATKOMODO_API_KEY']}",
},
json={
"name": "Hot lead follow-up",
"trigger": "label_added",
"config": {
"labels": [
"hot-lead",
],
},
"set_stage": "interested",
"actions": {
"assign": {
"agent_id": None,
},
"messages": [
{
"delay_minutes": 1440,
"text": "Hi {{first_name|there}}, can I help you complete your order?",
},
],
"stop_on_reply": True,
"once_days": 30,
},
},
timeout=30,
)
res.raise_for_status()
print(res.json())<?php
require 'vendor/autoload.php';
$client = new GuzzleHttp\Client();
$res = $client->request('POST', 'https://api.chatkomodo.com/v1/labels/rules', [
'headers' => [
'Authorization' => 'Bearer ' . getenv('CHATKOMODO_API_KEY'),
],
'json' => [
'name' => 'Hot lead follow-up',
'trigger' => 'label_added',
'config' => [
'labels' => [
'hot-lead',
],
],
'set_stage' => 'interested',
'actions' => [
'assign' => [
'agent_id' => null,
],
'messages' => [
[
'delay_minutes' => 1440,
'text' => 'Hi {{first_name|there}}, can I help you complete your order?',
],
],
'stop_on_reply' => true,
'once_days' => 30,
],
],
]);
print_r(json_decode((string) $res->getBody(), true));package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{
"name": "Hot lead follow-up",
"trigger": "label_added",
"config": {
"labels": [
"hot-lead"
]
},
"set_stage": "interested",
"actions": {
"assign": {
"agent_id": null
},
"messages": [
{
"delay_minutes": 1440,
"text": "Hi {{first_name|there}}, can I help you complete your order?"
}
],
"stop_on_reply": true,
"once_days": 30
}
}`)
req, err := http.NewRequest("POST", "https://api.chatkomodo.com/v1/labels/rules", body)
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("CHATKOMODO_API_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
if res.StatusCode >= 400 {
panic(fmt.Sprintf("%d: %s", res.StatusCode, data))
}
fmt.Println(string(data))
}Rules work on chats with a person. People stay in control: a label someone removes by hand is never put back by a rule or the AI for that person (adding it by hand again lifts that), and every change is kept in the chat's history with its source (manual, rule, ai, store).
Leads board
Every person can be in one lead stage. The default stages are New, Contacted, Interested, Won and Lost; set your own (1–12) with PUT /v1/leads/stages, each open, won or lost. GET /v1/leads returns the board with each person's labels, deal value, owner, follow-up and latest message (filter with label, q, owner or due=1); move someone with PATCH /v1/leads/{contactId} or PUT /v1/sessions/{sid}/inbox/{chatId}/stage.
Deal value, owner, follow-ups and notes
PATCH /v1/leads/{contactId} also sets the deal_value (in the lead currency, PUT /v1/leads/settings), the agent who looks after the lead (owner_agent_id) and a follow-up (follow_up_at in milliseconds, follow_up_note). When a follow-up is due, the owner's devices get a notification (the business owner's when nobody owns the lead). Agents can take a lead nobody owns or let go of their own; only the business owner gives a lead to another agent. Notes for the team: POST /v1/leads/{contactId}/notes; GET /v1/leads/{contactId} returns the lead with its notes and history.
curl -X PATCH "https://api.chatkomodo.com/v1/leads/01JA6P2T5V8X0Z3B6D9F2H5K8M" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"stage": "interested",
"deal_value": 450,
"owner_agent_id": "01JA6Q0AGENT00000000000000",
"follow_up_at": 1767258000000,
"follow_up_note": "Send the quote"
}'const res = await fetch('https://api.chatkomodo.com/v1/leads/01JA6P2T5V8X0Z3B6D9F2H5K8M', {
method: 'PATCH',
headers: {
Authorization: `Bearer ${process.env.CHATKOMODO_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"stage": "interested",
"deal_value": 450,
"owner_agent_id": "01JA6Q0AGENT00000000000000",
"follow_up_at": 1767258000000,
"follow_up_note": "Send the quote"
}),
});
const data = await res.json();
if (!res.ok) throw new Error(`${data.code}: ${data.error}`);
console.log(data);import os
import requests
res = requests.patch(
"https://api.chatkomodo.com/v1/leads/01JA6P2T5V8X0Z3B6D9F2H5K8M",
headers={
"Authorization": f"Bearer {os.environ['CHATKOMODO_API_KEY']}",
},
json={
"stage": "interested",
"deal_value": 450,
"owner_agent_id": "01JA6Q0AGENT00000000000000",
"follow_up_at": 1767258000000,
"follow_up_note": "Send the quote",
},
timeout=30,
)
res.raise_for_status()
print(res.json())<?php
require 'vendor/autoload.php';
$client = new GuzzleHttp\Client();
$res = $client->request('PATCH', 'https://api.chatkomodo.com/v1/leads/01JA6P2T5V8X0Z3B6D9F2H5K8M', [
'headers' => [
'Authorization' => 'Bearer ' . getenv('CHATKOMODO_API_KEY'),
],
'json' => [
'stage' => 'interested',
'deal_value' => 450,
'owner_agent_id' => '01JA6Q0AGENT00000000000000',
'follow_up_at' => 1767258000000,
'follow_up_note' => 'Send the quote',
],
]);
print_r(json_decode((string) $res->getBody(), true));package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{
"stage": "interested",
"deal_value": 450,
"owner_agent_id": "01JA6Q0AGENT00000000000000",
"follow_up_at": 1767258000000,
"follow_up_note": "Send the quote"
}`)
req, err := http.NewRequest("PATCH", "https://api.chatkomodo.com/v1/leads/01JA6P2T5V8X0Z3B6D9F2H5K8M", body)
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("CHATKOMODO_API_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
if res.StatusCode >= 400 {
panic(fmt.Sprintf("%d: %s", res.StatusCode, data))
}
fmt.Println(string(data))
}Broadcast by stage, owner or value
CRM segments can filter on the leads board: stage (a stage id; empty = not on the board), owner (an agent id), deal_value (in the lead currency) and follow_up (within_days = due within N days, overdue included). A broadcast to such a segment reaches, for example, everyone who is Interested but has not bought yet.
curl -X POST "https://api.chatkomodo.com/v1/crm/segments" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Interested, worth over 1 million",
"filter": {
"match": "all",
"rules": [
{
"field": "stage",
"op": "is",
"value": "interested"
},
{
"field": "deal_value",
"op": "gte",
"value": 1000000
}
]
}
}'const res = await fetch('https://api.chatkomodo.com/v1/crm/segments', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.CHATKOMODO_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"name": "Interested, worth over 1 million",
"filter": {
"match": "all",
"rules": [
{
"field": "stage",
"op": "is",
"value": "interested"
},
{
"field": "deal_value",
"op": "gte",
"value": 1000000
}
]
}
}),
});
const data = await res.json();
if (!res.ok) throw new Error(`${data.code}: ${data.error}`);
console.log(data);import os
import requests
res = requests.post(
"https://api.chatkomodo.com/v1/crm/segments",
headers={
"Authorization": f"Bearer {os.environ['CHATKOMODO_API_KEY']}",
},
json={
"name": "Interested, worth over 1 million",
"filter": {
"match": "all",
"rules": [
{
"field": "stage",
"op": "is",
"value": "interested",
},
{
"field": "deal_value",
"op": "gte",
"value": 1000000,
},
],
},
},
timeout=30,
)
res.raise_for_status()
print(res.json())<?php
require 'vendor/autoload.php';
$client = new GuzzleHttp\Client();
$res = $client->request('POST', 'https://api.chatkomodo.com/v1/crm/segments', [
'headers' => [
'Authorization' => 'Bearer ' . getenv('CHATKOMODO_API_KEY'),
],
'json' => [
'name' => 'Interested, worth over 1 million',
'filter' => [
'match' => 'all',
'rules' => [
[
'field' => 'stage',
'op' => 'is',
'value' => 'interested',
],
[
'field' => 'deal_value',
'op' => 'gte',
'value' => 1000000,
],
],
],
],
]);
print_r(json_decode((string) $res->getBody(), true));package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{
"name": "Interested, worth over 1 million",
"filter": {
"match": "all",
"rules": [
{
"field": "stage",
"op": "is",
"value": "interested"
},
{
"field": "deal_value",
"op": "gte",
"value": 1000000
}
]
}
}`)
req, err := http.NewRequest("POST", "https://api.chatkomodo.com/v1/crm/segments", body)
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("CHATKOMODO_API_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
if res.StatusCode >= 400 {
panic(fmt.Sprintf("%d: %s", res.StatusCode, data))
}
fmt.Println(string(data))
}Import and export
POST /v1/leads/import puts up to 2 000 people per call on the board (phone, name, stage by id or name, deal value, labels, owner by name, follow-up, a note); people are matched by number and nothing is sent to them. GET /v1/leads/export returns the board as a CSV with the same columns, so a file can go out and come back.
From ads and your website to the board
A click-to-WhatsApp link (POST /v1/links) opens a chat with your device with a ready message that ends in a short code, e.g. Hello, I'd like to know more. #K7Q2MX. When the visitor sends it, the chat is matched to the visit: the contact gets the attributes source (the link name) and utm_source / utm_medium / utm_campaign (first touch), the link's labels, and its lead stage if they are not on the board yet. Leads show it as source; filter the board with ?source=<link id>. The same link can power a chat button on your website (the widget settings and widget_snippet).
curl -X POST "https://api.chatkomodo.com/v1/links" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Instagram bio",
"session_id": "YOUR_DEVICE_ID",
"message": "Hello, I'\''d like to know more.",
"utm_source": "instagram",
"utm_medium": "social",
"labels": [
"instagram"
],
"stage": "new"
}'const res = await fetch('https://api.chatkomodo.com/v1/links', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.CHATKOMODO_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"name": "Instagram bio",
"session_id": "YOUR_DEVICE_ID",
"message": "Hello, I'd like to know more.",
"utm_source": "instagram",
"utm_medium": "social",
"labels": [
"instagram"
],
"stage": "new"
}),
});
const data = await res.json();
if (!res.ok) throw new Error(`${data.code}: ${data.error}`);
console.log(data);import os
import requests
res = requests.post(
"https://api.chatkomodo.com/v1/links",
headers={
"Authorization": f"Bearer {os.environ['CHATKOMODO_API_KEY']}",
},
json={
"name": "Instagram bio",
"session_id": "YOUR_DEVICE_ID",
"message": "Hello, I'd like to know more.",
"utm_source": "instagram",
"utm_medium": "social",
"labels": [
"instagram",
],
"stage": "new",
},
timeout=30,
)
res.raise_for_status()
print(res.json())<?php
require 'vendor/autoload.php';
$client = new GuzzleHttp\Client();
$res = $client->request('POST', 'https://api.chatkomodo.com/v1/links', [
'headers' => [
'Authorization' => 'Bearer ' . getenv('CHATKOMODO_API_KEY'),
],
'json' => [
'name' => 'Instagram bio',
'session_id' => 'YOUR_DEVICE_ID',
'message' => 'Hello, I\'d like to know more.',
'utm_source' => 'instagram',
'utm_medium' => 'social',
'labels' => [
'instagram',
],
'stage' => 'new',
],
]);
print_r(json_decode((string) $res->getBody(), true));package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{
"name": "Instagram bio",
"session_id": "YOUR_DEVICE_ID",
"message": "Hello, I'd like to know more.",
"utm_source": "instagram",
"utm_medium": "social",
"labels": [
"instagram"
],
"stage": "new"
}`)
req, err := http.NewRequest("POST", "https://api.chatkomodo.com/v1/links", body)
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("CHATKOMODO_API_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
if res.StatusCode >= 400 {
panic(fmt.Sprintf("%d: %s", res.StatusCode, data))
}
fmt.Println(string(data))
}Leads report
GET /v1/leads/report (days: 7, 30, 90 or 365) returns new leads, deals won and lost (people still in a won or lost stage), the win rate, how many new leads became a deal, the average days to win, value won and still open, how far new leads got through the stages, a daily series, the labels added by hand, rules, AI and store, the rules at work, and per agent their open leads, deals and overdue follow-ups.