{"_id":"59d154884ac471001a07afeb","project":"5746675a5aa03c0e00fce9bc","version":{"_id":"5746675a5aa03c0e00fce9bf","__v":8,"project":"5746675a5aa03c0e00fce9bc","createdAt":"2016-05-26T03:02:50.849Z","releaseDate":"2016-05-26T03:02:50.849Z","categories":["5746675a5aa03c0e00fce9c0","574899e7e8c6a420000b7314","57489c11d929e919006ed4ae","57489c82d929e919006ed4b1","57489ce91b345d0e004e5231","5748a82e1b345d0e004e5256","59ce5c88e8c105001a4bedd7","59f96cd129b4d600246c2899"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"category":{"_id":"59ce5c88e8c105001a4bedd7","project":"5746675a5aa03c0e00fce9bc","version":"5746675a5aa03c0e00fce9bf","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2017-09-29T14:45:28.177Z","from_sync":false,"order":1,"slug":"blockspring-scripts","title":"Blockspring Scripts"},"user":"545988354f86a50800f9cce4","__v":0,"parentDoc":null,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2017-10-01T20:48:08.745Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":9,"body":"Let's learn how to create alerts.\n[block:api-header]\n{\n  \"title\": \"Usecase: Send New Card Alert\"\n}\n[/block]\nSometimes you'll want to know when a new card is created, especially when it's related to a topic you're interested in.\n\nLet's walk through how to send alerts when a new card has a trigger word in its name. We'll be using:\n- Event triggers\n- The Gmail app connector\n\nFirst, we'll paste in the following code:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"import gmail_app\\nimport trello_app\\n\\n# SETUP 1: Sign in with Gmail.\\n# SETUP 2: Replace the interesting term with what you want to monitor.\\n# SETUP 3: Enter an email address to send alerts to.\\ninteresting_term = \\\"cats\\\"\\nemail = \\\"ENTER_EMAIL_TO_SEND_ALERT_TO\\\"\\n\\n# when a new card is added...\\ndef on_create_card():\\n    # get the current card\\n    card = trello_app.get_current_card()\\n\\n    # if term is in the name, send an alert\\n    if interesting_term in card.get_name().lower():\\n        gmail_app.send_message(\\\"Someone mentioned %s in %s\\\" %\\n                               (interesting_term,\\n                                card.get_field(\\\"url\\\")), email, \\\"Trello Alert\\\")\\n\",\n      \"language\": \"python\"\n    }\n  ]\n}\n[/block]\nFollow the setup steps, as outlined in the script:\n1) Sign in with Gmail.\n2) Replace \"cats\" with your own interesting term.\n3) Enter you email address.\n\nYou can see in the script, on each new card, we'll get that card's information, check if the term is in the name, and if so, send an email using our Gmail account.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/a9dc894-alert_trello.gif\",\n        \"alert_trello.gif\",\n        971,\n        686,\n        \"#f2f2f3\"\n      ],\n      \"border\": true\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"title\": \"Need Help?\"\n}\n[/block]\nIf you run into any issues, or what to chat with others, [connect to the Blockspring community](https://blockspring-help.readme.io/docs/getting-help) right from the Scripts editor.","excerpt":"","slug":"tutorial-alerts","type":"basic","title":"Tutorial: Alerts"}
Let's learn how to create alerts. [block:api-header] { "title": "Usecase: Send New Card Alert" } [/block] Sometimes you'll want to know when a new card is created, especially when it's related to a topic you're interested in. Let's walk through how to send alerts when a new card has a trigger word in its name. We'll be using: - Event triggers - The Gmail app connector First, we'll paste in the following code: [block:code] { "codes": [ { "code": "import gmail_app\nimport trello_app\n\n# SETUP 1: Sign in with Gmail.\n# SETUP 2: Replace the interesting term with what you want to monitor.\n# SETUP 3: Enter an email address to send alerts to.\ninteresting_term = \"cats\"\nemail = \"ENTER_EMAIL_TO_SEND_ALERT_TO\"\n\n# when a new card is added...\ndef on_create_card():\n # get the current card\n card = trello_app.get_current_card()\n\n # if term is in the name, send an alert\n if interesting_term in card.get_name().lower():\n gmail_app.send_message(\"Someone mentioned %s in %s\" %\n (interesting_term,\n card.get_field(\"url\")), email, \"Trello Alert\")\n", "language": "python" } ] } [/block] Follow the setup steps, as outlined in the script: 1) Sign in with Gmail. 2) Replace "cats" with your own interesting term. 3) Enter you email address. You can see in the script, on each new card, we'll get that card's information, check if the term is in the name, and if so, send an email using our Gmail account. [block:image] { "images": [ { "image": [ "https://files.readme.io/a9dc894-alert_trello.gif", "alert_trello.gif", 971, 686, "#f2f2f3" ], "border": true } ] } [/block] [block:api-header] { "title": "Need Help?" } [/block] If you run into any issues, or what to chat with others, [connect to the Blockspring community](https://blockspring-help.readme.io/docs/getting-help) right from the Scripts editor.