Create external integration on the AmoMarket page
- Go to the "AmoMarket" section.
- In the upper right corner, click "...".
- Select "Create Integration".
- Click on "External Integration".
- Select "Give access to: everyone."
- Fill in the "Title" and "Description" fields.
- Click "Save".
Generate a "Long-term key" for integration
- On the "AmoMarket" page, open the "Installed" tab.
- Find your integration and click on it.
- Go to the "Keys and Access" section.
- Click on the "Generate" button to create a long-term key.
- Save this key - you will need it when setting up the bot builder.
Get the source code from the bot builder
Go to the bot builder and follow these steps:
- Incoming webhook - a block for receiving data via a webhook.
- API - create a GET request to your AMOcrm:
https://{{your domain AMOcrm}}/api/v4/contacts.
In the page header parameters, the field is “Authorization” and the value is “Medium {{long-term key}}”. - Changing a Variable 1 - Set variable i to 0.
- Changing a Variable 2 - assign a value to the contact_type variable from the API request: {{...data._embedded.contacts[i].custom_fields_values[1].values[0].value}}.
If true, connect to the Pause block.
If false, connect to the Sending message 1 block. - Sending message 1 - send a message via ChatID using the result of the API request: {{...data._embedded.contacts[i].custom_fields_values[2].values[0].value}}.
- Pause - add a pause of 1 second.
- Condition 2 - check if i >= 200.
- If true, connect to the Sending message 2 block.
- If false, connect the Programmer to the block.
- Programmer - create a function: {{i}} + 1.
- Connect it to the Changing a Variable 2 block.
Make sure the script is configured correctly. An example script is available here:
Scenario.
Network up and deal financial in AMO
- Go to the "Transactions" section in AMO.
- In the top right corner, click “Customize Funnel.”
- Remove all unnecessary stages.
- Rename the remaining stages to “Start mailing” and “Carry out mailing”.
- At the "Start mailing" stage, add a "Webhook" trigger.
- In the "Specify URL" field, paste the link from the "Incoming webhook" block of the bot constructor.
- Add a "Status Change" trigger.
- Specify completion in 2 minutes and change to the “Distribution completed” stage.
- Save the funnel.
Now all that remains is to add a deal at the “Submission Completed” stage and wait for a message from the bot.