function telecoms.telecaptcha.create

This function can be used to interactively check whether the phone number a user has entered on a web form is not only a valid phone number, but also actually belongs to that user.

It does this by making a call to that number and interacting with the user.

There are two modes of operation; you may choose whichever you prefer:

Realtime webhooks can be sent to a URL you supply (optional in "say" mode, required in "read_dtmf" mode). This allows you to present realtime status information to the user if you wish, such as a message saying "Calling ...", and then "Ringing ..." etc to make this a truly interactive experience.

See also:

Arguments:

argrequired?syntaxinfo
ddiYTelNumthe phone number to be checked
custIDNposintthe customer account that will be charged for the test call (default is the account of the current API user)
cliYTelNumThe number the user will see as the calling number whilst making the test call to them
typeNenum:say|read_dtmfthe operating mode you want to use; default="say"
PINYunsintThe PIN the user must enter in order to validate their number; min length 1 digit, max length 10 digits
entry_attemptsNposintonly applicable to "read_dtmf" mode; how many attempts the user is given in order to correctly enter the PIN before the call is ended; min value=1, max value=10
refNstringa ref string that will be included in an extra field in the webhooks; max length 45 characters
callbackURLY (if type=read_dtmf)url.httpthe http or https URL of your endpoint where realtime webhooks will be sent detailing call events
callback_formatNenum:JSON|URLENCthe format that the realtime webhook data will be posted in (default JSON)
full_callback_dataNbooleanWhether to provide additional detail in realtime webhooks; 1=yes, 0=no. Default=0 (no)
secret_saltNstringif supplied, a salted checksum will be included in the realtime webhooks to help security

Further argument information

cli

When calling the user to verify their number, the number in the cli argument will be shown as the calling number. This must be a number on your account, and cannot be a premium rate number.

type

This argument determines which type of telecaptha to create.

When type is "say" (or not specified), then the user will be called and the PIN will be audibly read out to them over the phone. The user then has to enter this PIN into your web form. Your own web site code will then need to compare what the user entered with the PIN that it supplied in the PIN argument to telecoms.telecaptcha.create.

When type is "read_dtmf", then the user will be called and hear and audio prompt asking them to enter the PIN. The user should then use the telephone keypad to enter the PIN they were shown on your web form. Your web site code will need to analyse the webhooks in order to know whether the PIN has been entered successfully.

Telecaptcha "say" is simpler to implement as it doesn't require the use of webhooks unless you also want to show realtime call events to the user on screen. Telecaptcha "read_dtmf" cannot work without proper and timely processing of webhooks.

PIN

Your code should generate a random PIN between 1 and 10 digits and supply this in the PIN argument. The user must enter this PIN correctly.

callbackURL

This argument is optional with telecaptcha "say" but mandatory with telcaptcha "read_dtmf".

In this argument you should enter the URL to where you want realtime webhooks to be sent. These webhooks notify your site in real time as call events happen. See below for format and examples of call events.

callback_format

This argument is optional with telecaptcha "say" but mandatory with telcaptcha "read_dtmf".

In this argument you should enter the URL to where you want realtime webhooks to be sent. These webhooks notify your site in real time as call events happen. See below for format and examples of call events.

full_callback_data

By default, the webhooks contain minimal data - just enough for you to be able to provide realtime feedback if required.

If you supply 1 in this argument, the webhooks will contain additional data about the call. See further down for webhook data format.

secret_salt

This is a security/validation option.

When you supply a secret salt here, the webhooks will include a chksum field which your scripts can double check in order to be sure that the callback came from us.

The checksum is calculated by doing an MD5 checksum of the string XXXYYYZZZ where XXX is the value in the uniqueID field, YYY is the value in the seq field and ZZZ is the value you supplied in the secret_salt argument.

