{"_id":"580f2b923898430f00c9af44","__v":1,"user":"54eb4fdedf7add210007b29b","category":{"_id":"551546edbc466623002afe72","pages":["551549c0bc466623002afe76","55154afbc859ac2f0001b486","55154daec859ac2f0001b48b","55154f36bc466623002afe7c","551550c5e68daa2f00cff84c","551551d4f854a31900368737","551552e7c859ac2f0001b494","551be4e3a0ee622b0087f69e","5527acc447b71d0d0044e6cd","552f84ad633a5b0d00e99daf","5537533df162750d00bbf7d0","554b3ffd6b448d0d00646d79","55506416fa289c0d0075e4f0","5550aaea00420e0d00d13113","55545865b450630d00041d80","55546906f9a7871700ef8e3c","555c4bf87e271d0d00f3c8c4","5564318c1fa8002300ea4bb0","556ffbd5910c090d00c432b6","557019f4cc189a21001ab258","55703aefcc189a21001ab2a3","5575a3c60b81dc230069c910","558ab69575eaf50d004e4cf3","55b0b41fb3171b3700b1539a","55ba2e48d72d1e1900276ac1","55ba45c804775a2f00628101","55c0b789344dc40d00f55933","55c0b8c837298d0d00088d88","55c0c095344dc40d00f55960","55d43e05b49ab11900328e2e","55d72c8c60fc730d00fc2738","55e6c564d678ad17001589ac","55e9b7780c9b420d0042b275","55f7cf2de32e9b0d00a2d4b6","56094efea7b2590d0089eb95","5613cdbeecbebc21003fa179","5613d8de6a092921004c30b8","5613de7c443514170060dbb6","5613e02823ecf6350009eefc","5613e4271db46e2100e142ad","5614d73c8113d20d00082e3e","561e11ae50e0a62100955946","561e2008efcf8217003adf77","5620f184b244890d001868e0","5620feb740e2c30d0002a899","562105ce40e2c30d0002a8a3","56210b3340e2c30d0002a8b3","56210c74b244890d0018690e","56249a0372ac510d00e49149","56249df185a31117001c53de","56249f0c85a31117001c53e1","5624a9e7c4bf501700bc5ec8","5624b29806e8040d005ed6a0","562507435a86b42300946324","563877854bfb360d00a463c1","5639e0f91846790d0089529a","565327d17d29410d004a0835","565457df04feff210074b17d","56545821ec189235002967af","565485099c4c6d0d00aeda02","5666f1f1f672550d000851ad","566abc7b74d574170070b700","566ad3c7c7c3cd1700265d14","566aede7b5ccc20d00817f71","566aef3147ebaf1900fe65d6"],"project":"54eb50e5615ffc1900305a16","version":"54eb63b859b1172100334fae","__v":65,"sync":{"url":"","isSync":false},"reference":true,"createdAt":"2015-03-27T12:02:53.314Z","from_sync":false,"order":11,"slug":"advanced-tutorials","title":"Advanced tutorials"},"version":{"_id":"54eb63b859b1172100334fae","project":"54eb50e5615ffc1900305a16","forked_from":"54eb63a1867e1917009b711d","__v":28,"createdAt":"2015-02-23T17:30:32.501Z","releaseDate":"2015-02-23T17:30:32.501Z","categories":["54eb63b959b1172100334faf","54eb63b959b1172100334fb0","54eb63b959b1172100334fb1","54eb63b959b1172100334fb2","54ed8dd4ab373e2300f50eae","54ed99b2ab373e2300f50ede","55153a6de68daa2f00cff838","551546edbc466623002afe72","5515472ac28d6125001b8884","55154749c28d6125001b8885","555d9b4106dfec0d00d38ea7","5613e06e433e5735007c7708","5624bbb785a31117001c5403","56669e857cc81e0d00253f8e","568b8d837a42220d00498311","56a632277ef6620d00e2f18a","56d8147c3eb4dd0b00201aac","57a9ce2fac6db30e000d7efd","57a9cf4e944ea60e00dc3f74","58172386715dce0f00da4aa0","582dc59ee1b8692300c0dd03","589b19b4fec2730f0082e040","58b04a023529383900a759b5","58b92d1598157a0f004869bf","592e7685c58275000f20174f","59392839e376d4002f8a0474","59393064e376d4002f8a05a1","5947ae0d4005e2000f3a4fec","594a74df1d1de5001ab3517a","5954bc387a147f001b918915","59b8eeeb707542001076d3b6"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1"},"parentDoc":null,"project":"54eb50e5615ffc1900305a16","updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-10-25T09:53:22.679Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":true,"order":7,"body":"Sending an SMS message seems simple enough until you get unexpected results which can be caused by various reasons. Just a single unsupported character can significantly reduce the total number of available characters per message which can cause a message to be split into two or even more messages, significantly increasing the cost of sending messages. Things get even trickier when messages must be sent in different languages and **language **and **transliteration **options are introduced.\n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"To avoid unpleasant surprises, use this method to preview messages before sending them.\",\n  \"title\": \"Note\"\n}\n[/block]\nThe preview method can provide you with the following information:\n* `originalText` - original text that was supplied for preview\n* `textPreview` - preview of the text as it should appear on the recipient's device\n* `messageCount` - number of messages required to deliver `textPreview`\n* `charactersRemaining` - number of remaining characters before `messageCount` increase\n* `configuration` - configuration setup that should be included in advanced SMS in order to deliver `textPreview` message\n[block:api-header]\n{\n  \"type\": \"post\",\n  \"title\": \"Message count and remaining characters\"\n}\n[/block]\nUse this method to see how many characters are left 'unspent' in the message and if the message fits in one or more messages.\n\n##Request\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"POST /sms/1/preview HTTP/1.1\\nHost: api.infobip.com\\nAuthorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==\\nContent-Type: application/json\\n\\n{\\n    \\\"text\\\": \\\"Let's see how many characters will remain unused in this message.\\\"\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n##Response\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"originalText\\\": \\\"Let's see how many characters will remain unused in this message.\\\",\\n  \\\"previews\\\": [\\n    {\\n      \\\"textPreview\\\": \\\"Let's see how many characters will remain unused in this message.\\\",\\n      \\\"messageCount\\\": 1,\\n      \\\"charactersRemaining\\\": 95,\\n      \\\"configuration\\\": {}\\n    }\\n  ]\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\nThe response contains the original text (sent text) and one preview which showcases a message received by the recipient without any configuration. In this case, the text will fit in one message and there will be 95 characters left. No special configuration is needed if your goal is to deliver the message as seen in `textPreview`. \n\nYou can use 'simple' or 'advanced' 'send SMS' methods to send this message.\n[block:api-header]\n{\n  \"type\": \"post\",\n  \"title\": \"Message language\"\n}\n[/block]\nBy introducing language code we can preview a message displayed using selected alphabet. In this example we will request a message preview for Turkish language by introducing the `languageCode` parameter.\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Info\",\n  \"body\": \"Sending messages in a specific language is supported in advanced SMS method. Find more information about supported languages and language codes: [SMS language](/docs/language)\"\n}\n[/block]\n##Request\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"POST /sms/1/preview HTTP/1.1\\nHost: api.infobip.com\\nAuthorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==\\nContent-Type: application/json\\n\\n{\\n    \\\"text\\\": \\\"Mesaj gönderimi yapmadan önce önizleme seçeneğini kullanmanız doğru karar vermenize yardımcı olur.\\\",\\n    \\\"languageCode\\\": \\\"TR\\\"\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n##Response\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"originalText\\\": \\\"Mesaj gönderimi yapmadan önce önizleme seçeneğini kullanmanız doğru karar vermenize yardımcı olur.\\\",\\n  \\\"previews\\\": [\\n    {\\n      \\\"textPreview\\\": \\\"Mesaj gönderimi yapmadan önce önizleme seçeneğini kullanmanız doğru karar vermenize yardımcı olur.\\\",\\n      \\\"messageCount\\\": 2,\\n      \\\"charactersRemaining\\\": 36,\\n      \\\"configuration\\\": {}\\n    },\\n    {\\n      \\\"textPreview\\\": \\\"Mesaj gönderimi yapmadan önce önizleme seçeneğini kullanmanız doğru karar vermenize yardımcı olur.\\\",\\n      \\\"messageCount\\\": 1,\\n      \\\"charactersRemaining\\\": 57,\\n      \\\"configuration\\\": {\\n        \\\"language\\\": {\\n          \\\"languageCode\\\": \\\"TR\\\"\\n        }\\n      }\\n    }\\n  ]\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\nResponse model is formatted like this:\n* **Original text** - text entered as parameter when method was called\n * **Preview 1** - scenario in which no configuration is applied\n * **Preview 2** - scenario with desired language configuration applied\n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"Both previews are returned in the same response, side by side, so you can easily compare your sending options and choose the best solution for that particular message.\",\n  \"title\": \"Compare your previews!\"\n}\n[/block]\nThe first preview shows what would happen if the message was sent with no configuration whatsoever. Characters would be interpreted as Unicode which would use up 2 message parts and bring the remaining number of remaining characters to 36. Other than that, the message will look the same. \n\nIn this case you would want to use `languageCode` to instruct the system to use the correct alphabet and by doing so bring the message count to 1. This is where the second preview of this example comes in handy. It shows you **exactly what configuration settings to use** when sending [advanced message](/docs/language).\n\n```\n\"language\": {\n    \"languageCode\": \"TR\"\n }\n```\n\nNote that by configuring the `languageCode` option, `charactersRemaining` expand significantly. This gives you the ability to send a significantly longer message.   \n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Transliteration\"\n}\n[/block]\nIf the message language is not supported by National Language Identifier (NLI), transliteration is another option to send messages. Since transliteration is a technique that replaces the original special characters, having an output message preview makes a lot of sense.\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Info\",\n  \"body\": \"Learn how to send messages with transliteration: [SMS transliteration](/docs/transliteration)\"\n}\n[/block]\nLet's examine an example with the message in Greek with `transliteration` option\n\n##Request\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"POST /sms/1/preview HTTP/1.1\\nHost: api.infobip.com\\nAuthorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==\\nContent-Type: application/json\\n\\n{\\n    \\\"text\\\": \\\"Ως Μεγαρικό ψήφισμα είναι γνωστή η απόφαση της Εκκλησίας του δήμου των Αθηναίων (πιθανόν γύρω στο 433/2 π.Χ.) να επιβάλει αυστηρό και καθολικό εμπάργκο στα\\\",\\n    \\\"transliteration\\\": \\\"GREEK\\\"\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n##Response\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"originalText\\\": \\\"Ως Μεγαρικό ψήφισμα είναι γνωστή η απόφαση της Εκκλησίας του δήμου των Αθηναίων (πιθανόν γύρω στο 433/2 π.Χ.) να επιβάλει αυστηρό και καθολικό εμπάργκο στα\\\",\\n  \\\"previews\\\": [\\n    {\\n      \\\"textPreview\\\": \\\"Ως Μεγαρικό ψήφισμα είναι γνωστή η απόφαση της Εκκλησίας του δήμου των Αθηναίων (πιθανόν γύρω στο 433/2 π.Χ.) να επιβάλει αυστηρό και καθολικό εμπάργκο στα\\\",\\n      \\\"messageCount\\\": 3,\\n      \\\"charactersRemaining\\\": 46,\\n      \\\"configuration\\\": {}\\n    },\\n    {\\n      \\\"textPreview\\\": \\\"ΩΣ MEΓAPIKO ΨHΦIΣMA EINAI ΓNΩΣTH H AΠOΦAΣH THΣ EKKΛHΣIAΣ TOY ΔHMOY TΩN AΘHNAIΩN (ΠIΘANON ΓYPΩ ΣTO 433/2 Π.X.) NA EΠIBAΛEI AYΣTHPO KAI KAΘOΛIKO EMΠAPΓKO ΣTA\\\",\\n      \\\"messageCount\\\": 1,\\n      \\\"charactersRemaining\\\": 5,\\n      \\\"configuration\\\": {\\n        \\\"transliteration\\\": \\\"GREEK\\\"\\n      }\\n    }\\n  ]\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\nResponse model is formatted like this:\n* **Original text** - text entered as parameter when method was called\n * **Preview 1** - scenario in which no configuration is applied\n * **Preview 2** - scenario with desired transliteration configuration applied\n\nThis is a great example where you can examine how unsupported characters were replaced with similar charters included in the default alphabet. The difference is more obvious when you compare `messageCount`. The default message would cost 3 messages per recipient, while transliteration will bring the message count to 1 with 5 characters to spare.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Sending language and transliteration messages\"\n}\n[/block]\nEach preview object shows the `configuration` you should use when composing an API request to send a message if you want to get the result as seen in the `textPreview`\n\nIn the transliteration example a configuration can look like this\n```\n\"transliteration\": \"GREEK\"\n```\nand you can use it like it's shown in [this example](/docs/transliteration).\n\nFor NLI, the suggested configuration might be\n```\n\"language\": {\n    \"languageCode\": \"TR\"\n }\n```\nin this case you will use it like it's shown in [this example](/docs/language).\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"Warning!\",\n  \"body\": \"Even though the preview engine relies on the same business logic as sending actual messages, we cannot completely guarantee that the message received by the recipient will look exactly like the message in the preview, since some networks may not support the language feature or handle it differently.\"\n}\n[/block]","excerpt":"This method allows you to preview SMS messages before sending them. Discover the message length, number of message parts, language, and transliteration output.","slug":"sms-preview","type":"basic","title":"SMS preview"}

SMS preview

This method allows you to preview SMS messages before sending them. Discover the message length, number of message parts, language, and transliteration output.

Sending an SMS message seems simple enough until you get unexpected results which can be caused by various reasons. Just a single unsupported character can significantly reduce the total number of available characters per message which can cause a message to be split into two or even more messages, significantly increasing the cost of sending messages. Things get even trickier when messages must be sent in different languages and **language **and **transliteration **options are introduced. [block:callout] { "type": "info", "body": "To avoid unpleasant surprises, use this method to preview messages before sending them.", "title": "Note" } [/block] The preview method can provide you with the following information: * `originalText` - original text that was supplied for preview * `textPreview` - preview of the text as it should appear on the recipient's device * `messageCount` - number of messages required to deliver `textPreview` * `charactersRemaining` - number of remaining characters before `messageCount` increase * `configuration` - configuration setup that should be included in advanced SMS in order to deliver `textPreview` message [block:api-header] { "type": "post", "title": "Message count and remaining characters" } [/block] Use this method to see how many characters are left 'unspent' in the message and if the message fits in one or more messages. ##Request [block:code] { "codes": [ { "code": "POST /sms/1/preview HTTP/1.1\nHost: api.infobip.com\nAuthorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==\nContent-Type: application/json\n\n{\n \"text\": \"Let's see how many characters will remain unused in this message.\"\n}", "language": "json" } ] } [/block] ##Response [block:code] { "codes": [ { "code": "{\n \"originalText\": \"Let's see how many characters will remain unused in this message.\",\n \"previews\": [\n {\n \"textPreview\": \"Let's see how many characters will remain unused in this message.\",\n \"messageCount\": 1,\n \"charactersRemaining\": 95,\n \"configuration\": {}\n }\n ]\n}", "language": "json" } ] } [/block] The response contains the original text (sent text) and one preview which showcases a message received by the recipient without any configuration. In this case, the text will fit in one message and there will be 95 characters left. No special configuration is needed if your goal is to deliver the message as seen in `textPreview`. You can use 'simple' or 'advanced' 'send SMS' methods to send this message. [block:api-header] { "type": "post", "title": "Message language" } [/block] By introducing language code we can preview a message displayed using selected alphabet. In this example we will request a message preview for Turkish language by introducing the `languageCode` parameter. [block:callout] { "type": "info", "title": "Info", "body": "Sending messages in a specific language is supported in advanced SMS method. Find more information about supported languages and language codes: [SMS language](/docs/language)" } [/block] ##Request [block:code] { "codes": [ { "code": "POST /sms/1/preview HTTP/1.1\nHost: api.infobip.com\nAuthorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==\nContent-Type: application/json\n\n{\n \"text\": \"Mesaj gönderimi yapmadan önce önizleme seçeneğini kullanmanız doğru karar vermenize yardımcı olur.\",\n \"languageCode\": \"TR\"\n}", "language": "json" } ] } [/block] ##Response [block:code] { "codes": [ { "code": "{\n \"originalText\": \"Mesaj gönderimi yapmadan önce önizleme seçeneğini kullanmanız doğru karar vermenize yardımcı olur.\",\n \"previews\": [\n {\n \"textPreview\": \"Mesaj gönderimi yapmadan önce önizleme seçeneğini kullanmanız doğru karar vermenize yardımcı olur.\",\n \"messageCount\": 2,\n \"charactersRemaining\": 36,\n \"configuration\": {}\n },\n {\n \"textPreview\": \"Mesaj gönderimi yapmadan önce önizleme seçeneğini kullanmanız doğru karar vermenize yardımcı olur.\",\n \"messageCount\": 1,\n \"charactersRemaining\": 57,\n \"configuration\": {\n \"language\": {\n \"languageCode\": \"TR\"\n }\n }\n }\n ]\n}", "language": "json" } ] } [/block] Response model is formatted like this: * **Original text** - text entered as parameter when method was called * **Preview 1** - scenario in which no configuration is applied * **Preview 2** - scenario with desired language configuration applied [block:callout] { "type": "info", "body": "Both previews are returned in the same response, side by side, so you can easily compare your sending options and choose the best solution for that particular message.", "title": "Compare your previews!" } [/block] The first preview shows what would happen if the message was sent with no configuration whatsoever. Characters would be interpreted as Unicode which would use up 2 message parts and bring the remaining number of remaining characters to 36. Other than that, the message will look the same. In this case you would want to use `languageCode` to instruct the system to use the correct alphabet and by doing so bring the message count to 1. This is where the second preview of this example comes in handy. It shows you **exactly what configuration settings to use** when sending [advanced message](/docs/language). ``` "language": { "languageCode": "TR" } ``` Note that by configuring the `languageCode` option, `charactersRemaining` expand significantly. This gives you the ability to send a significantly longer message. [block:api-header] { "type": "basic", "title": "Transliteration" } [/block] If the message language is not supported by National Language Identifier (NLI), transliteration is another option to send messages. Since transliteration is a technique that replaces the original special characters, having an output message preview makes a lot of sense. [block:callout] { "type": "info", "title": "Info", "body": "Learn how to send messages with transliteration: [SMS transliteration](/docs/transliteration)" } [/block] Let's examine an example with the message in Greek with `transliteration` option ##Request [block:code] { "codes": [ { "code": "POST /sms/1/preview HTTP/1.1\nHost: api.infobip.com\nAuthorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==\nContent-Type: application/json\n\n{\n \"text\": \"Ως Μεγαρικό ψήφισμα είναι γνωστή η απόφαση της Εκκλησίας του δήμου των Αθηναίων (πιθανόν γύρω στο 433/2 π.Χ.) να επιβάλει αυστηρό και καθολικό εμπάργκο στα\",\n \"transliteration\": \"GREEK\"\n}", "language": "json" } ] } [/block] ##Response [block:code] { "codes": [ { "code": "{\n \"originalText\": \"Ως Μεγαρικό ψήφισμα είναι γνωστή η απόφαση της Εκκλησίας του δήμου των Αθηναίων (πιθανόν γύρω στο 433/2 π.Χ.) να επιβάλει αυστηρό και καθολικό εμπάργκο στα\",\n \"previews\": [\n {\n \"textPreview\": \"Ως Μεγαρικό ψήφισμα είναι γνωστή η απόφαση της Εκκλησίας του δήμου των Αθηναίων (πιθανόν γύρω στο 433/2 π.Χ.) να επιβάλει αυστηρό και καθολικό εμπάργκο στα\",\n \"messageCount\": 3,\n \"charactersRemaining\": 46,\n \"configuration\": {}\n },\n {\n \"textPreview\": \"ΩΣ MEΓAPIKO ΨHΦIΣMA EINAI ΓNΩΣTH H AΠOΦAΣH THΣ EKKΛHΣIAΣ TOY ΔHMOY TΩN AΘHNAIΩN (ΠIΘANON ΓYPΩ ΣTO 433/2 Π.X.) NA EΠIBAΛEI AYΣTHPO KAI KAΘOΛIKO EMΠAPΓKO ΣTA\",\n \"messageCount\": 1,\n \"charactersRemaining\": 5,\n \"configuration\": {\n \"transliteration\": \"GREEK\"\n }\n }\n ]\n}", "language": "json" } ] } [/block] Response model is formatted like this: * **Original text** - text entered as parameter when method was called * **Preview 1** - scenario in which no configuration is applied * **Preview 2** - scenario with desired transliteration configuration applied This is a great example where you can examine how unsupported characters were replaced with similar charters included in the default alphabet. The difference is more obvious when you compare `messageCount`. The default message would cost 3 messages per recipient, while transliteration will bring the message count to 1 with 5 characters to spare. [block:api-header] { "type": "basic", "title": "Sending language and transliteration messages" } [/block] Each preview object shows the `configuration` you should use when composing an API request to send a message if you want to get the result as seen in the `textPreview` In the transliteration example a configuration can look like this ``` "transliteration": "GREEK" ``` and you can use it like it's shown in [this example](/docs/transliteration). For NLI, the suggested configuration might be ``` "language": { "languageCode": "TR" } ``` in this case you will use it like it's shown in [this example](/docs/language). [block:callout] { "type": "warning", "title": "Warning!", "body": "Even though the preview engine relies on the same business logic as sending actual messages, we cannot completely guarantee that the message received by the recipient will look exactly like the message in the preview, since some networks may not support the language feature or handle it differently." } [/block]