Python Push notification workflow rule example

From DreamFactory
Jump to: navigation, search
DreamFactoryTutorialsPython Push notification workflow rule example

NOTE: DreamFactory Python scripting requires 'bunch' package to be installed on server. sudo pip install bunch

# POST /api/v2/db/_table/todo triggers script
# This script runs AFTER records are written to the db.
payload = event.request.payload;
if payload.resource != "":
    for record in payload.resource:
        msg = '{"Message":"A new Todo named '' was just created!", "Subject":"New Todo Created"}';
        # service name is 'push', push to SNS topic by name
        result ='/push/topic/arn:aws:sns:us-east-1:xxxxxxx:new_todo', msg);
        # output result to storage/logs/dreamfactory.log