AOMessageRouting - dwilkie/nuntium GitHub Wiki
== How an Application Originated message is routed to one or more channels ==
These are the steps ran when a message is being delivered by an application through Nuntium:
If the message is SMS:
# Save the [API](/dwilkie/nuntium/wiki/country) and [API](/dwilkie/nuntium/wiki/carrier) [Messages](/dwilkie/nuntium/wiki/message-attributes) to the [MobileNumbersTable](/dwilkie/nuntium/wiki/Mobile-Numbers-table).
# Run the [AttributeInference](/dwilkie/nuntium/wiki/attribute-inference), if "country" and/or "carrier" are still unknown.
Rules specified in the application that sent the message.
Run theChannels out the possible channels for delivering the message.
Channels the message through any of the resulting channels.
Rules specified in that resulting channel.
Run the== How to use Application AO rules route to a specific channel for AO Messages ==
Add an AO rules to your application by selecting 'Add Condition' and 'Add Action' in the application edit or new page.
The following example routes messages from the country code 855 (Cambodia) with the format 85510xxxxx or 85569xxxxx to the 'smart' channel, messages from the country code 1 (USA/Canada) or (44) UK to the 'twilio' channel and all others to the 'qst' channel.
|=Condition Field |=Condition Type |=Condition Value|=Action Field |=Action Value |=Stop |
|To | Regexp | sms://855(?:10~|69)\d+ | suggested_channel | smart | checked |
|To | Regexp | sms://(?:1~|44)\d+ | suggested_channel | twilio | checked |
|To | Regexp | sms://\d+ | suggested_channel | qst | checked |
Note that the stop means "stop executing rules after this one if this rules matches" so you in the example above you would need the check them all so prevent it falling through to qst everytime since this is the most general match. Also note that you need to add a new 'rule' for each case and //not// a new condition an ad action.