Apply patterns, custom indexes, filtering, and exclusions

This page provides examples of regular expression patterns and how they could be structured to create display lists.

Creating these regular expression patterns will be determined by the information available via your APIs and how they are structured.

The examples provided here are intended to provide guidance in creating meaningful ways of presenting information to your users via the use of Display List nodes and Dynamic List node.

Examples

{
    "products": [
        {
            "id": "1001",
            "desc": "Potatoes",
            "unitPrice": 100,
            "category": "veg"
        },
        {
            "id": "1002",
            "desc": "Melon",
            "unitPrice": 200,
            "category": "fruit"
        },
        {
            "id": "1003",
            "desc": "Grapes",
            "unitPrice": 300,
            "category": "fruit"
        },
        {
            "id": "1004",
            "desc": "Milk",
            "unitPrice": 400,
            "category": "dairy"
        }
    ]
}

Example session variables that will be used in the below explanations (produced for example as a result of an earlier API Integration node):

  • "[[EXAMPLE:products.1.id]]": "1001"

  • "[[EXAMPLE:products.1.desc]]": "Potatoes"

  • "[[EXAMPLE:products.1.unitPrice]]": 100

  • "[[EXAMPLE:products.1.category]]": "veg"

  • "[[EXAMPLE:products.2.id]]": "1002"

  • "[[EXAMPLE:products.2.desc]]": "Melon"

  • "[[EXAMPLE:products.2.unitPrice]]": 200

  • "[[EXAMPLE:products.2.category]]": "fruit"

  • "[[EXAMPLE:products.3.id]]": "1003"

  • "[[EXAMPLE:products.3.desc]]": "Grapes"

  • "[[EXAMPLE:products.3.unitPrice]]": 300

  • "[[EXAMPLE:products.3.category]]": "fruit"

  • "[[EXAMPLE:products.4.id]]": "1004"

  • "[[EXAMPLE:products.4.desc]]": "Milk"

  • "[[EXAMPLE:products.4.unitPrice]]": 400

  • "[[EXAMPLE:products.4.category]]": "dairy"

"Pattern" field

The Pattern field is used to match possible session variables that would be used to display to the user as a list. The pattern may contain the # character. If so, it is replaced with '1' and checked if it exists in the session store. If it exists, it is added to the list and it tries '2', etc. If it is not found then it is done and the list is returned.

For the above session variables, a "pattern" of "[EXAMPLE:products.#.desc] ([EXAMPLE:products.#.unitPrice] cents)" will (with a numbered list) return a list of

  1. Potatoes (100)

  2. Melon (200)

  3. Grapes (300)

  4. Milk (400)

For the above session variables, a "pattern" of "[EXAMPLE:products.#.desc]" will (with a numbered list and ". " seperator/indexPattern) return a list of

  1. Potatoes

  2. Melon

  3. Grapes

  4. Milk

"Custom Index" field

This is the separator field above and can also contain the "#" character to be replaced with the incrementing list counter. This field is not resolved (unlike with "pattern")

For the above session variables, a "pattern" of "[EXAMPLE:products.#.desc]" will (with a numbered list and "--#--" indexPattern) return a list of

--1-- Potatoes

--2-- Melon

--3-- Grapes

--4-- Milk

For the above session variables, a "pattern" of "[EXAMPLE:products.#.desc]" will (with a numbered list and "--->>" indexPattern) return a list of

--->> Potatoes

--->> Melon

--->> Grapes

--->> Milk

"Filter By" field

Optional map of key value pairs where:

  • key: contains the expected text to include if matched by the pattern (the value).

  • value: the pattern to evaluate (same as pattern fields above) to test against the key.

For the above session variables, a "pattern" of "[EXAMPLE:products.#.desc]", and with a Filter By map of

  • key: "fruit"

  • value: "[EXAMPLE:products.#.category]"

will (with a numbered list and ". " seperator/indexPattern) return a list of

  1. Melon

  2. Grapes

"Exclude" field

Optional map of key-value pairs where (same as "Filter By")

  • key: contains the expected text to exclude if matched by the pattern (the value).

  • value: the pattern to evaluate (same as pattern fields above) to test against the key.

For the above session variables, a "pattern" of "[EXAMPLE:products.#.desc]", and with an "Exclude" map of

  • key: "fruit"

  • value: "[EXAMPLE:products.#.category]"

will (with a numbered list and ". " seperator/indexPattern) return a list of

  1. Potatoes

  2. Milk

Logo

© Copyright 2024 Clickatell. All rights reserved.