Automatic chat summarization in Kommo is built on three API calls: retrieve conversation history via GET amojo.kommo.com/v2/origin/custom/{scope_id}/chats/{conversation_id}/history, summarize via POST api.openai.com/v1/chat/completions with the gpt-4o-mini model, and write the result via POST /api/v4/leads/notes. A rep opens the deal card before a call and sees structured context - without scrolling through 60 messages.
Off-the-shelf widgets for this do not exist: Kommo Chats API operates on a separate domain with HMAC-SHA1 authentication that has nothing in common with the standard OAuth token. No-code connectors like Zapier or Make do not support this API layer. The implementation requires a custom microservice.
In Exceltic.dev projects we consistently see the same pattern: reps spend 15-20 minutes reviewing chat history before each call. At 8 calls per day that is 2-2.5 hours daily - time spent reading chats rather than selling. The problem doubles when a deal is transferred between reps: the receiving rep spends another 30-40 minutes getting up to speed. This article shows how to solve this architecturally - with concrete endpoints, code samples, and real numbers.
What Gets Built
Auto-summary of chat history - structured text generated by a language model from the conversation history and written into a note and a custom field on the Kommo deal card.
The integration solves a specific problem: the rep does not read the chat thread before a call. Instead they see a ready-made summary - who the client is, what was discussed, what objections came up, the agreed next step.
Trigger: webhook or cron
Two working trigger options:
- Webhook on chat close - Kommo sends an event when a dialog is closed. The response is instant; the summary appears immediately. Works well when reps explicitly close dialogs.
- Cron every N hours - the service checks active deals on a schedule and updates summaries automatically. Works for most teams where chats are not closed explicitly.
Kommo Chats API: fetching history
Chat history endpoint:
GET https://amojo.kommo.com/v2/origin/custom/{scope_id}/chats/{conversation_id}/history?limit=50&offset=0
scope_id - an identifier that combines channel ID and account ID (format: {channel_id}_{account_id}). Issued when the channel is connected. conversation_id - the ID of the specific dialog, available from a webhook event or from the contact card.
Important: authentication here is fundamentally different from the main REST API. Every request must be signed with HMAC-SHA1 via the X-Signature header. The standard Kommo OAuth Bearer token does not work here. The signature is built from the HTTP method, the values of the Date/Content-MD5/Content-type headers and the request path, then signed with the channel secret.
Before sending to OpenAI, messages are formatted into a text block:
def format_messages(messages):
lines = []
for msg in messages:
from datetime import datetime
ts = datetime.fromtimestamp(msg["timestamp"]).strftime("%d.%m %H:%M")
sender = msg.get("sender", {}).get("name", "unknown")
text = msg.get("text", "[media]")
lines.append(f"{ts} [{sender}]: {text}")
return "\n".join(lines)
OpenAI: model, prompt, cost
Model: gpt-4o-mini. Pricing as of 2026: $0.15 per 1 million input tokens and $0.60 per 1 million output tokens. A 50-message conversation (~2,500 tokens) costs $0.0004-0.001 - less than one tenth of a cent.
System prompt for structured output:
You are a CRM assistant. Summarize the following sales conversation in Russian.
Output format (strict):
- Client context: who the client is, their need (1-2 sentences)
- Key facts: budget, timeline, decision maker, objections (bullets)
- Open questions: what was promised or needs follow-up
- Sentiment: positive / neutral / negative
Be concise. Max 150 words total.
API call:
import openai
response = openai.chat.completions.create(
model="gpt-4o-mini",
messages=[
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": formatted_chat}
],
max_tokens=300,
temperature=0.3
)
summary = response.choices[0].message.content
temperature=0.3 reduces variability - the summary becomes predictable in structure.
Writing the result back to Kommo
The result is written via two paths simultaneously:
Deal note - via the standard Kommo REST API:
payload = [
{
"entity_id": lead_id,
"note_type": "common",
"params": {
"text": f"AI summary ({datetime.now().strftime('%d.%m.%Y %H:%M')}):\n\n{summary}"
}
}
]
requests.post(
f"https://{subdomain}.kommo.com/api/v4/leads/notes",
headers={"Authorization": f"Bearer {access_token}"},
json=payload
)
Custom deal field - convenient for quick viewing without opening the notes feed:
requests.patch(
f"https://{subdomain}.kommo.com/api/v4/leads/{lead_id}",
headers={"Authorization": f"Bearer {access_token}"},
json={
"custom_fields_values": [
{"field_id": AI_SUMMARY_FIELD_ID, "values": [{"value": summary}]}
]
}
)
A textarea field is created once in Kommo settings. Place it at the top of the card template - the rep sees it immediately when the deal opens.
Cost, idempotency, privacy
Cost. With 100 active deals updated twice a day - roughly $5-10 per month for the entire account. Far less than one hour of a rep’s time.
Idempotency. The service stores a hash of the last processed msgid for each lead_id + conversation_id pair. If no new messages have appeared, the OpenAI call is skipped. No duplicate notes are created.
Privacy. Chat text is sent to the OpenAI API. Per OpenAI policy, data from API requests is not used to train models. For EU teams with strict data-localization requirements, the alternative is a self-hosted LLM (Llama 3 or Mistral via Ollama). The Chat Completions API interface is compatible - swapping the model in code is a one-line change.
Step-by-Step Blueprint
Step 1. Create a private integration in the Kommo developer panel. Obtain client_id and client_secret for OAuth, plus channel_id and channel_secret for the Chats API. These two credential sets exist independently.
Step 2. Set up OAuth 2.0 authorization: obtain access_token and refresh_token. The access token lives 24 hours - implement automatic refresh via the refresh token on every request to the main API.
Step 3. Retrieve the conversation_id for a deal. It is available via GET /api/v4/leads/{id}?with=chats - the response includes the linked chat. Alternatively, use the webhook payload from a new-message event.
Step 4. Fetch history via Chats API with HMAC-SHA1 signing. If there are more than 50 messages, paginate via offset. For very long conversations, take the last 40 messages plus the first 5 (preserving the initial context of the first contact).
Step 5. Format the messages, send to OpenAI. Write the result to a note (POST /api/v4/leads/notes) and to a custom field (PATCH /api/v4/leads/{id}).
Step 6. Log every run: lead_id, message count, OpenAI tokens, execution time. On a 403 from Chats API - check whether the channel secret has expired. On 429 from OpenAI - apply exponential backoff with a base of 2 seconds.
The full cycle takes 3-8 seconds. Infrastructure: one Docker container on Railway or a VPS, PostgreSQL or Redis for state storage.
Real Case with Numbers
A B2B company in Western Europe, 8 sales reps, approximately 120 active deals in Kommo. Primary channel: WhatsApp Business via Kommo Inbox. Average conversation per deal: 55-70 messages over the full sales cycle.
Before implementation. Time-tracking over a working week showed an average of 17 minutes spent preparing for a call on an active deal, and 30-40 minutes getting up to speed when a deal was transferred to another rep.
After implementation. Call preparation time: 2-3 minutes. The rep reads the structured block in the top field of the card. Savings across a team of 8: roughly 95-110 hours per month.
Implementation cost: 3-4 working days of development, a VPS at $12/month, OpenAI API at this volume - around $8-10 per month. The investment paid back within the first two weeks.
A side effect: when a rep is replaced, the incoming rep enters the first client call already prepared. Previously this was a point of friction - the client felt they were explaining things they had already said.
Who This Is Right For
The integration is optimal for B2B teams on Kommo where:
- 5+ reps are actively messaging through Kommo Inbox (WhatsApp, Telegram, Instagram)
- The average conversation is 20+ messages before the first call or meeting
- Deals are regularly transferred between reps
- The deal cycle is 2+ weeks (enough time for history to accumulate and become hard to reconstruct)
- The company operates across time zones: a rep picks up a dialog after an overnight gap
Not a fit if all communication happens via email outside Kommo, the team is 1-3 people, or deals close in 1-2 contacts.
If you use other AI integrations with Kommo - for example automatic lead qualification via OpenAI - the chat auto-summary slots into the same service layer without duplicating authorization logic. For teams with active messenger workflows, the article on Kommo and a Telegram bot in the funnel is also relevant.
Term: Chats API - a separate Kommo API layer on the amojo.kommo.com domain, designed for working with messenger chats. Uses HMAC-SHA1 authentication instead of the standard OAuth Bearer token.
Frequently Asked Questions
How does Kommo Chats API differ from the main REST API?
Kommo has two independent APIs. The main REST API ({subdomain}.kommo.com/api/v4/) works with deals, contacts, and notes and uses an OAuth 2.0 Bearer token. Chats API (amojo.kommo.com/v2/) is a separate service for messenger chats and messages with HMAC-SHA1 authentication: every request is signed with the channel secret, not the access token. This means two different authentication systems inside one microservice - they cannot be used interchangeably. This is exactly why Zapier and Make cannot work with chat history: their Kommo connector only supports the main REST API.
Can auto-summary be set up without development using Zapier or Make?
No. Kommo Chats API is not accessible through standard no-code connectors. Beyond authentication, there is also a data-size issue: Zapier has a 10 MB payload limit and does not handle offset-based pagination well for long conversations. The minimum option without full-stack development is a Python script on a cron in a cloud environment (Railway or Render, for example). That takes 1-2 developer days instead of 3-4 days for a full service.
How accurately does gpt-4o-mini summarize conversations in Russian?
For structured fact extraction from conversations, gpt-4o-mini delivers quality sufficient for practical use. The model handles Russian well and extracts names, amounts, dates, and objections reliably. Weak spots: mixed slang and abbreviations from specific industries (construction or healthcare, for example). In those cases, adding domain-specific terminology examples to the system prompt helps. For high-stakes deals, treat the summary as a supporting tool rather than a replacement for a full read when necessary.
What happens to conversation data in OpenAI?
Per OpenAI policy, data from API requests is not used to train models by default - this is documented in their Data Processing Agreement. Data is temporarily retained for up to 30 days for safety and logging purposes. If conversations contain personal data covered by GDPR, make sure your privacy policy covers processing by AI services. For maximum privacy - self-hosted LLM (Mistral 7B via Ollama): the interface is compatible with the OpenAI Chat Completions API and data never leaves your infrastructure.
Can the summary be stored in a custom field instead of a note?
Yes, and this is often more convenient for quick access. A textarea field at the top of the card template is visible immediately when the deal opens - no scrolling through the event feed. The downside: the field is overwritten on each update, so the history of summaries is not preserved. The optimal setup: notes for full history (each new summary becomes a new note) plus a custom field with the latest summary for quick access. The rep sees the current context at the top of the card and can view the change history in the feed when needed.
Summary
Auto-summarizing Kommo chat history via ChatGPT is a solved engineering problem with a predictable ROI.
Key implementation parameters:
- Stack: Kommo Chats API (
amojo.kommo.com) -> Python/Node.js -> OpenAIgpt-4o-mini-> Kommo Notes API + Custom Fields - Cost: $0.0004-0.001 per summary, $5-15/month at average volume
- Time saved: 90-120 minutes of working time per rep per day with 8+ reps
- Implementation time: 3-5 working days
- Two authentication systems in one service: HMAC-SHA1 for Chats API and OAuth Bearer for Notes API
Documentation: Kommo Chats API - chat history, OpenAI API pricing.
If your team is on Kommo with active chats and reps are spending time reviewing history before calls - describe the task to the Exceltic.dev team. We will work through the architecture for your stack: trigger type, conversation volume, data-privacy requirements, and the need for industry-specific custom processing.