Overview of developing add-ons for amoCRM using webHook and widgets

Content





  1. WebHook





  2. Widget





  3. Technical support





  4. Outcome





We did not use all the development possibilities for amoCRM, we limited ourselves to a private widget and webHook, so this is exactly what we will discuss below.





WebHook





For each account (on a trial only for 14 days), you can install a  webHook , the  documentation describes the process in detail . There is no need to develop any integrations.





In our case, there was enough information about  adding a deal .





url  (  index.php



)  POST json php:





//   POST    {   json
if(strlen($sRawPost) > 0 && $sRawPost[0] == "{")
{
    $sDecode = json_decode($sRawPost, true);
    if($sDecode !== null) 
        $_POST = $sDecode;
}
      
      



 get



  webHook



  ,  post



  :





{
    "leads": {
        "add": [
            {
                "id": 4564454,
                "name": " ",
                "status_id": 7534534,
                "price" => 0,
                "responsible_user_id": 453453453,
                "last_modified": 1612007407,
                "modified_user_id": 0,
                "created_user_id": 0,
                "date_create": 1612007407,
                "pipeline_id": 4546445,
                "tags": [
                    {
                        "id": 7899
                        "name": tilda
                    }
                ]
            }
        ],
        "account_id": 19277260
        "custom_fields": [
            {
                "id": 448797,
                "name": "name_field",
                "code": "code_field",
                "values": [
                    {
                        "value": "string"
                    }
                ]
            }
        ],
        "created_at": 1612007407,
        "updated_at": 1612007407
    },
    "account": [
        {
            "subdomain": "subdomain",
            "id": 19217260,
            "_links": [
                "self": "https://subdomain.amocrm.ru"
            ]
        }
    ]
}
      
      



     account



,  leads["add"][0]["account_id"] == account["id"]



.





 leads["add"][0]["tags"]



   , , - ,  tilda



.





 leads["add"][0]["custom_fields"]



 -   .





"" ,   ,    - -.





, "".





Editing deal fields

- API.





:





$aAdd = $_POST['leads']['add'][0];
 
//  
$aNameCustomFields = array_column($aAdd['custom_fields'], 'name');
 
//     
 
//  
$idOrder = $aAdd['custom_fields'][array_search('ORDERID', $aNameCustomFields)]['values'][0]['value'];
      
      



Adding a new deal field

webHook :)





Tilda, Tilda amoCRM. , amoCRM   , CRM





  , .  .





  , .





    .





 javascript,  twig, js  jquery,  css





 manifest.json



 - ,  ,    .   i18n



.





  ,  manifest.json







 WEB SDK  .





, ,    :)





 ajax  ( , ),  Access-Control-Allow-Origin: *



:





header("Access-Control-Allow-Origin: *");
      
      



, ,     .





,  manifest.json



     widget.version



, .





amoCRM CRM . CRM , 14 . ,  CRM,   . 14 . , , 10 . , -       .  ip amoCRMfrom which they send webHook to our server, those. support via online chat kindly provided them. At the time of this writing, the ip addresses of amoCRM servers are not in the public domain, you can find out information about them through the online chat on the site.





Outcome

In general, I liked the development for amoCRM, the clear and voluminous documentation with examples, but loading the widget brings certain inconveniences.





Author: Vitaly Buturlin








All Articles