Skip to content

SMS Parsers

A device forwards every bank SMS and push notification it receives. A parser turns one of those notifications into an amount, and Trader automatically confirms the operation that message belongs to.

Field Required Description
bank_id Yes bank the parser belongs to
sms_type Yes card, sbp, account, or link
currency Yes currency code, up to 3 characters
sim Yes exact notification source, e.g. com.vtb.mobile
from_pattern Yes regular expression for the sender or header
text_pattern Yes regular expression for the message body

from_pattern is the gate: a notification whose sender does not match it is not parsed at all, no matter what the body says. text_pattern has to match as well.

Matching is case-insensitive and works across multiple lines.

Values are pulled out of the expressions with named capture groups. amount is the one that has to be captured — without it the notification cannot be matched to an operation:

Зачисление (?<amount>[\d\s]+[.,]\d{2}) RUB

Groups from the sender and the body are combined, so the amount can be captured from either. Banks that put the amount in the header are handled entirely by from_pattern:

^Received\s+₹(?<amount>[\d.,]+)$

There are many other groups which narrow sms messages for transactions even more!

The amount group captures the amount in major units.

Both . and , are accepted as the decimal separator, and spaces are accepted as thousand separators, so 1 234.56 and 1 234,56 both parse to 1234.56. Capture the credited amount, never the balance printed alongside it.

The extracted amount is matched against unfinished operations on the same device. A notification whose amount is off by even 0.01 matches nothing and the operation stays open until it expires — which is why the amount randomizer keeps two open operations on one device from sharing an amount.

A parser can be checked against sample notifications before it is saved:

  • a positive test passes when every configured expression matches and the extracted groups equal the expected ones;
  • a negative test passes when the parser does not match the message.

Give each test the real from, text and sim of the notification you are targeting.