Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Insert multiple leads into Noojee Campaigner. Lead data is to be POSTed and encoded as json.

The Insert Leads api method was introduced to over come performance problems on systems with large numbers of campaigns/leads.

Noojee recommends that you utiliise Insert Leads rather than the Insert Lead methodThe endpoint InsertLeadFast replaces the original InsertLead method. The new endpoint takes the same arguments but has enhanced error codes and as the name implies is faster than the original InsertLead endpoint.

Performance considerations

Injection of leads into Noojee Campaigner is a 'heavy weight' process (it can take a long time) as each lead needs to be de-duplicated and activated.

A number of the processes that run for each call to this Insert Lead api take the same amount of time no matter how many leads you inject.

As such its much better to inject a large no. of leads in a single call to InsertLeads rather than making multiple calls with small numbers of leads.

Concurrency

Only a single InsertLeads/InsertLead call can be run at a time (due to the need to de-duplicate leadsIn order to protect the core function of the PBX the end point is rate limited. The api allows multiple concurrent calls limited to (No. of hardware threads / 2) and each call we never complete in less than 100 ms. On larger databases the time required to complete each insert may increase further.

If you exceed the above rates the system will queue additional requests. This may result in your call to the endpoint timing out (currently timeout is 10 minutes). If your call to the InsertLeadFast endpoint times out then the lead will not be inserted and you will need to retry the insertion.

Queue insertions

As the end point is rate limited we strongly recommend that you queue the inserts within your system and include retry logic if the insert fails. This will deal with the above rate limiting logic as well as provide guaranteed delivery even if the Noojee PBX goes down for maintenance.

Concurrency

The no. of concurrent calls to insert lead is limited by the number of hardware threads your server runs. The limit is set to (No. of hardware threads / 2).

If someone is running a manual import then the InsertLead call will fail, so be prepared to do retries.

Retries

You must expect calls to InsertLeads to fail so make certain you your code and can retry the action. If an insert fails then wait a couple of minutes before retrying (a manual import will cause a insertion failure).

...

Code Block
linenumberstrue
https://<server host>/servicemanager/rest/CampaignAPI/insertLeadsinsertLeadsFast


Parameters:

ParameterDescriptionRequired
fTemplateId

Campaign Template id of the Template that the lead will be associated with.

See 16.0 Get Campaign Template List to obtain Template Id's

Yes
fCampaignId

Campaign id of the Campaign that the lead will be associated with.

See 17.0 Get Campaign List to obtain a list of campaign Id's.

Yes
fAllocationId

Allocation id of the Campaign that the lead will be associated with.

See 18.0 Get Allocation List to obtain a list of allocations.

Yes
allowDuplicatesIf true checking for duplicate phone numbers will NOT be performed .No
apiKeyapi key provided by Noojee SupportYes

...

ParameterDescriptionRequired
njExternalLeadIdA reference, account number or the like taken from the external data source. Also used to identify lead when updates are made.No
njCallBackDate

The date and time on which the lead is to be called. If not specified the lead is treated as a 'new' lead and will be called on a first come first served basis.

Format is "yyyy/MM/dd HH:mm"

No
njPriorityA priority between 0 and 100. The lower the number the higher the priority. Higher priority leads will be called before lower priority calls. Default priority is 10.No
njContactHoursSets the Contact Hours for the lead. If not passed the lead will default to the Campaign Templates default Contact Hours.No

Syntax

The format of the data posted is a json array containing one or more sets of name value pairs:

Code Block
[{"fieldname1": "lead 1 field 1 value", "fieldname2" , "lead 1field 2 value"}, {"fieldname1": "lead 2 field 1 value", "fieldname2" , "lead 2 field 2 value"}, {"fieldname1": "lead 3 field 1 value", "fieldname2" , "lead 3field 2 value"}]

Curl Sample query:

Code Block
linenumberstrue
curl -v -H "Accept: application/json" -H "Content-Type: application/json" -X POST 
-d '[{"Name":"Jane Smith","StreetAddress":"Suite 8/10 Hoddle St", "City": "Abbotsford", "State":"Vic", "PostCode":"3064", "FirstPhone":"0383218199"}
, {"Name":"John Smith","StreetAddress":"Suite 9/10 Main St", "City": "Yarravile", "State":"Vic", "PostCode":"3000", "FirstPhone":"0383218100"}]' 
'https://<server host>/servicemanager/rest/CampaignAPI/insertLeadsinsertLeadFast?fTemplateId=41&fCampaignId=41&fAllocationId=38&apiKey=f863246a-973e-11e6-8784-08002718f5b5&allowDuplicates=true'

...

Code Block
linenumberstrue
{"code":0,"message":"Imported 1 Updated 0 Rejected 0 leads.\n\nErrors (If any):\n Name,State,PostCode,FirstPhone,City,StreetAddress,Error Reason,\nOK"}