Creating CAP Alerts

  • 2
  • Question
  • Updated 2 years ago
  • Answered
Archived and Closed

This conversation is no longer open for comments or replies and is no longer visible to community members.

Is it possible to post alerts to the CAP web service URL? Here's what we've tried

simple python script to submit a sample CAP 1.2 XML using the requests module:

import requests
xml = """<?xml version = "1.0" encoding = "UTF-8"?> 
<alert xmlns = "urn:oasis:names:tc:emergency:cap:1.2">
 <identifier>43b080713727</identifier>   
 <sender>hsas@dhs.gov</sender>
 <sent>2016-01-26T15:20:01-07:00</sent>
 <status>Actual</status>   
 <msgType>Alert</msgType> 
 <scope>Public</scope>   
 <info> 
   <category>Security</category>     
   <event>Homeland Security Advisory System Update</event>     
   <urgency>Immediate</urgency>     
   <severity>Severe</severity>     
   <certainty>Likely</certainty>     
   <senderName>U.S. Government, Department of Homeland Security</senderName> 
   <headline>Homeland Security Sets Code ORANGE</headline> 
   <description>The Department of Homeland Security has elevated the Homeland Security Advisory 
System threat level to ORANGE / High in response to intelligence which may indicate a heightened 
threat of terrorism.</description> 
   <instruction> A High Condition is declared when there is a high risk of terrorist attacks. In 
addition to the Protective Measures taken in the previous Threat Conditions, Federal departments 
and agencies should consider agency-specific Protective Measures in accordance with their 
existing plans.</instruction>
 </info> 
</alert>"""
headers = {'Content-Type': 'application/xml'}
url = 'https://rvaserver2.appspot.com/alerts/cap?id=capidgoeshere'
r = requests.post(url, auth=('username', 'password'), headers=headers, data=xml)
print r.status_code
print r.text
XML Validates at https://cap-validator.appspot.com/validate (and is actually where the xml sample is from)

response is 200 OK with no text.

Alerts are never displayed. Any ideas?
Photo of Stephen Elaschuk

Stephen Elaschuk

  • 286 Points 250 badge 2x thumb
  • frustrated

Posted 3 years ago

  • 2
Photo of Blake Freeman

Blake Freeman, Official Rep

  • 36,116 Points 20k badge 2x thumb
Hi Stephen,

This is a bit outside of what I normally do. I'm going to call on some co-workers to take a look at this thread!
Photo of Wendi Borden

Wendi Borden, Champion

  • 6,028 Points 5k badge 2x thumb
This has been asked before, and I'd love to have something we could use..

https://community.risevision.com/rise_vision_inc/topics/alerting-available-in-displays

https://community.risevision.com/rise_vision_inc/topics/making-your-own-cap-provider

Maybe if we get an answer, it could be posted there, or those topics merged to this one?

Also maybe of interest, the initial discussion of Alerts at all..
https://community.risevision.com/rise_vision_inc/topics/emergency_alert_system
Photo of Byron

Byron, Keener

  • 9,658 Points 5k badge 2x thumb
Wendi, to confirm, are you asking if we are making an Alert publishing system or asking how to make one? Thanks!
Photo of Stephen Elaschuk

Stephen Elaschuk

  • 286 Points 250 badge 2x thumb
As an addendum, trying to post via curl has similar results of no alert display:
curl -X POST -d '<?xml version = "1.0" encoding = "UTF-8"?><alert xmlns = "urn:oasis:names:tc:emergency:cap:1.2"><identifier>43b080713727</identifier><sender>hsas@dhs.gov</sender><sent>2016-01-27T15:20:01-07:00</sent><status>Actual</status><msgType>Alert</msgType><scope>Public</scope><info><category>Security</category><event>Homeland Security Advisory System Update</event><urgency>Immediate</urgency><severity>Severe</severity><certainty>Likely</certainty><senderName>U.S. Government, Department of Homeland Security</senderName><headline>Homeland Security Sets Code ORANGE</headline><description>The Department of Homeland Security has elevated the Homeland Security Advisory System threat level to ORANGE / High in response to intelligence which may indicate a heightened threat of terrorism.</description><instruction> A High Condition is declared when there is a high risk of terrorist attacks. In addition to the Protective Measures taken in the previous Threat Conditions, Federal departments and agencies should consider agency-specific Protective Measures in accordance with their existing plans.</instruction></info></alert>' https://username:password@rvaserver2.appspot.com/alerts/cap?id=capid
Content is valid CAP 1.2 as per https://cap-validator.appspot.com/
The URL on the end is sanitized, but in testing we substitute the proper username/password/capid. It seems like rvaserver2.appspot.com/alerts/cap returns 200 OK no matter what is sent, so long as it is using the POST method.
Photo of Wendi Borden

