Example: National Weather Service |
Top Previous Next |
Note: This requires the GetASCII API and the Filter Pack.
With the HTTPGET and HTTPPOST protocols, you can poll information from any web API that supports the GET or POST methods. That information can then be fed through a filter pack to turn it in to a message to your recipients and groups. For instance, if you have a web resource that provides XML content, you can configure PageGate to poll for that XML content, then feed it through a filter pack to turn it in to a readable text message.
In this example, we're configuring PageGate to automatically poll the National Weather service for information on the weather in your local area, then send that weather information out as an SMS to your recipients and groups.
Step 1: Configure PageGate to send SMS
Step 2: Create the carrier to poll the information from the web API 1)Right click Carriers, left click Add. 2)Name the carrier: noaa-weather 3)Set the protocol to: HTTPGET 4)Set the Host to the National Weather Service's web API: w1.weather.gov/xml/<your region> For example, you would use this for the weather at Boston Logan International Airport: w1.weather.gov/xml/current_obs/KBOS.xml For more information on the National Weather Service's web API/XML feeds, have a look at their website: http://w1.weather.gov/xml/current_obs/ 5)Set the port to: 80
6)Click Apply to add the noaa-weather carrier. 7)Go to Carriers - noaa-weather - Template. 8)In the Settings section, specify the following: ResponseRecipient=weather-response
9)Click Apply.
Step 3: Create a File carrier to pass the web API information to PageGate's GetASCII API and Filter Pack for processing 1)In Windows, create a new directory for PageGate's message processing to reference. This can be any folder accessible to PageGate, whether on the local hard drive or by UNC path to a network resource. However, if PageGate will need to reference a network resource, the services relevant to these processes will need permission to access it. For more information, see the services section of the documentation. We recommend creating a directory called response as a sub-directory of PageGate's database directory (By default, c:\PageGateData\response\).
2) Right click Carriers, left click Add. 3) Specify the following: Carrier: weather-responses Protocol: File File Path: Specify the directory you created in step 10. By default, c:\PageGateData\response\ Extension: .txt Max Chars: 2000
4) Click Apply.
Step 4: Create a recipient tied to the File carrier 1)Right click Recipients, left click Add. 2)Specify the following: Full Name: weather-response Recipient: weather-response Type: Normal Carrier: weather-responses Failover: (none) ID/PIN: Leave blank Max Chars: 2000
3) Click Apply
Step 5: Configure and enable the GetASCII API 1)In Windows, create a new directory for the GetASCII API's basic processing. We recommend creating a directory called ASCII as a sub-directory of PageGate's database directory (By default, c:\PageGateData\ASCII\). 2)In the PageGate Admin, go to Interfaces - GetASCII - Settings. 3)Set the 'Polling Directory' to the directory you created in step 1. By default, c:\PageGateData\ASCII\ 4)Check Enabled.
5)Click Apply. 6)Say yes, you do want this to be enabled for everyone. 7)Go to Interfaces - GetASCII - Settings - Advanced Polling - Files. 8)Click Add and specify the following: Recipient: * From: File(s): *.txt File Type: Standard Path: Specify the folder the reply messages will be written to. By default, C:\PageGateData\response\
9)Click Apply. 10) Click Apply again. 11) Go to Program - Settings. 12) In the 'Run on this server' section, check GetASCII. 13)Click Apply. 14) If prompted for credentials, leave them blank and click Apply again.
Step 6: Configure the Filter Pack to process the web API data 1)Copy pgfilter.exe, pgfilter.xml and preproc.bat in to the directory you created for the weather-responses File carrier. By default, c:\PageGateData\response\ 2)Click here for the necessary pgfilter.xml script configuration.
Step 7: Create a recipient to initiate the weather check with the National Weather Service 1)Right click Recipients, left click Add. 2)Specify the following: Full Name: check-weather Recipient: check-weather Type: Normal Carrier: noaa-weather Failover: (none) ID/PIN: 123 Max Chars: 2000
3)Click Apply.
Once you finish this configuration, any time a any message is created for the check-weather recipient, the program will perform the necessary request to poll the current weather data from the National Weather service, then send that information as a text message to the recipients and groups specified in the filter pack's configuration.
As an added bonus, if you have the PageGate Client, you can configure a scheduled message to go to the weather-check recipient every day at a specified interval. So, you could configure the program to check and broadcast the weather every hour, day, week, month or at any other timescale you prefer.
It's also important to note that you can configure as many HTTPGET carriers to check as many National Weather service regions and have all output fed through the same filter pack. |