{"_id":"55b7f917568be2230092bc55","project":"53844557a43e08da4677be0e","version":{"_id":"53844558a43e08da4677be12","__v":8,"project":"53844557a43e08da4677be0e","createdAt":"2014-05-27T07:57:12.136Z","releaseDate":"2014-05-27T07:57:12.136Z","categories":["53844558a43e08da4677be13","538619e1ef91f96d49aa1a0b","541e82877eb16bb64f83c0ca","5445a073c3eb3808000c76b2","5445a098c3eb3808000c76b3","54bb05ab522f03150054d9e8","54bb05cf9741c81500078f73","55b7d0e5568be2230092bb92"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"false","version_clean":"1.0.0","version":"1.0"},"__v":8,"category":{"_id":"55b7d0e5568be2230092bb92","project":"53844557a43e08da4677be0e","version":"53844558a43e08da4677be12","pages":["55b7f917568be2230092bc55","55b800e2568be2230092bc85","55b83216d9caa30d001aae38","55b8324ad9caa30d001aae3a","55d3a5bac336ec0d007c222b","55d7732f4ad876170027fa1d"],"__v":6,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-07-28T18:58:45.698Z","from_sync":false,"order":2,"slug":"inbox-by-knowtify-in-app-notifications","title":"InBox by Knowtify - In-app Notifications"},"user":"5384345d90c19d5e43a8170c","updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-07-28T21:50:15.845Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":1,"body":"Shipping alerts to your Knowtify InBox works exactly the same as sending Transactional emails from Knowtify. You can see documentation for shipping transactional emails [here](http://api.knowtify.io/docs/sending-event-based-emails). \n\nTo trigger an alert from an event in your application, you will use either our [REST API](http://api.knowtify.io/docs/knowtify-api-basics), our [JavaScript API](http://api.knowtify.io/docs/javascript-widget) or directly from a [Segment integration](http://api.knowtify.io/docs/segmentio) - depending on the type of alerts and data you want to ship. \n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Creating the Alert in your code\"\n}\n[/block]\n*(Want a quick way to test our API? Check out our [Postman collection for alerts](https://www.getpostman.com/collections/467816e9b92543515d3f). If you haven't used Postman before you can see how to get started with [Postman for Knowtify here](http://api.knowtify.io/v1.0/docs/postman).)* \n\nWhen an event occurs in your app that should trigger an alert to your Knowtify InBox. You can do this via our REST API, our JavaScrip API (which is powering your InBox) or directly via [Segment](http://api.knowtify.io/docs/segmentio). \n\n**To trigger via our REST API: ** \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"POST http://www.knowtify.io/api/v1/contacts/upsert\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"event\\\":\\\"purchase\\\",  //this is the tag for the email in Knowtify\\n  \\\"contacts\\\": [\\n        {\\n            \\\"email\\\":\\\"marty:::at:::mcfly.io\\\", //this is to whom the email will be delivered\\n          \\t\\\"data\\\":{\\n              \\\"PurchasedItem\\\":\\\"Flux Capacitor 2000\\\", //this is all sample data that will populate the body of the email \\n              \\\"ItemImage\\\":\\\"/fluxcapacitor2000.jpg\\\",\\n              \\\"ItemDescription\\\": \\\"The most advanced Capacitor yet!\\\",\\n              \\\"PurchasePrice\\\":\\\"$1,299\\\"\\n            }\\n        }\\n   \\t]\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n**To trigger via JavaScript:** \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"_knowtify.push(['event', 'receipt', {\\n  id: 123,\\n  email: \\\"joe@test.com\\\",\\n  purchase_name: \\\"Chair\\\",\\n  purchase_price: \\\"$100\\\"\\n}]);\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nThe important elements for this call include: \n\n1. The tag of the notification in Knowtify (see below). This should be inserted as the value to an \"event\" key in the call.\n2. The email address of the person receiving the email. This is a key/value pair under \"Contacts\".\n3. The content of the email. Any data that will serve as the content of the email should also be inserted under \"Contacts\". Make sure that the key names you create here match the variables you enter into your message template in Knowtify.\n\n\n**To trigger directly via Segment, read [here](http://api.knowtify.io/docs/inbox-notifications-with-segment).** \n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Create the Event Notification in Knowtify\"\n}\n[/block]\n*Set an event Tag *\nTo trigger an alert from an event, you will need to create an Event Notification in the Knowtify InBox interface. You will add an Event tag to that message on the first screen. This tag is what you will reference in your event code in your application. \n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/3Uwc6rHoQFi61hWoXbiq_skitch.png\",\n        \"skitch.png\",\n        \"1252\",\n        \"545\",\n        \"#547fb1\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n*Create the Message*\nYou will then create your message in Knowtify. You will add {merge tags} for those pieces of content that will be customized for each specific user receiving the alert.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/F7DwIxubQEWO3V2F5EAx_skitch.png\",\n        \"skitch.png\",\n        \"933\",\n        \"675\",\n        \"#4284c5\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n*Set a Destination URL*\nYou can then set a URL that you want the notification to go to once clicked. It is likely that you will be passing a unique URL as a destination, in which case you will add a {merge tag} in this field. \n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/gbeYxUq1RrqRHKvVMIox_skitch.png\",\n        \"skitch.png\",\n        \"1218\",\n        \"631\",\n        \"#4480bd\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n*Turn it Live*\nFrom the Launch page, simply set your alter to LIVE and it will start to fly as those events occur in your app.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/P7JEk7QYSBmwj8YSPat8_skitch.png\",\n        \"skitch.png\",\n        \"1276\",\n        \"489\",\n        \"#4281c1\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]","excerpt":"How to send alerts triggered by specific events in your application to your InBox notification center","slug":"sending-alerts-to-inbox","type":"basic","title":"SENDING ALERTS TO INBOX"}

SENDING ALERTS TO INBOX

How to send alerts triggered by specific events in your application to your InBox notification center

Shipping alerts to your Knowtify InBox works exactly the same as sending Transactional emails from Knowtify. You can see documentation for shipping transactional emails [here](http://api.knowtify.io/docs/sending-event-based-emails). To trigger an alert from an event in your application, you will use either our [REST API](http://api.knowtify.io/docs/knowtify-api-basics), our [JavaScript API](http://api.knowtify.io/docs/javascript-widget) or directly from a [Segment integration](http://api.knowtify.io/docs/segmentio) - depending on the type of alerts and data you want to ship. [block:api-header] { "type": "basic", "title": "Creating the Alert in your code" } [/block] *(Want a quick way to test our API? Check out our [Postman collection for alerts](https://www.getpostman.com/collections/467816e9b92543515d3f). If you haven't used Postman before you can see how to get started with [Postman for Knowtify here](http://api.knowtify.io/v1.0/docs/postman).)* When an event occurs in your app that should trigger an alert to your Knowtify InBox. You can do this via our REST API, our JavaScrip API (which is powering your InBox) or directly via [Segment](http://api.knowtify.io/docs/segmentio). **To trigger via our REST API: ** [block:code] { "codes": [ { "code": "POST http://www.knowtify.io/api/v1/contacts/upsert", "language": "text" } ] } [/block] [block:code] { "codes": [ { "code": "{\n \"event\":\"purchase\", //this is the tag for the email in Knowtify\n \"contacts\": [\n {\n \"email\":\"marty@mcfly.io\", //this is to whom the email will be delivered\n \t\"data\":{\n \"PurchasedItem\":\"Flux Capacitor 2000\", //this is all sample data that will populate the body of the email \n \"ItemImage\":\"/fluxcapacitor2000.jpg\",\n \"ItemDescription\": \"The most advanced Capacitor yet!\",\n \"PurchasePrice\":\"$1,299\"\n }\n }\n \t]\n}", "language": "json" } ] } [/block] **To trigger via JavaScript:** [block:code] { "codes": [ { "code": "_knowtify.push(['event', 'receipt', {\n id: 123,\n email: \"joe@test.com\",\n purchase_name: \"Chair\",\n purchase_price: \"$100\"\n}]);", "language": "javascript" } ] } [/block] The important elements for this call include: 1. The tag of the notification in Knowtify (see below). This should be inserted as the value to an "event" key in the call. 2. The email address of the person receiving the email. This is a key/value pair under "Contacts". 3. The content of the email. Any data that will serve as the content of the email should also be inserted under "Contacts". Make sure that the key names you create here match the variables you enter into your message template in Knowtify. **To trigger directly via Segment, read [here](http://api.knowtify.io/docs/inbox-notifications-with-segment).** [block:api-header] { "type": "basic", "title": "Create the Event Notification in Knowtify" } [/block] *Set an event Tag * To trigger an alert from an event, you will need to create an Event Notification in the Knowtify InBox interface. You will add an Event tag to that message on the first screen. This tag is what you will reference in your event code in your application. [block:image] { "images": [ { "image": [ "https://files.readme.io/3Uwc6rHoQFi61hWoXbiq_skitch.png", "skitch.png", "1252", "545", "#547fb1", "" ] } ] } [/block] *Create the Message* You will then create your message in Knowtify. You will add {merge tags} for those pieces of content that will be customized for each specific user receiving the alert. [block:image] { "images": [ { "image": [ "https://files.readme.io/F7DwIxubQEWO3V2F5EAx_skitch.png", "skitch.png", "933", "675", "#4284c5", "" ] } ] } [/block] *Set a Destination URL* You can then set a URL that you want the notification to go to once clicked. It is likely that you will be passing a unique URL as a destination, in which case you will add a {merge tag} in this field. [block:image] { "images": [ { "image": [ "https://files.readme.io/gbeYxUq1RrqRHKvVMIox_skitch.png", "skitch.png", "1218", "631", "#4480bd", "" ] } ] } [/block] *Turn it Live* From the Launch page, simply set your alter to LIVE and it will start to fly as those events occur in your app. [block:image] { "images": [ { "image": [ "https://files.readme.io/P7JEk7QYSBmwj8YSPat8_skitch.png", "skitch.png", "1276", "489", "#4281c1", "" ] } ] } [/block]