Wendi Borden, Champion

  • 6,028 Points 5k badge 2x thumb
Hey Byron,

I've read about the providers on the setup page, but we are not subscribers to their services. What I'd like to be able to do is the same as the original poster.. create our own CAP feed and post it to Rise Vision. We're capable of creating the feed ourselves and making it CAP compliant, we just don't know how to post it to RV.

It seems like it should be possible, but we're just not sure where to push our info or how Rise will pick it up (without RaveAlerts or E2Campus). Specifically, we already send our customers txts and emails for weather alerts (via NOAA, that also has CAP feed), but if we can send that info straight to their sign as well, that would be incredible.

It's not huge priority for us, but if we could find out, I'd love to be in the loop. Thanks! :)
Photo of Biologyben

Biologyben

  • 3,558 Points 3k badge 2x thumb
I would note that I tried to do this using the CAP 1.2 data from NOAA, and also had no luck.  I would love something that would grab that NOAA Cap feed and send it as an alert!
Photo of Stephen Elaschuk

Stephen Elaschuk

  • 286 Points 250 badge 2x thumb
Not sure if something recently changed, or if I just hit on the right way to structure the CAP alert, but this is working for me now:
curl -X POST -H "Content-Type: application/xml" -d '<alert xmlns = "urn:oasis:names:tc:emergency:cap:1.2"><identifier>1</identifier><sender>someorg.com</sender><sent>2016-01-27T15:35:00-07:00</sent><status>Actual</status><msgType>Alert</msgType><scope>Public</scope><info><category>Safety</category><event>test event</event><urgency>Immediate</urgency><severity>Severe</severity><certainty>Observed</certainty><headline>headline goes here</headline><description>description goes here</description><instruction>instruction goes here</instruction></info></alert>' https://username:password@rvaserver2.appspot.com/alerts/cap?id=capidgoeshere
Photo of HSuarez

HSuarez

  • 11,896 Points 10k badge 2x thumb
It is hard to tell for sure. But I have come across an instance when a certificate being used was not being accepted since the Certificate Authority is in beta. What provider are you using?
Photo of Biologyben

Biologyben

  • 3,558 Points 3k badge 2x thumb
I was talking about using the cURL code posted above in a terminal environment to POST the XML to Rise.  The certificate would more likely by the certificate on my machine running the code.  I don't know if I would see an error message if this were the case...
Photo of george saad

george saad

  • 60 Points
 Wendi Borden
Can you please provide the step and the curl you used to make that happen please?
Photo of Wendi Borden

Wendi Borden, Champion

  • 6,028 Points 5k badge 2x thumb
Hi George,

It's been about a year since I last messed with it.. but I put this together from my notes and just sent it and it worked perfectly. Pretty sure it's just a copy of Stephen's curl command. I just put it right in the terminal, but you can set it up in some scripts to take care of your particular circumstances.
Just fill in the headline, description, and instruction fields. Be sure the CAP service is setup in your account and type in your CAP id where the XXXX's are at the end.

curl -X POST -H "Content-Type: application/xml" -d '<alert xmlns = "urn:oasis:names:tc:emergency:cap:1.2"><identifier>1</identifier><sender>yourcompany.com</sender><sent>2017-01-27T07:38:00-06:00</sent><status>Actual</status><msgType>Alert</msgType><scope>Public</scope><info><category>Safety</category><event>test event</event><urgency>Immediate</urgency><severity>Severe</severity><certainty>Observed</certainty><headline>headline goes here</headline><description>description goes here</description><instruction>instruction goes here</instruction></info></alert>' https://rvaserver2.appspot.com/alerts/cap?id=XXXXXXXXXXXXXX



Additionally, if you're looking for a super simple way to send CAP info to your screen, check out Dave's project below. It's very intuitive and easy to use.

https://community.risevision.com/rise_vision_inc/topics/custom-alert-message-service-from-your-smart...
Photo of George Saad

