Skip to main content Link Search Menu Expand Document (external link)

SMS Parser Tag

The SMS parser tag can be used to add a new SMS parsers to Jancy’s parser registry. SMS parsers can be used with 2FA resolvers that support them to give Jancy the ability to find and parse different SMS messages.

<jyl>
  <sms-parser name="google">
    <description>
      Parses codes from SMS messages sent by Google.
    </description>
    <example>
      G-928862 is your Google verification code.
    </example>
    <parse-message>
      let match = msg.match(/g-(\d+) is your google verification code./i)
      return match ? match[1] : null
    </parse-message>
  </sms-parser>
</jyl>

Format

SMS parsers start and end with an email-parser tag.

email-parser tag properties:

  • name required a unique name that identifies the parser.

Jancy will always prepend the word user- to user defined email parsers.

Parse Message Tag

The sms-parser tag must contain a parse-message tag. The contents of the parse-message tag will be used as the body of a Javascript function that will serve as both a filter and parser for the contents of SMS messages passed into it.

The function generated will be called with the following arguments:

The function generated by the content of the parse-message should either return a string which indicates the parser was successful otherwise it should return null.

Description Tag

The sms-parser tag can contain an optional description tag. The contents of the description tag should describe what types of messages the parser deals with.

Example Tag

The sms-parser tag can contain an optional example tag. The contents of the example tag should provide an example of the message the parser can deal with.

The primary purpose of the description and example tags is to provide information in the Jancy parser registry. The parser registry can be accessed in app by navigating to jancy://parsers.

image info

For a slightly more detailed information about the functions generate by the parse-message tag see the parserRegistry.registerParser method.