Pipedrive CRM revisited - how to stop a scenario loop after 1st iteration?

Status
Not open for further replies.

Mark Phillips

Customer
Advanced Certified
Joined
Jan 28, 2019
Messages
154
Reaction score
53
Hi All
A few years ago I posted my original Pipedrive/3CX integration which I know at least a few people picked up and used (and updated to make compatible with changes to the Pipedrive API). I am now looking at it again and have come across the following scenario that I would like to deal with.

Scenario: I only want to do call journalling on contacts who are not labelled as SUPPLIER or SPAM in Pipedrive.. In other words, I only want to do call journalling for contacts who are customers (but I do not want to go through the laborious task of labelling every contact as a customer) - by default there is no label assigned.

In pipedrive each contact record can be assigned to one category label. When fetching the contact record as JSON, the label is returned as an ID integer. The list of category labels set up in Pipedrive is also available via a separate API call, and the JSON response contains an array with elements ID (integer) and label (string).

Now, I know that I could simply put some logic in the ReportCall "Skip If" to the effect of "SkipIf (Contact Label ID == X) || (Contact Label ID == Y)", where X is the ID of the SPAM label and Y is the ID of the SUPPLIER label. However, this requires me to delve into JSON responses to find what those IDs are (they are not visible in the pipedrive UI). This also means that if my clients add a third category label that they want to exclude (e.g. STAFF) then it would mean that the CRM template would need to be updated to take into account the third skipif case.

I have therefore been experimenting with the following chain of scenarios:
Parameter "IgnoreContactsWithLabels" defined with string = "SPAM, SUPPLIER"
ReportCall -> return customer record using EntityId from prior look up, chain to next scenario ReportCall1
ReportCall1 -> return list of category labels. Store ID and Label in variables LabelID, LabelDescription, chain to next scenario ReportCall2
ReportCall2 -> SkipIf method invocation: [[IgnoreContactsWithLabels].Contains([LabelDesc])] (this works as expected, skipping the labels SPAM and SUPPLIER), chain to next scenario

However this is where I get stuck. If there are say five category labels set up (e.g. COLD, WARM, HOT, SPAM, SUPPLIER), then the next scenario will run three times, once for COLD, once for WARM, once for HOT. I need a way of running the next scenario once and then stopping. In a normal programming environment I would set a boolean flag to indicate "done" and then exit the loop early. I cannot see a way of doing this within the framework of the CRM template.

Any ideas from anyone?

Thanks
Mark
 
You can't have it stop. But you shouldn't be doing that kind of loop in 3CX. It could easily crash the integration.

In your case, with specific things like that, you're better off using a proxy script that can handle all of that in code directly.
 
By "proxy script" - do you mean an intermediate layer between 3CX and Pipedrive, which would receive the raw data from the ReportCall scenario and then process it / update pipedrive accordingly?
 
By "proxy script" - do you mean an intermediate layer between 3CX and Pipedrive, which would receive the raw data from the ReportCall scenario and then process it / update pipedrive accordingly?
Yes, like a PHP script that can handle the API requests and have more control over how the data is handled. You can also have it use a cache to make it faster for recurrent calls with the same customers, for example.
 
  • Like
Reactions: Mark Phillips
Status
Not open for further replies.

Forum statistics

Threads
112,322
Messages
591,887
Members
165,470
Latest member
Robert Lee