{"_id":"57fcc4870312b20e00ac64e0","__v":0,"parentDoc":null,"user":"5589fde775eaf50d004e4b0c","category":{"_id":"57fcc4860312b20e00ac64c8","__v":0,"version":"57fcc4860312b20e00ac64c0","project":"5435687035740020002a1c04","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-11-04T23:13:08.376Z","from_sync":false,"order":7,"slug":"lua-scripting","title":"Agent Lua Scripting"},"project":"5435687035740020002a1c04","version":{"_id":"57fcc4860312b20e00ac64c0","project":"5435687035740020002a1c04","__v":1,"createdAt":"2016-10-11T10:52:54.637Z","releaseDate":"2016-10-11T10:52:54.637Z","categories":["57fcc4860312b20e00ac64c1","57fcc4860312b20e00ac64c2","57fcc4860312b20e00ac64c3","57fcc4860312b20e00ac64c4","57fcc4860312b20e00ac64c5","57fcc4860312b20e00ac64c6","57fcc4860312b20e00ac64c7","57fcc4860312b20e00ac64c8","57fcc4860312b20e00ac64c9","57fcc4860312b20e00ac64ca","57fcc4860312b20e00ac64cb"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"[APP-1265], [APP-1035]","version_clean":"5.2.0","version":"5.2"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-12-21T22:49:36.461Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":2,"body":"You can load the Telemetry notifications library using the `require()` function. This exposes the `post()` function which can be used to send notifications to a Telemetry channel. You will typically (although not necessarily always) want to use it inside an if-then-else statement to advise your users of anomalous conditions.\n\nIt supports the following arguments:\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"`channel`\",\n    \"h-0\": \"Name\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-1\": \"string\",\n    \"0-2\": \"The tag of the channel to which the notification should be sent. Either `channel` or `flow` is required. The other must be included as an empty \\\"\\\" string.\",\n    \"2-0\": \"`title`\",\n    \"2-1\": \"string\",\n    \"2-2\": \"The title of the notification (required).\",\n    \"3-0\": \"`message`\",\n    \"3-1\": \"string\",\n    \"3-2\": \"A message that accompanies the notification (required).\",\n    \"4-0\": \"`duration`\",\n    \"4-1\": \"string\",\n    \"4-2\": \"A string that expresses the amount of time during which the notification is visible on a board (required).\",\n    \"5-0\": \"`icon`\",\n    \"5-1\": \"string\",\n    \"5-2\": \"If set, causes boards to display the specified [Font Awesome](http://fortawesome.github.com/Font-Awesome/) icon alongside the notification (optional, defaults to an empty string).\",\n    \"6-0\": \"`sound`\",\n    \"6-1\": \"string\",\n    \"6-2\": \"If provides, this argument should contain the HTTPS URL to a sound that should be played alongside the notification (optional, defaults to `\\\"default\\\"`).\",\n    \"1-0\": \"`flow`\",\n    \"1-1\": \"string\",\n    \"1-2\": \"The tag of a flow. The notification will be sent to the flow's channel. Either `channel` or `flow` is required. The other must be included as an empty \\\"\\\" string.\"\n  },\n  \"cols\": 3,\n  \"rows\": 7\n}\n[/block]\nHere's an example of `post()` in action:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"local n = require(\\\"telemetry/notifications\\\")\\nlocal a = 10\\n\\nif a < 20 then\\n\\tn.post(\\\"\\\", \\\"flow_tag\\\", \\\"Warning\\\", \\\"Important alert\\\", \\\"10s\\\")\\nend\",\n      \"language\": \"lua\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"notifications-1","type":"basic","title":"Notifications"}
You can load the Telemetry notifications library using the `require()` function. This exposes the `post()` function which can be used to send notifications to a Telemetry channel. You will typically (although not necessarily always) want to use it inside an if-then-else statement to advise your users of anomalous conditions. It supports the following arguments: [block:parameters] { "data": { "0-0": "`channel`", "h-0": "Name", "h-1": "Type", "h-2": "Description", "0-1": "string", "0-2": "The tag of the channel to which the notification should be sent. Either `channel` or `flow` is required. The other must be included as an empty \"\" string.", "2-0": "`title`", "2-1": "string", "2-2": "The title of the notification (required).", "3-0": "`message`", "3-1": "string", "3-2": "A message that accompanies the notification (required).", "4-0": "`duration`", "4-1": "string", "4-2": "A string that expresses the amount of time during which the notification is visible on a board (required).", "5-0": "`icon`", "5-1": "string", "5-2": "If set, causes boards to display the specified [Font Awesome](http://fortawesome.github.com/Font-Awesome/) icon alongside the notification (optional, defaults to an empty string).", "6-0": "`sound`", "6-1": "string", "6-2": "If provides, this argument should contain the HTTPS URL to a sound that should be played alongside the notification (optional, defaults to `\"default\"`).", "1-0": "`flow`", "1-1": "string", "1-2": "The tag of a flow. The notification will be sent to the flow's channel. Either `channel` or `flow` is required. The other must be included as an empty \"\" string." }, "cols": 3, "rows": 7 } [/block] Here's an example of `post()` in action: [block:code] { "codes": [ { "code": "local n = require(\"telemetry/notifications\")\nlocal a = 10\n\nif a < 20 then\n\tn.post(\"\", \"flow_tag\", \"Warning\", \"Important alert\", \"10s\")\nend", "language": "lua" } ] } [/block]