George Saad

  • 134 Points 100 badge 2x thumb
Thank you Wendi, I look at the two options and see which one works for me! 
Thanks for your help!
Photo of Biologyben

Biologyben

  • 3,558 Points 3k badge 2x thumb
Also - for the RISE developers - 

In the Alert GUI, you show filters that include required CAP compliant indicators.  Two however are odd.  

Handling Code (Code) is listed in the CAP standards as optional information to add to the Alert before the info area.  However Rise shows this as two separate areas - Handling & Code.   (Actually - looking at the previous RVA version of the gui, my guess is that 'Code' is the optional event code - infering based on the location of the text box)

However, CAP 1.2 also requires Sent, Identifier, MsgType, Scope, Event, but I do not see via the gui that Rise does anything with this info.  

I'm curious if "Code' that the GUI refers to one of these other pieces of information and if Rise does anything in the backend with the other items.

CAP 1.2 requirements are listed as outlined here
(Edited)
Photo of HSuarez

HSuarez

  • 11,896 Points 10k badge 2x thumb
Are you currently using Alerts in conjunction with E2Campus or GetRave? We have also written an article introducing Alerts but in relation to these third party services.
Photo of Biologyben

Biologyben

  • 3,558 Points 3k badge 2x thumb
No - If I had that kind of money I likely wouldn't be using Rise either! No offence ;-)

My question was how the Rise GUI relates to the raw XML code requirements by the CAP 1.2 standard. 
Photo of Biologyben

Biologyben

  • 3,558 Points 3k badge 2x thumb
And for others interested in pursuing some sort of homebrew CAP alerts for thier own systems, I thought I'd go ahead and drop this package of opensource tools here for future reference.  

If I had the time & skill - I'd think this is a likely starting point to develop an opensource Alert system to integrate into Rise.

https://github.com/CAPTools 
(Edited)
Photo of Biologyben

Biologyben

  • 3,558 Points 3k badge 2x thumb
So - the answer seems to be a definite YES.

I suppose my cURL wasn't configured properly as I was able to use https://www.hurl.it/ to send just the xml code above to my displays!  Worked great!  

To replicate, first be sure that your settings in the RISE alert Tab are configured (and perhaps limit the displays to a single display to test.  You may also choose to limit the number of minutes the alert is show to keep from tying up the system for too long - 5 minutes is a good start.

Then go to Hurt.it  Choose POST and use your URL from Rise
https://rvaserver2.appspot.com/alerts/cap?id=YOUR_ID_GOES_HERE
Choose basic authentication and insert the Username and Password you set up (at the Rise Alerts tab) 

Ignore headers and parameters - select Body and paste the XML and submit.  (be sure to update the UTC time and set the time code  to your local time(<sent>YYYY-MM-DDTHH:MM:SS-05:00</sent> -- 05:00 for East Coast, -08:00 for Pacific)
<alert xmlns = "urn:oasis:names:tc:emergency:cap:1.2"><identifier>1</identifier><sender>someorg.com</sender><sent>YYYY-MM-DDTHH:MM:SS-05:00</sent><status>Actual</status><msgType>Alert</msgType><scope>Public</scope><info><category>Safety</category><event>test event</event><urgency>Immediate</urgency><severity>Severe</severity><certainty>Observed</certainty><headline>headline goes here</headline><description>description goes here</description><instruction>instruction goes here</instruction></info></alert>
In just a second or three, the alert should show on your screen.  If not, run your XML through the CAP Validator, Double check your settings in Rise, and be sure your XML has the time set properly.



I would think it should be easy to create a simple form with drop down fields for the basic alert categories and fill in the the three items Rise will show.  

Perhaps also it wouldn't be much harder to direct an NWS atom feed directly back to the Displays as well...
(Edited)
Photo of Wendi Borden

Wendi Borden, Champion

  • 6,028 Points 5k badge 2x thumb
Thanks for posting this! I had a crazy week and was unable to offer any input, but I'm honestly grateful for the information you've found :) I haven't had a lot of time to sit down and test the RV Alerts system very well. I honestly never got it working in my main company, and i only worked in the sub-company I made just to test it out. I've come to the conclusion that maybe it's nice for the people with the paid services, but for us in particular I don't feel comfortable with it's stability for writing our own warnings. I also don't think I'd be able to get it to work exactly in the manner than we need here at our company. Given that, we'll probably just make our own widget for the sake of our purpose. Or write some script to publish a specific playlist ourselves using the API. I'm still interested in seeing what it's capable of, and I'm glad to know some workarounds now for actually utilizing it.
Photo of Biologyben

Biologyben

  • 3,558 Points 3k badge 2x thumb
I would think it should relatively easy assemble the parts to make this work for certain use cases - perhaps not life & death situations, but for easy way to have a quick screen takeover.

I feel it would just take the right person to take the pieces and put them together 
  • Create a simple webform GUI
  • On form submission, the entries are wrapped in properly formatted XML
  • Webserver then POST to Rise URL

Perhaps this could be used more for information notices - others who had asked how to supersede the schedule (Free Coffee in the break room)  (Blue Light Special for the next 5 minutes,  etc)

Of course - I'd love to see other widgets that might do a similar function ;)
Photo of Wendi Borden

Wendi Borden, Champion

  • 6,028 Points 5k badge 2x thumb
I don't think that would be too difficult to code up actually. Might not be bad for a quick screen takover. I'd need to test it out really well before being comfortable with it. I seemed to be having problems with it not making it to the screen at times.. I suspect it was a timing issue on my part. Anyway, this does seem like a pretty cool idea. Might be something we choose to pursue :) We may also consider some type of schedule change via the API on our end for notices.. rather than POST an <xml> maybe we'll update our schedule instead through the API and then set it back. Given that, we could even alter the time of the takover or choose a different presentation. Forgive me, my gears are just turning now.. *lol*
Photo of Biologyben

