User creation events (Solved)

Hello!

Can you guys explain to me why this works the way it works and is nothing like other webhooks in Pipedrive? I have a webhook enabled for object=user and actions=*. Now, it doesn’t matter if I create a completely new user, deactivate or activate existing one - webhook ALWAYS sends user.updated event. I wasn’t able to perform any action that would end in sending an event with a different action. And by looking at current and previous parts of incoming JSON, it is impossible to decide whether this user was just created or updated or whatever. That way I’m forced to put some extra logic on my side to perform this task.

Can you help me here anyway?

Hey @majk

Sorry for such a late reply. I missed this earlier.

I just tried testing with adding a user, and the beginning of the query string contained “"v":1,"action":"added","object":"user","id"” which I think should be enough to understand the action taken, but maybe you could explain more exactly where you’re looking?

Hi @David

I’m not sure what you did exactly, but I was able to reproduce this behaviour just a moment ago, three times in a row, each time using different external site to catch events (postb.in, webhook.site and requestcatcher.com). I did this to be sure there’s no problem with my AWS API Gateway that is normally catching those events.

My test case scenario is as simple as possible:

  1. go to settings -> webhooks -> create new webhook for *.user events and set endpoint url to each of those three sites
  2. got to settings -> manage users
  3. do some changes: add a new user, deactivate an old one, activate some other again etc.

Results are consistent - every time I receive an updated.user event, no matter what I do. And I’m using various combinations of user names and emails (fresh ones, old ones etc.). I can update you with screenshots too, if necessary. I’m using a sandbox account, this might be relevant (but this would be an odd behaviour, meaning that some backend things may work differently on different account types).

Side note: user id in response is sometimes a string and sometimes an integer. String when user was removed, otherwise it’s an integer.

Bump.

Can I get any response to this one? Or at least confirmation that this scenario will occur every time? I think my test is detailed enough to check what is happening on your end. You need to understand that it’s hard to build logic around something that’s unpredictable.

Hi @majk

I’m afraid you’ll need to supply me with your direct examples as I can’t replicate what you’re seeing.
When I test this, adding a User gives a very clear "event":"added.user"
For deactivating, you need to look at the first active_flag, if it is ‘false’, then the User was deactivated.

Hi @David,

I do not know what more can I provide. I can post full responses, but how I created webhooks and what I did with persons do achieve such results - I think it cannot be more clear than what I wrote above. Everything I did was simple clicking in Pipedrive, no API operations, nothing like that. I can run the process again, shall I make screenshots on every steps?
Only other thing that comes to my mind is that a normal account and a sandbox one work differently.

Can you message me an example of a payload from adding a User?

POST /test HTTP/1.1
Host: cc.requestcatcher.com
Connection: close
Accept: application/json, text/plain, /
Connection: close
Content-Length: 1200
Content-Type: application/json
User-Agent: Pipedrive Webhooks
X-Datadog-Parent-Id: 3577951053228794376
X-Datadog-Sampling-Priority: 1
X-Datadog-Trace-Id: 8270109296859987122

{“v”:1,“matches_filters”:null,“meta”:{“v”:1,“action”:“updated”,“object”:“user”,“id”:“8314418”,“company_id”:3606875,“user_id”:8314418,“host”:“app.pipedrive.com”,“timestamp”:1571834247,“timestamp_micro”:1571834247036030,“permitted_user_ids”:[5510054],“trans_pending”:false,“is_bulk_update”:false,“pipedrive_service_name”:false,“webhook_id”:“88423”},“current”:[{“id":8314418,“name”:“TestUser”,“default_currency”:“USD”,“locale”:“en_US”,“lang”:1,“email”:"michglo@gmail.com”,“phone”:null,“activated”:true,“created”:“2019-02-26 14:56:08”,“modified”:“2019-09-04 08:47:10”,“signup_flow_variation”:null,“has_created_company”:false,“is_admin”:0,“active_flag”:false,“timezone_name”:“Europe/Warsaw”,“timezone_offset”:"+01:00",“role_id”:1,“icon_url”:null,“is_you”:true}],“previous”:[{“id":8314418,“name”:“TestUser”,“default_currency”:“USD”,“locale”:“en_US”,“lang”:1,“email”:"michglo@gmail.com”,“phone”:null,“activated”:true,“created”:“2019-02-26 14:56:08”,“modified”:“2019-09-04 08:47:10”,“signup_flow_variation”:null,“has_created_company”:false,“is_admin”:0,“active_flag”:true,“timezone_name”:“Europe/Warsaw”,“timezone_offset”:"+01:00",“role_id”:1,“icon_url”:null,“is_you”:true}],“event”:“updated.user”,“retry”:0}

POST /test HTTP/1.1
Host: cc.requestcatcher.com
Connection: close
Accept: application/json, text/plain, /
Connection: close
Content-Length: 1282
Content-Type: application/json
User-Agent: Pipedrive Webhooks
X-Datadog-Parent-Id: 9138204208997056775
X-Datadog-Sampling-Priority: 1
X-Datadog-Trace-Id: 7340300150573852188

{“v”:1,“matches_filters”:null,“meta”:{“v”:1,“action”:“updated”,“object”:“user”,“id”:10982780,“company_id”:3606875,“user_id”:10982780,“host”:“app.pipedrive.com”,“timestamp”:1571834284,“timestamp_micro”:1571834284822512,“permitted_user_ids”:[5510054,10982780],“trans_pending”:false,“is_bulk_update”:false,“pipedrive_service_name”:false,“webhook_id”:“88423”},“current”:[{“id”:10982780,“name”:“Payload test user",“default_currency”:“USD”,“locale”:“en_US”,“lang”:1,“email”:"michal.glowaczewski+payload@crazycall.com”,“phone”:null,“activated”:true,“created”:“2019-10-23 12:37:58”,“modified”:“2019-10-23 12:38:03”,“signup_flow_variation”:null,“has_created_company”:false,“is_admin”:0,“active_flag”:true,“timezone_name”:“America/St_Kitts”,“timezone_offset”:"-04:00",“role_id”:1,“icon_url”:null,“is_you”:true}],“previous”:[{“id”:10982780,“name”:“Payload test user",“default_currency”:“USD”,“locale”:“en_US”,“lang”:1,“email”:"michal.glowaczewski+payload@crazycall.com”,“phone”:null,“activated”:true,“created”:“2019-10-23 12:37:58”,“modified”:“2019-10-23 12:37:58”,“signup_flow_variation”:null,“has_created_company”:false,“is_admin”:0,“active_flag”:true,“timezone_name”:“America/St_Kitts”,“timezone_offset”:"-04:00",“role_id”:1,“icon_url”:null,“is_you”:true}],“event”:“updated.user”,“retry”:0}

First one is from deactivating old user, second one from adding a new.

The first result is correct (“active_flag”.false) for a deactivated user, but the second you are positive is the payload from only Adding a User (I see you deactivated the 2nd User as well).

Using requestcatcher just now I receive:

Update: Issue only occurs with Sandbox Accounts. (Added User is shown as Updated Event in Webhook payload).