What the agent does in amoCRM
You can build a manager’s assistant in amoCRM yourself. It receives the data of a new deal, asks a model to assess the lead and leaves a note in the card: what the customer wants, what is missing for a quote, and the next step.
An API is the way a program reads and changes amoCRM data at an address like https://subdomain.amocrm.ru/api/v4/. A webhook works the other way round: amoCRM itself sends an event to the address of your server.
You need administrator rights in the account, since only the administrator creates integrations. You also need n8n on a server with a domain, so that amoCRM can reach the webhook, and a model. Ollama runs open models on your computer or server and comes under the MIT license.
Step 1: a private integration and a token
A private integration is a connection that works only in your account. It receives a token, the access key to the API.
1. Open the “amoMarket” section in your account and click “Create integration”.
2. Enter a name and a description, choose the permissions, fill in the Redirect URI and upload a logo. You can skip the hook for switching the integration off, since that field is optional.
3. Save the integration, open the “Keys” tab in its window and click “Generate token”. Choose an end date: the term runs from 1 day to 5 years.
4. Copy the token at once, since it is shown only once. A long-lived token needs no exchange or refresh, and you can revoke it with the “Revoke access” button on the “Issued access” tab.
The token goes in every request in the Authorization header, with the word Bearer and then the token. Keep it in the n8n credentials, not in the workflow text.
Step 2: a webhook for a new deal
1. In n8n, create a workflow with a “Webhook” node and choose POST in the “HTTP Method” field. In the “Respond” field choose “Immediately”: amoCRM waits no longer than 2 seconds for a reply, and a model thinks longer.
2. Publish the workflow and copy the node’s “Production URL”.
3. In amoCRM, in the “amoMarket” section, click “WEB HOOKS” in the top right corner, paste the address, tick the event for a new deal and click “Save”.
4. Create a test deal and open the “Executions” tab of the workflow in n8n. amoCRM sends data in the x-www-form-urlencoded format, with the id of the new deal among it.
If more than 100 failed replies pile up within 2 hours and the last one also fails, amoCRM switches the webhook off and notifies the administrators. You can switch it on again in the settings with the “Enable” button.
Step 3: the model writes a note
1. After the “Webhook” node, place “AI Agent”. In the “Prompt” parameter choose “Define below” and insert the deal data from the webhook into the “Prompt (User Message)” field.
2. In the node options, add a “System Message” that says how to assess a lead and in what form to write the conclusion: three lines, no promises to the customer.
3. Connect a model, for example the “Ollama Chat Model” node with an open model on your own server. The n8n documentation also requires at least one tool connected to the agent.
4. Add an “HTTP Request” node: a POST to https://subdomain.amocrm.ru/api/v4/leads/deal-number/notes with the Authorization header. In the JSON body, pass a list with one note: note_type set to common and params with a text field that holds the model’s answer.
5. Create another test deal and open its card: a text note from the integration should appear in it.
If the agent needs other events, webhooks also cover a deal change, a status change, a new contact and a new note. One account can have no more than 100 webhooks.
Customer data and rights
A deal holds the customer’s name, phone number and messages, and these are personal data. Under 152-FZ, Russia’s personal data law, they are collected and stored in databases in Russia. Since 1 March 2023, an operator notifies Roskomnadzor, the Russian regulator, before transferring them abroad.
Keep the model that reads deals on a server in Russia. The page on data security describes how we store customer data.
Choose the integration’s permissions for the task: an assistant that writes notes does not need to delete deals. If a token leaks, a one-month token does less harm than a 5-year one.
Working with webhooks through the API, not the interface, needs the “Advanced” or “Professional” plan.
When you need a developer
This assistant cannot answer customers in amoCRM chats. According to the chats API documentation, an integration works as a message transport from an outside chat system and sees only the chats it created itself. That is a separate development project.
We connect an agent that answers in messengers, creates deals, moves them through the pipeline and hands the conversation to a manager, as a turnkey project: a pilot in 14 days from $1,499 with a metric in the contract. Details are on the AI agent for amoCRM page.
n8n in this build runs under the Sustainable Use License (fair-code): you may install and change it for yourself, but not resell it as a cloud service. A similar build in another CRM has its own guide, and we wrote on the blog about how to choose a CRM for an agent.