Biologyben

  • 3,558 Points 3k badge 2x thumb
The time part is fiddly (especially if you use a short duration in Rise to display and your watch is off) but if it was auto populated with UTC, this should be eliminated.  I also kept using local time instead of utc...silly me...

One other odd ball thing I found was CAP standards limit special characters - an ampersand in the field text for instructions (Drop & Cover) did not validate and thus did not display.
Photo of HSuarez

HSuarez

  • 11,896 Points 10k badge 2x thumb
Thanks for sharing your findings here :) And also dropping the Github repo for CAPTools https://github.com/CAPTools for other users!
Photo of Dave

Dave

  • 2,836 Points 2k badge 2x thumb
Quick question:

I am able to trigger the designated Alert Presentation with CURL and get a 200 OK. But the text passed in XML never displays inside the designated presentation when it comes up. I have validated it a few times and it all looks alright.

curl -X POST -H "Content-Type:application/xml" -d '<alert xmlns = "urn:oasis:names:tc:emergency:cap:1.2"><identifier>1</identifier><sender>someorg.com</sender><sent>2016-10-20T20:15:00-05:00</sent><status>Actual</status><msgType>Alert</msgType><scope>Public</scope><info><category>Safety</category><event>test event</event><urgency>Immediate</urgency><severity>Severe</severity><certainty>Observed</certainty><headline>LOOK AT ME</headline><description>THIS IS BAD</description><instruction>RUN</instruction></info></alert>' https://rvaserver2.appspot.com/alerts/cap?id=xxxxxxxxxxxxxxxxxxxx


Any thoughts? 
(Edited)
Photo of Stephen Elaschuk

Stephen Elaschuk

  • 286 Points 250 badge 2x thumb
Hm, the only thing I can think of is that maybe the designated presentation doesn't have the fields specified for the text?

If you check in the HTML for the presentation you should have a few lines similar to the following which will include the CAP alert message:
<div id="headline" class="fill_with_text" style="margin-left:5%; margin-right:5%; margin-top:2%;width:90%">%HEADLINE%</div>
<div id="description" class="fill_with_text" style="margin-left:5%; margin-right:5%; margin-top:-3%; width:90%">%DESCRIPTION%</div>
<div id="instruction" class="fill_with_text" style="margin-left:5%; margin-right:5%; width:90%">%INSTRUCTION%</div>
Photo of Dave

Dave

  • 2,836 Points 2k badge 2x thumb
Thanks Stephen,

Do you know if there a doc or a sample presentation that lists the or describes the field variables?!?! I had searched before I posted and found no joy.

Or is it simply a matter of %---% around the XML nodes?
Photo of Dave

Dave

  • 2,836 Points 2k badge 2x thumb
