Navigation: How to... >
Connector specific routing
The main routing procedure in Diafaan SMS Server is connector specific routing. For each connector you can choose if you want to use the available gateways to send and receive messages, send or receive only or not at all.
Each gateway can be designated as a primary gateway or as a backup gateway. Diafaan SMS Server will first try to send the message with one of the assigned primary gateways. If sending the message failed it will be repeated with a maximum of Max send Attempts for each primary gateway. If sending the message is still not successful on all primary gateways, the same procedure is used with the assigned backup gateway(s).
The Max. total primary send attempts can be used to limit the total amount of send attempts that are made with the primary gateways. For instance, if this value is set to 1 Diafaan SMS Server will only try to send the messages one time with one of the primary gateways. If the message fails it will switch to the backup gateways or mark the message as failed. The Max. total backup send attempts does the same for all the the backup gateways.
Use this gateway as a primary gateway
Use this gateway as a backup gateway
The gateway is not used for this connector
Use the gateway to send message only
Use the gateway to receive message only
Use the gateway to send and receive message
Message specific routing using the To Address, From address or Message Type
For each Gateway in the Connector Properties you can specify whether you want to use the Gateway for all messages or only for specific messages. Messages can be routed depending on the to address, from address or the message type of the message.
The routing filter can consist of one or more wildcards, separated by semicolons or comma's, or a regular expression match when the filter starts with the text "regex:". If the routing filter starts with a minus character (-), the message is routed through the gateway when the to address or message type does not match the filter.
Use this gateway for messages with numbers starting with 07 or +447:
Do not use this gateway for messages with numbers starting with 07 or +447:
Use this gateway for messages with British mobile numbers, using a regular expression:
Do not use this gateway for messages with British mobile numbers, using a regular expression:
Message specific routing using the Gateway field
With most connectors you can use the Gateway field to specify a gateway (list) for each message. The gateway list can be a single gateway name or multiple gateway names separated by semicolons. Only gateways that are enabled for sending in the connector specific routing options can be used, other gateway names are ignored.
By default, if a gateway is assigned as backup gateway in the connector specific routing options, it will still be used only as a backup gateway. But it is possible to change the primary and backup designation of the gateways with the '|' separator. The gateways before the '|' character become the primary gateways and the gateways after the '|' characters become the backup gateways. An optional value can be added after the gateway name to specify the maximum number of send attempts that is used for that gateway using a colon plus the maximum number of send attempts, e.g. Clickatell Gateway:2.
In the first example below you can use the GSM Modem on COM1 as a primary gateway and the Clickatell Gateway as the backup gateway by setting the Gateway field to GSM Modem on COM1;Clickatell Gateway:2. The gateway GSM Modem on COM10 is not used for this message.
In the second example the gateway field is set to Clickatell Gateway|GSM Modem on COM1;GSM Modem on COM10. The gateway Clickatell is used as a primary gateway and the gateways GSM Modem on COM10 and GSM Modem on COM10 will be used as backup gateways.
Using message specific routing in the Web Connector:
Change the primary/backup order of the message specific routing:
http://localhost:9710/http/send-message?to=%2B44xxx&message=Message&gateway=Clickatell+Gateway%7CGSM+Modem+on+COM1%3BGSM Modem on COM10
Message specific routing with the HTTP callback request
The message out HTTP callback request can return the gateway query field to specify a gateway (list) for each individual message. The gateway list can be a single gateway name or multiple gateway names separated by semicolons with an optional '|' character to designate the primary and backup gateways (see Message specific routing using the Gateway field).
Example HTTP callback response with a 'gateway' field:
Only available in Diafaan SMS Server - basic and full editions.
The most flexible way to route messages is with a gateway script. Depending on the destination address, message type or message text a different gateway (list) can be used to send the messages. It is also possible to change the destination address, message type and message text before it is sent.
In the gateway skeleton script the message is routed with the PostDispatchMessage method.
private void PostDispatchMessage(
The gateway name list is set in the gateway and backupGateway parameters. An optional value can be added after the gateway name to specify the maximum number of send attempts that is used for that gateway, GSM Modem on COM10:4 for a maximum of 4 send attempts. E.g.:
private void OnMessageToSend(string recordId, string toAddress, string fromAddress,
string message, string messageType)
"Dispatched: " + message,
"GSM Modem on COM1;Clickatell Gateway",
"GSM Modem on COM10:4");
See for a routing example the Dispatch SMS to gateway script.