bitrix

How to add a Reminder for an Activity via Rest API in Bitrix24 CRM?


I'm working on a NodeJS integration to manage Leads. I'm currently able to create Leads and an Activity connected to the Lead using the endpoint /crm.activity.todo.add.json.

Now I need to notify the Responsible of the Activity to attend that activity, so I'm trying to create a reminder for that activity.

I can't find any way to achieve it in the Bitrix Docs. However, I notice that the Activity has a field NOTIFY_TYPE and NOTIFY_VALUE https://training.bitrix24.com/rest_help/crm/rest_activity/crm_activity_fields.php

I've also analyzed the web app to see if I could intercept the URLs it uses under the hood and I noticed that it uses this PHP page:

https://avify.bitrix24.es/bitrix/services/main/ajax.php?action=crm.activity.todo.updatePingOffsets

and sends this form data:

Action: crm.activity.todo.updatePingOffsets

Form data:
- ownerTypeId: 1 // lead type
- ownerId: 555 // lead id
- id: 1111 // task id
- value[0]: 30 // minutes

and it returned me a 400 error.

Any help is welcome


Solution

  • I've found a way to create a reminder for an activity via Rest API:

    const addReminderToActivity = async (
        activityId: number,
        itemId: number,
        itemType: ItemType
      ) => {
        const ownerTypeIds = {
          'LEAD': 1,
          'CONTACT': 3,
          'COMPANY': 4
        };
    
        const minutesBeforeDeadline = 15;
    
        return axios.post('/crm.activity.todo.updatePingOffsets.json', {
          ownerTypeId: ownerTypeIds[itemType],
          ownerId: itemId,
          id: activityId,
          value: [minutesBeforeDeadline]
        });
      };
    

    As @usersuper says, there is not an API method in the docs, but I found this endpoint by analyzing the web app requests, so it seems the method exists but it's not documented.

    This is a GitHub gist I made as reference: https://gist.github.com/ChemaCLi/9c3b18e8bf59026561f65338d72decc7

    It allows to: