The SMS worker allows iCM to interact with an SMS provider, generating message content in iCM and passing it to the provider to be sent.
The SMS worker can integrate with a range of providers. The exact configuration of these providers will vary, and they must exist as JavaScript files in the API Server's SMS worker providers directory.
Worker Configuration Properties
Property | Type | Description |
---|---|---|
providers | Array, required | This is an array of the provider names that represents the providers that can be specified in the sendSMS function. Implementations must exist for all of the providers |
defaultProvider | String, required | This is the name of the provider that will be used if none is specified |
providersDir | String, required | This is the directory in which provider implementations can be found. Its default value is within the worker distribution and should not be changed |
The following optional properties can be set if you are using an End Point as a provider:
Property | Type | Description |
---|---|---|
EndPoint_ApiClientConfig | Object | If you are using the End Point provider you can provide an apiclient configuration object (to set an apiKey, serverid, user/password etc if needed) |
EndPoint_Name | String | If you are using the default End Point provider, this is the name of the End Point that will be called by it |
EndPoint_Worker | String | Either ajaxlibrary or serverlibrary, depending upon where your End Point is deployed |
EndPoints | Array | An array of End Point provider details. The properties set for each provider override those defined above |
EndPoints.Provider | String | The name of this provider that should be set in the sendSMS method call |
EndPoints.EndPoint_Name | String | The name of the End Point that will be invoked when this provider is used |
EndPoints.EndPoint_Worker | String | The worker this End Point is deployed to |
EndPoints.ApiClientConfig | Object | Any configuration to supply to the End Point |
Other providers may require additional configuration information, for example an API key, supplied as part of the worker configuration. These configuration settings should be named with the provider name as a prefix. For example, the Eagle Eye provider requires a username, password and sender:
"EagleEye_username": "xxxxxx",
"EagleEye_password": "xxxxxx",
"EagleEye_sender": "xxxxxx"
Example
{
"name": "sms",
"instances": 1,
"defaultProvider": "Example",
"providers": ["Example", "EndPoint"],
"EndPoint_Name": "Tests.smsHandler",
"EndPoint_Worker": "serverlibrary",
"EndPoint_ApiClientConfig": {},
"EndPoints": [{
"Provider": "o2",
"EndPoint_Name": "Tests.smsHandlerO2",
"EndPoint_Worker": "serverlibrary",
"EndPoint_ApiClientConfig": {}
}, {
"Provider": "ee",
"EndPoint_Name": "Tests.smsHandlerEE",
"EndPoint_Worker": "serverlibrary",
"EndPoint_ApiClientConfig": {}
}]
}
In the example above, if no provider is supplied with the call to
If the call to
To use the
API
The functions and responses of the SMS worker will vary between providers. By convention all support
sendSMS
The send SMS function is used to send message details to your chosen provider.
Parameter | Type | Description |
---|---|---|
provider | String, optional | The provider you would like to pass the message to. The defaultProvider will be used if none is specified |
destNumber | String, required | The number to send the SMS to |
message | String, required | The SMS message |
sender | String, optional | A sender identifier |
Example Request
In this example the default "Example" provider will be used.
let resp = this.callWorkerMethod( "sms", "sendSMS", {
"destNumber" : params.mobileNumber,
"message" : params.message
});
Example Responses
Responses will vary by provider. By convention the result object should contain the following.
Property | Type | Description |
---|---|---|
sent | Boolean | Whether or not the SMS was sent |
providerResp | Object | The actual response from the SMS provider |
error | String | If an error is returned from the provider the error text will be in this property |
The "Example" provider always returns
{
"jsonrpc": "2.0",
"id": 9,
"result": {
"sent": true,
"providerResp": {
"resp": "No message actually sent"
}
}
}
listProviders
Lists all currently configured providers and returns information about them.
let resp = this.callWorkerMethod("sms", "listProviders", {});
return resp;
Each provider implements an "information" function which provides the detail of the response.
{
"jsonrpc": "2.0",
"id": 11,
"result": [{
"name": "Example",
"description": "Example implementation.",
"restrictions": "Does not actually send a message.",
"chargeable": false,
"providerWebsite": ""
}]
}