Inserts a lead into a designated Campaign/Allocation ready to be dialed.
The timing of when the lead will be dialed depends on the normal lead prioritisation mechanism (priority, callback date, balance mode etc) however the lead won't be considered until the next dialer cache refresh occurs. Cache refreshes occur every two minutes, so on average, injected leads will take at least one minute before they will be considered for dialing.
The 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.
...
In 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.
Note: the rate limiting is across both the UpdateLeadFast and InsertLeadFast combined.
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 minutes1 minute). If your call to the InsertLeadFast endpoint times out then the lead will not be inserted and you will need to retry the insertion.
...
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 InsertLeadFast to fail so make certain your code can retry the action. If an insert fails then wait a couple of minutes before retrying (a manual import will cause a insertion failure).
Entry point:
Lead data must be POSTed and encoded as json.
Code Block | ||
---|---|---|
| ||
https://<server host>/servicemanager/rest/CampaignAPI/insertLeadsFast |
URL Parameters:
Parameter | Description | Required |
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 |
allowDuplicates | If true checking for duplicate phone numbers will NOT be performed . | No |
apiKey | api key provided by Noojee Support | Yes |
...
HTTP status of 500 is returned if our system throws an exception (our code is broken).
Code | Message | HTTP status | Description |
---|---|---|---|
0 | OK | 200 | The lead was successfully inserted or updated. |
101 | COULDNT_FIND_THE_LEAD | 400 | For an update, the njExternalLeadId didn't match a lead |
102 | NO_PHONE_FIELDS | 400 | For an import the lead doesn't have and phone numbers. |
103 | EXCEPTION |
500 | |||
104 | DNC | 400 | The lead's phone numbers are on the DNC list |
105 | DUPLICATE | 400 | There is already a lead with this phone number |
106 | INVALID_DISPOSTION | 400 | When updating, the supplied disposition doesn't exist. |
107 | DISPOSTION_ISNT_SET_AND_NOCHANGE_SPECIFIED | 400 | When updating a a lead the disposition can be omitted, and <NO CHANGE> specified. But this is an error condition if the lead doesn't already have a disposition. |
108 | IMPORT_BUT_NOCHANGE_SPECIFIED | 400 | Tried to insert a lead but a field contained the value '<NO CHANGE>' which is only valid for updates. |
109 | TIMEOUT_TOO_MANY_CONCURRENT_REQUESTS | 400 | There are too many concurrent insert/update API requests. Wait a bit and then retry the insert/update. Currently a call will timeout if it is delayed by more than 1 minute. |
110 | LEAD_NOT_UPDATED_DUE_TO_CONFLICT | 400 | The lead update caused a conflict with another update and failed. This usually means that a user was editing the lead whilst you were trying to update it via the api. This type of issues should be rare as in most cases the user will see the error not the api. When the user sees the error they will be given the opportunity to merge the two leads via a specialised merge lead screen. If the api recieves this error then you will need to manually intervene to ensure that data isn't over-written which a simply retry is likely to do. |