Welcome to the video tutorial on how to write a filter script for PageGate. Before you go through this video, you'll first want to determine what you want filtered and how you want to filter it. Is this an inbound filter or an outbound filter? Are you scanning reply messages for keywords or keyphrases? Are you monitoring a CAD system's input for special calls? Do you want to change the visible sender of the message based on what the message says?
What you want to do will directly determine the code you use in the script. Before we get in to how to write the script, I'd like to show you what a complete script looks like and also show you a portion of the documentation you'll want to keep for reference. In a web browser, go to www.notepage.net On the left hand side, click the Support section, then PageGate Support, then PageGate Manual/Documentation.
Click the link for PageGate Server Online Manual. On the left side of the documentation, expand 'How PageGate Accepts Messages' and 'Filter Pack' Expand, then click on 'Complete Script Examples'. There are a few examples in the list here and you'll definitely want to review them all for ideas on how to implement different scripts but the one we're interested in is Example 8. This is what a complete script looks like.
In this example, PageGate is scanning the sending phone number in all replies sent to the system and it matches that against a list of allowed phone numbers. If the phone number isn't on the list, the message is considered spam and not delivered. If the phone number is on the list of allowed numbers, the reply is allowed through the system. To do this, we have a single filter statement and within that filter statement, we have a search and a replace section.
The search section tells it to scan the phone number of the sender and match it against a list of phone numbers. The replace section says that if the phone number is in the list of allowed senders, the message should be allowed to go to the specified recipient or group. So, let's get in to actually writing a filter script. The first step is to create a new XML file and determine where you want that file stored.
This file can be named anything but do remember what you call the file; you'll need to reference that later. This file can be stored in any path accessible by the PageGate server, whether that's a local drive or UNC path to a shared directory. However, if this file is stored on a network share, you will need to give the PageGate, PageGate Scheduler, PageGate Interface and/or PageGate Connector Windows Services an appropriate service account to access the network resource.
In this example, I'm going to name the file newscript.xml and store it in c:\PageGateData\Scripts\ It is possible to have multiple scripts in use on the same PageGate server as you can create as many XML files as you need. This XML file controls what the filter script does and what steps it takes to accomplish the desired results. To start, let’s go over the filter script’s basic XML structure again.
A single filter script may reference multiple individual
Now, this being called a 'Replace' section can be a little misleading because you can do far more that simply replace searched data. You could store the matched data in a temporary variable to call for output or modification later. You could use the instance of finding the searched pattern to set a true or false flag. There are many things you can do with a Replace section. The
Before we get in to the specific values that can be set, let’s go over why certain names are the way they are. PageGate's standard format is as follows: Recipient Sender Message To be explicit, that is line 1, carriage return line feed, line 2, carriage return feed, lines 3 and following. So, from PageGate's basic perspective, the first line of data is the ‘recipient’ section, whether or not any recipient information is found there.
The second line is the ‘sender’ section, again, whether or not any sender information is found there. The third and following lines are the ‘message’ section. Effectively, ‘Recipient’ just the first line of data, ‘Sender’ is the second line of data and ‘Message’ is the third and following lines of data. To get back to the values that can be set for Section, this can be set to: · All This value tells the filter to scan the entire input data. · Recipient This value tells the filter to scan just the first line of the input data. · Sender This value tells the filter to scan just the second line of the input data. · Message This value tells the filter to scan everything at and beyond the third line of the input data. · Temp Temp is a temporary string variable.
In your filter script, you can write matched values to the Temp variable and then use it later for additional searches or replacements. For example, you can have certain information stored in the Temp value, and then search on and output that Temp value in successive Filter statements. · Flag Flag is another temporary variable that you can have the script assign values to. However, it is a boolean variable and can hold only a true or false value.
It can be used with boolean logic like "And" or "Or" statements to create advanced logic chains.
For example, you could enter the text ‘Fire Department’ in the Text section if you want the filter to key off of that literal sequence of alphanumeric characters. It’s also important to note that the Text section supports using boolean parameters and they can be found in 'The Filter Script' section of the documentation. The Replace section determines what you want to do with the data found in the Search and contains five values that will need to be specified.
Recipient tells the filter to replace values only in the first line of the file. Sender tells the filter to replace values only in the second line of the file. Message tells the filter to replace values only in the third and following lines of the file. Temp is a string variable that can be passed strings of characters to hold, then use its value to search on later. Temp does not support boolean operators.
For example, you can have certain information stored in the Temp value, then both search on and output that Temp value in successive Filter tags. Flag is a boolean value that can only hold a true or false statement. However, you can run "And" or "Or" statements against it for advanced logic chains. Type determines whether you want to use literal text or a RegEx statement in the Text tag and can also be used as a situational boolean operator to determine how to proceed.
The values you can specify are: Literal, RegEx, Or, And The boolean values (Or & And) modify the Flag value. So, for example, you could have the filter search for a value and set it as the Flag, then have the replace filter use "Or" to indicate that the Flag value may be more than one thing. You could also use the And operator to tell the filter that the Flag value must contain multiple variables to be matched.
See Examples 1 and 3 of the Complete Filter Examples in the documentation. If
In the next
If
The
The
This section supports using a list of variables that can be found in the documentation https://www.notepage.net/manualchoice.htm For examples of how to construct Replace statements, have a look at the ‘Filter Statement Examples’ as well as examples 1 through 6 in the ‘Complete Script Examples’ in PageGate’s documentation. Our last two sections are Continue and Abort. The Continue section tells the script whether or not you want the script to continue to the next action if it finds a match and can be set to a value of True or False.
Abort can be set to True or False and tells the script to abort its processes if no match is found. So, to review, you'll create filter blocks that must contain Search and Replace blocks and may also contain Continue or Abort blocks. Search blocks must contain a reference to Section, Type and Text Replace blocks must contain a reference to Section, Type, Scope, All, and Text. Continue sections tell the script whether or not there are multiple Filter blocks and whether the script should continue or stop.
Abort sections tell the script to abort its processes if a searched value can't be matched. This concludes the video tutorial on how to build a filter script. For more information, including examples of what different coded scripts look like, have a look at our documentation and video tutorial library.
All PageGate Tutorials

Download a free trial or contact us with questions.