Yep that was it. Had the fields disabled in the RV alert configuration
Photo of Dave

Dave

  • 2,836 Points 2k badge 2x thumb
At the risk of duplicating something someone else may have already worked on, I built a small, sloppy, mobile web app that sends app-user-created CAP messages to the Risevision Alert service.

It should be in a broader beta test state in two weeks. If anyone would like to critique or participate in what we are doing, it would be appreciated.
Photo of Biologyben

Biologyben

  • 3,558 Points 3k badge 2x thumb
I'd definitely be interested!
Photo of Scott Williams

Scott Williams

  • 158 Points 100 badge 2x thumb
I would be intrested also
Photo of Dave

Dave

  • 2,836 Points 2k badge 2x thumb
Real simple interface. All of the CAP functionality is server sided. Transmission time is usually under 400ms and Risevision Alert Service responds and pushes to the display in usually under 20 seconds worst case and near immediately in the best case.

The Jquery UI really does nothing more than what was originally suggested by Biologyben up-stream in previous discussions. It takes 3 CAP variables off the form, does some basic validation and then pushes to the remote service for munging into the CAP1.2 format. The server packages the XML and sends it to the RiseVision Alert services over https.

This implies that either the company or sub-company where alerts are made active , must either provide the companies Alert ID (perhaps secured in a server sided config DB) or the app will need to ask for it and then possibly store it in the devices browser app-cache. 

It would be cool to utilize the user id and password option when connecting to the RiseVision Alert services. But it does not seem to make a difference if the credentials provided are incorrect or not present. As it stands now, whatever you throw at it, the Alert Service publishes. 

Photo of Robb

Robb, Official Rep

  • 76,676 Points 50k badge 2x thumb
Very cool! Thanks for sharing Dave!
Photo of Biologyben

Biologyben

  • 3,558 Points 3k badge 2x thumb
Sweet - I hoped someone with the skills would pull this off!  I'm looking forward to trying this out!    

The next cool someday 'feature' would be if Rise Vision would select the alert presentation (or perhaps just a color variable or icon/photo all within one presentation) based on a field for alert category. 

Imagine if you could change the border color for drill (yellow) vs real, Red) or add a fire or torndado icon.  Or even a Coffee Cup for a "Free Coffee in the Break Room" style message. 

It would take adding a 4th dropdown selector to the webgui to choose and some code in the Rise presentation to show the color/icons based on category (if category= Fire > Fire.jpg)
Photo of Dave

Dave

  • 2,836 Points 2k badge 2x thumb
First Field Customer Beta test is starting tomorrow. This is a government services facility so I do not know how fast our trusted on-site user will be able to test. As soon as I have commentary, I will post here.

Anyone wishing to test this service on their own displays can send me an email. I think for testing purposes I am going to make the alert URL "ID" a form field on the UI. This will force the end users who test the app to type in the ID each time they dump their browser cache. It will also prevent you from having to give me your Alert ID. 

Though I think Biologyben has an interesting idea with 'the next cool someday feature' , this application is doing only one thing and that is posting the CAP Headline, Description and Instructions as if they were any other text.

The next thing to look at (beyond fixing all of the bugs) will be to implement more of the CAP XML as form and post elements for end users that really want/need full CAP1.2 msg compliance.

email : info@6signs.com
Photo of Dave

Dave

  • 2,836 Points 2k badge 2x thumb
To-the-point  review: "It worked."
Cleaning up UI and ID management.
Photo of Dave

Dave

  • 2,836 Points 2k badge 2x thumb
ready to test
Photo of Robb

Robb, Official Rep

  • 76,676 Points 50k badge 2x thumb
Fantastic.
Photo of Dave

Dave

  • 2,836 Points 2k badge 2x thumb
Rob,

Would it be OK if I set up a new discussion to gather feedback and discussion on this as a new topic?
Photo of Robb

Robb, Official Rep

  • 76,676 Points 50k badge 2x thumb
Of course Dave! My only suggestion would be to link to this conversation so people have some context :)
Photo of Biologyben

Biologyben

  • 3,558 Points 3k badge 2x thumb
Fantastic - this will be a great feature!
Photo of Dave

Dave

  • 2,836 Points 2k badge 2x thumb
I have started a new "idea" thread to allow community participation and comment.

https://community.risevision.com/rise...

Support or access requests can be sent to support@6signs.com