For example, if uniqueID had the value 1234567890.12345_11, seq had the value 4 and the secret_salt you supplied was grassyfields then for that webhook the chksum field would contain the MD5 checksum of 1234567890.12345_114grassyfields, which is 5e4fe817db6e255de3d4ef13b2334492.

Return Values

There are no return values to the initial API call other than an indication of successful job submission, or any immediate errors (eg syntax errors in arguments). The result of a successful submission is as below:

All results of the telecaptcha call are returned in the webhook data. That being said, if you're just using telecaptcha "say" then you don't strictly need to monitor the webhooks at all - it may be sufficient to just see whether the user enters the correct PIN into the web form.

Having said the above, the webhooks are still required if you want to present the user with realtime information, which may be useful, especially if for example they entered a wrong number and it came back number unallocated, busy, etc. Or, if it went directly to voicemail the webhooks would show the call as answered; the user may realise what has happened and take steps to remedy that and try again.

Example 1

Use telecoms.telecaptcha.create to verify the number 01134960000 that the user has entered into the web form as their phone number.

Your system generates a random PIN (but doesn't show it to the user). It supplies this pin to telecoms.telecaptcha.create in "say" mode. The system will call the number that the user supplied and read out that PIN to them. The user should then enter that PIN into the web form.

You have requested realtime webhooks to be sent to https://mysite.example.com/signup/callback?64bfe45adfc4305a49d7a44d8e9c0. The user will see the call coming from 01632968765.

JSON example request:

POST https://live.apicontrol.co.uk/1/json
{
    "auth" : {
        "username" : "YOURUSERNAME",
        "password" : "YOURPASSWORD",
    },
   "func" : "telecoms.telecaptcha.create",
   "args" : {
      "ddi" : "01134960000",
      "PIN" : 50834,
      "callbackURL" : "https://mysite.example.com/signup/callback?64bfe45adfc4305a49d7a44d8e9c0",
      "callback_format" : "JSON",
      "cli" : "01632968765",
      "type" : "say"
    }
}

JSON example response:

{
   "results" : {},
   "success" : 1
}
Note that the immediate API response (above) just indicates a successful job submission.

Webhooks generated:

{"uniqueID":"1690300253.3721099_12", "seq":1, "status.tech":"init", "status.eng":"Preparing"}

{"uniqueID":"1690300253.3721099_12", "seq":2, "status.tech":"dial.01134960000", "status.eng":"Calling 01134960000"}

{"uniqueID":"1690300253.3721099_12", "seq":3, "status.tech":"ringing", "status.eng":"Ringing"}

{"uniqueID":"1690300253.3721099_12", "seq":4, "status.tech":"progress", "status.eng":"Ringing"}

{"uniqueID":"1690300253.3721099_12", "seq":5, "status.tech":"answered", "status.eng":"Answered"}

{"uniqueID":"1690300253.3721099_12", "seq":6, "status.tech":"end.OK", "status.eng":"Call ended"}

This call generated 6 seperate webhooks, which were sent in real-time as call events happened.

Each webhook contains the following fields:

Example 2

The same as Example 1, except that this is done in read_dtmf mode. This means that the caller will be played a voice prompt asking them to enter their PIN. The user should then entier their PIN on the telephone keypad.

JSON example request:

POST https://live.apicontrol.co.uk/1/json
{
    "auth" : {
        "username" : "YOURUSERNAME",
        "password" : "YOURPASSWORD",
    },
   "func" : "telecoms.telecaptcha.create",
   "args" : {
      "ddi" : "01134960000",
      "PIN" : 114075,
      "callbackURL" : "https://mysite.example.com/signup/callback?64bfe45adfc4305a49d7a44d8e9c0",
      "callback_format" : "JSON",
      "cli" : "01632968765",
      "type" : "read_dtmf",
      "entry_attempts":3
    }
}

JSON example response:

{
   "results" : {},
   "success" : 1
}
Note that the immediate API response (above) just indicates a successful job submission.

Webhooks generated:

{"uniqueID":"1690551123.3494066_16","seq":1,"status.tech":"init","status.eng":"Preparing"}

{"uniqueID":"1690551123.3494066_16","seq":2,"status.tech":"dial.01134960000","status.eng":"Calling 01134960000"}

{"uniqueID":"1690551123.3494066_16","seq":3,"status.tech":"ringing","status.eng":"Ringing"}

{"uniqueID":"1690551123.3494066_16","seq":4,"status.tech":"progress","status.eng":"Ringing"}

{"uniqueID":"1690551123.3494066_16","seq":5,"status.tech":"answered","status.eng":"Answered"}

{"uniqueID":"1690551123.3494066_16","seq":6,"status.tech":"input.wait","status.eng":"Waiting for input"}

{"uniqueID":"1690551123.3494066_16","seq":7,"status.tech":"input.1","status.eng":"Received digits 1"}

{"uniqueID":"1690551123.3494066_16","seq":8,"status.tech":"input.11","status.eng":"Received digits 11"}

{"uniqueID":"1690551123.3494066_16","seq":9,"status.tech":"input.114","status.eng":"Received digits 114"}

{"uniqueID":"1690551123.3494066_16","seq":10,"status.tech":"input.1140","status.eng":"Received digits 1140"}

{"uniqueID":"1690551123.3494066_16","seq":11,"status.tech":"input.11407","status.eng":"Received digits 11407"}

{"uniqueID":"1690551123.3494066_16","seq":12,"status.tech":"input.114075.ok","PINverified":1,"status.eng":"Received digits 114075 - PIN verified"}

{"uniqueID":"1690551123.3494066_16","seq":13,"status.tech":"end.OK","status.eng":"PIN verified successfully; call ended","PINverified":1}

In the above webhooks, you can see that at

Example 3

The same as Example 2, except this time the user kept entering the wrong PIN.

JSON example request:

POST https://live.apicontrol.co.uk/1/json
{
    "auth" : {
        "username" : "YOURUSERNAME",
        "password" : "YOURPASSWORD",
    },
   "func" : "telecoms.telecaptcha.create",
   "args" : {
      "ddi" : "01134960000",
      "PIN" : 114075,
      "callbackURL" : "https://mysite.example.com/signup/callback?64bfe45adfc4305a49d7a44d8e9c0",
      "callback_format" : "JSON",
      "cli" : "01632968765",
      "type" : "read_dtmf",
      "entry_attempts":3
    }
}

JSON example response:

{
   "results" : {},
   "success" : 1
}
Note that the immediate API response (above) just indicates a successful job submission.

Webhooks generated:

{"uniqueID":"1690551761.3755608_15","seq":1,"status.tech":"init","status.eng":"Preparing"}

{"uniqueID":"1690551761.3755608_15","seq":2,"status.tech":"dial.01974272014","status.eng":"Calling 01974272014"}

{"uniqueID":"1690551761.3755608_15","seq":3,"status.tech":"progress","status.eng":"Ringing"}

{"uniqueID":"1690551761.3755608_15","seq":4,"status.tech":"ringing","status.eng":"Ringing"}

{"uniqueID":"1690551761.3755608_15","seq":5,"status.tech":"answered","status.eng":"Answered"}

{"uniqueID":"1690551761.3755608_15","seq":6,"status.tech":"input.wait","status.eng":"Waiting for input"}

{"uniqueID":"1690551761.3755608_15","seq":7,"status.tech":"input.1","status.eng":"Received digits 1"}

{"uniqueID":"1690551761.3755608_15","seq":8,"status.tech":"input.12","status.eng":"Received digits 12"}

{"uniqueID":"1690551761.3755608_15","seq":9,"status.tech":"input.123","status.eng":"Received digits 123"}

{"uniqueID":"1690551761.3755608_15","seq":10,"status.tech":"input.1234","status.eng":"Received digits 1234"}

{"uniqueID":"1690551761.3755608_15","seq":11,"status.tech":"input.12345","status.eng":"Received digits 12345"}

{"uniqueID":"1690551761.3755608_15","seq":12,"status.tech":"input.123456.wrongPIN.retries=2","status.eng":"Received digits 123456 - PIN incorrect; please try again"}

{"uniqueID":"1690551761.3755608_15","seq":13,"status.tech":"input.wait","status.eng":"Waiting for input"}

{"uniqueID":"1690551761.3755608_15","seq":14,"status.tech":"input.4","status.eng":"Received digits 4"}

{"uniqueID":"1690551761.3755608_15","seq":15,"status.tech":"input.45","status.eng":"Received digits 45"}

{"uniqueID":"1690551761.3755608_15","seq":16,"status.tech":"input.456","status.eng":"Received digits 456"}

{"uniqueID":"1690551761.3755608_15","seq":17,"status.tech":"input.4567","status.eng":"Received digits 4567"}

{"uniqueID":"1690551761.3755608_15","seq":18,"status.tech":"input.45678","status.eng":"Received digits 45678"}

{"uniqueID":"1690551761.3755608_15","seq":19,"status.tech":"input.456789.wrongPIN.retries=1","status.eng":"Received digits 456789 - PIN incorrect; please try again"}

{"uniqueID":"1690551761.3755608_15","seq":20,"status.tech":"input.wait","status.eng":"Waiting for input"}

{"uniqueID":"1690551761.3755608_15","seq":21,"status.tech":"input.4","status.eng":"Received digits 4"}

{"uniqueID":"1690551761.3755608_15","seq":22,"status.tech":"input.45","status.eng":"Received digits 45"}

{"uniqueID":"1690551761.3755608_15","seq":23,"status.tech":"input.456","status.eng":"Received digits 456"}

{"uniqueID":"1690551761.3755608_15","seq":24,"status.tech":"input.4561","status.eng":"Received digits 4561"}

{"uniqueID":"1690551761.3755608_15","seq":25,"status.tech":"input.45612","status.eng":"Received digits 45612"}

{"uniqueID":"1690551761.3755608_15","seq":26,"status.tech":"input.456123.wrongPIN","status.eng":"Received digits 456123 - PIN incorrect"}

{"uniqueID":"1690551761.3755608_15","seq":27,"status.tech":"end.fail.user.wrongPIN","status.eng":"Verification failure; call ended","PINverified":0}

In the above webhooks, you can see that at

Example 4

The same as Example 2, except this time the user failed to enter anything the first two times, then only entered 2 digits before everything timed out.

JSON example request:

POST https://live.apicontrol.co.uk/1/json
{
    "auth" : {
        "username" : "YOURUSERNAME",
        "password" : "YOURPASSWORD",
    },
   "func" : "telecoms.telecaptcha.create",
   "args" : {
      "ddi" : "01134960000",
      "PIN" : 114075,
      "callbackURL" : "https://mysite.example.com/signup/callback?64bfe45adfc4305a49d7a44d8e9c0",
      "callback_format" : "JSON",
      "cli" : "01632968765",
      "type" : "read_dtmf",
      "entry_attempts":3
    }
}

JSON example response:

{
   "results" : {},
   "success" : 1
}
Note that the immediate API response (above) just indicates a successful job submission.

Webhooks generated:

{"uniqueID":"1690552947.3785005_13","seq":1,"status.tech":"init","status.eng":"Preparing"}

{"uniqueID":"1690552947.3785005_13","seq":2,"status.tech":"dial.01974272014","status.eng":"Calling 01974272014"}

{"uniqueID":"1690552947.3785005_13","seq":3,"status.tech":"progress","status.eng":"Ringing"}

{"uniqueID":"1690552947.3785005_13","seq":4,"status.tech":"ringing","status.eng":"Ringing"}

{"uniqueID":"1690552947.3785005_13","seq":5,"status.tech":"answered","status.eng":"Answered"}

{"uniqueID":"1690552947.3785005_13","seq":6,"status.tech":"input.wait","status.eng":"Waiting for input"}

{"uniqueID":"1690552947.3785005_13","seq":7,"status.tech":"input.none.timeout.retries=2","status.eng":"No digits received (input timeout); please try again"}

{"uniqueID":"1690552947.3785005_13","seq":8,"status.tech":"input.wait","status.eng":"Waiting for input"}

{"uniqueID":"1690552947.3785005_13","seq":9,"status.tech":"input.none.timeout.retries=1","status.eng":"No digits received (input timeout); please try again"}

{"uniqueID":"1690552947.3785005_13","seq":10,"status.tech":"input.wait","status.eng":"Waiting for input"}

{"uniqueID":"1690552947.3785005_13","seq":11,"status.tech":"input.1","status.eng":"Received digits 1"}

{"uniqueID":"1690552947.3785005_13","seq":12,"status.tech":"input.12","status.eng":"Received digits 12"}

{"uniqueID":"1690552947.3785005_13","seq":13,"status.tech":"input.12.timeout","status.eng":"Received digits 12 - PIN incorrect (input timeout)"}

{"uniqueID":"1690552947.3785005_13","seq":14,"status.tech":"end.fail.user.timeout","status.eng":"Verification failure; call ended","PINverified":0}

In the above webhooks, you can see that at

Example 5

On this occasion, the number being tested is busy.

JSON example request:

POST https://live.apicontrol.co.uk/1/json
{
    "auth" : {
        "username" : "YOURUSERNAME",
        "password" : "YOURPASSWORD",
    },
   "func" : "telecoms.telecaptcha.create",
   "args" : {
      "ddi" : "01134960000",
      "PIN" : 50834,
      "callbackURL" : "https://mysite.example.com/signup/callback?64bfe45adfc4305a49d7a44d8e9c0",
      "callback_format" : "JSON",
      "cli" : "01632968765",
      "type" : "say"
    }
}

JSON example response:

{
   "results" : {},
   "success" : 1
}
Note that the immediate API response (above) just indicates a successful job submission.

Webhooks generated:

{"uniqueID":"1690554436.2534496_17","seq":1,"status.tech":"init","status.eng":"Preparing"}

{"uniqueID":"1690554436.2534496_17","seq":2,"status.tech":"dial.01134960000","status.eng":"Calling 01134960000"}

{"uniqueID":"1690554436.2534496_17","seq":3,"status.tech":"end.fail.tel.busy.17","status.eng":"Call failed: line engaged","PINverified":0}

The last webhook tells you that the call failed because the line was busy. You can tell this by status.tech having the value of end.fail.tel.busy.17, which means that:

Example 6

Here, the user had entered a number that is in a number range that is not in use. There are no webhooks generated here because no actual call was made.

JSON example request:

POST https://live.apicontrol.co.uk/1/json
{
    "auth" : {
        "username" : "YOURUSERNAME",
        "password" : "YOURPASSWORD",
    },
   "func" : "telecoms.telecaptcha.create",
   "args" : {
      "ddi" : "02920180239",
      "PIN" : 50834,
      "callbackURL" : "https://mysite.example.com/signup/callback?64bfe45adfc4305a49d7a44d8e9c0",
      "callback_format" : "JSON",
      "cli" : "01632968765",
      "type" : "say"
    }
}

JSON example response:

{
   "success" : 0,
   "error" : "number non-valid",
   "errordiags" : {
      "arg" : "number",
      "badval" : "01134960000",
      "errclass" : "syntax",
      "errtype" : "perm",
      "info" : "number not in use",
      "syntax" : "TelNumExt(complete)"
   },
   "errornum" : "5.1.3",
   "results" : {}
}

webhook status.tech values

In webhooks, status.tech can have these possible values:

These additional values can appear in webhooks when using read_dtmf mode: