`
sms messaging
NotePage Logo
NotePage Software
NotePage Orders
Download NotePage Software
Integration
Software Solutions
NotePage Support

 SNPP Settings
 WCTP Settings
 TAP Numbers
 SMTP Settings
 PageGate Support
 NotePager Pro Support
 Learning Center
 Support Forum
NotePage Resellers
NotePage Press Releases
 

NotePage Background Graphic

How to Write a Filter Script for PageGate Video Tutorial

How to Write a Filter Script


Please be patient while the video loads
wmv video format mov video format
itunes feed avi video format

How to Write a Filter Script for PageGate Transcript for Video:
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.

<Filter>
The Filter section determines what you want to do with the data read as input. A single filter script may reference multiple individual <Filter> sections to perform multiple tasks within the same data set. It's also important to note that the filter system supports the use of Regex, allowing for a high level of customization and control.

You'll build Filter block sections and each Filter section will determine a step in scanning for information and processing your data.

Each Filter section contains a <Search> section, which tells the filter what to look for, and a <Replace> section, which tells the filter what to do with the data it's found.

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 <Search> section contains three values that will need to be specified:

<Section>
<Type>
<Text>

<Section> determines where in the data this filter statement needs to look.

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.

<Type> determines what sort of information the filter should expect to see in the following <Text> section. This can be set to RegEx or Literal.
If Type is set to RegEx, the value in the Text section will need to be a RegEx expression.
If Type is set to Literal, the filter will expect a literal text value in the Text section and won’t expect any RegEx expressions.

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.
<Section>
<Type>
<Scope>
<All>
<Text>

<Section> determines where in the data this filter statement needs to look and can be set to the following values:

All tells the filter to replace any instance of the searched text within the entire data set read from the input file.

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 <Type> is set to RegEx, the value in the Text section will need to be a RegEx expression.

If the value Flag is used in <Section> then one of the Boolean operators (And, Or) can be used in the <Type> section. They will use this operator and the new <Text> section value to modify the Flag variable.

For example, in one <Filter> section you could set Flag to True if certain text is found. In the next <Filter> section you could search for different text and update the Flag variable using the value 'And' or 'Or' in the <Type> section, depending if you want the new Flag variable's value to signify if BOTH the first text searched for AND the second text searched for were found, or if EITHER the first text searched for OR the second text searched for was found.

For a more specific example of this, see Example 3 in the ‘Complete Script Examples’ section of the documentation.
 
If <Type> is set to Literal, the filter will expect a literal text value in the <Text> section and won’t expect any RegEx expressions.

The <Scope> section tells the filter how much data to replace if a match is found. It can be set to a value of either Match or Section.

If <Scope> is set to Match, only the text found in the <Search> section will be replaced
If <Scope> is set to Section, then all the text in the data specified by <Section> will be replaced

For example, you could search for the text ‘Fire Department’ and then set <Section> to Recipient and <Scope> to Section, to tell the script to replace the recipient section with the new text, effectively telling the script: So, if you find this text in the body, change the recipient to the value specified.

The <All> section tells the script whether it should replace all matches found or just the first match found, and can be set to True or False.

For example, if you’re searching for the word ‘pills’ and that word appears multiple times in the data, if <All> is set to True, the replacement will happen for all instances of the word ‘pills’. If <All> is set to False, the replacement will happen only for the first instance of the word ‘pills’.

The <Text> section, of course, controls the text used to make the replacement, and the type of information you can use in this section is controlled by the <Type> section.

As an example for the <Text> section, you could enter the text ‘Fire Department’ in the <Text> section if you wanted the filter to replace the text found in the Search with that literal sequence of alphanumeric characters.
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.

PageGate Video Tutorials Additional PageGate Video Tutorials
RSS Feed for Video Tutorials Video RSS Feed

send sms
Copyright 1996-2020 NotePage, Inc. Privacy Policy
View Mobile Version NotePage.net