{"id":19519133,"url":"https://github.com/cmdotcom/text-sdk-java","last_synced_at":"2025-04-26T07:31:07.866Z","repository":{"id":39960163,"uuid":"176910694","full_name":"cmdotcom/text-sdk-java","owner":"cmdotcom","description":"Java SDK to send messages with CM.com","archived":false,"fork":false,"pushed_at":"2024-06-14T22:05:03.000Z","size":124,"stargazers_count":4,"open_issues_count":3,"forks_count":10,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-04-04T09:36:07.288Z","etag":null,"topics":["cm","imessage","java","sdk","sms","telegram","whatsapp"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cmdotcom.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-03-21T09:18:25.000Z","updated_at":"2024-04-23T10:01:23.000Z","dependencies_parsed_at":"2024-01-15T09:53:39.400Z","dependency_job_id":"add3a989-079c-4d4a-be94-6be4158a6d95","html_url":"https://github.com/cmdotcom/text-sdk-java","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmdotcom%2Ftext-sdk-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmdotcom%2Ftext-sdk-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmdotcom%2Ftext-sdk-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmdotcom%2Ftext-sdk-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cmdotcom","download_url":"https://codeload.github.com/cmdotcom/text-sdk-java/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250953348,"owners_count":21513300,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cm","imessage","java","sdk","sms","telegram","whatsapp"],"created_at":"2024-11-11T00:16:29.717Z","updated_at":"2025-04-26T07:31:07.580Z","avatar_url":"https://github.com/cmdotcom.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n## @cmdotcom/text-sdk: A helper library to send messages.\n\nWant to send messages in your Java application? Then you are at the right place.\nIf you want to get all the functionalities, go to: [CM.com API Docs](https://developers.cm.com/messaging)\n\n\n## Installing\nWarning: Namespace has been changed between 1.3 and 2.0\n### Above 2.0\nYou can find our SDK [here](https://mvnrepository.com/artifact/com.cm/text-sdk), or below incase you are using a generic pom.xml.\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.cm\u003c/groupId\u003e\n    \u003cartifactId\u003etext-sdk\u003c/artifactId\u003e\n    \u003cversion\u003e3.0.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n### Version 1.3\nVersion 1.3 is available as JAR under the [1.3 release here](https://github.com/cmdotcom/text-sdk-java/releases/tag/v1.3-snapshot) \u003cbr\u003e\nYou will have to add GSON manually: https://mvnrepository.com/artifact/com.google.code.gson/gson/2.8.5\n\n\n## Instantiate the client\nUse your productToken which authorizes you on the CM platform. Get yours on CM.com\n\n```java\nMessagingClient client = new MessagingClient(\"YourCMProductToken\");\n```\n\n## Send a message\nBy calling `SendTextMessage` and providing message text, sender name, recipient phone number(s).\n\n```java\n   MessagingClient client = new MessagingClient(\"YourProductToken\");\n   client.sendTextMessage(\"Message Text\", \"TestSender\", new String[] {\"00316012345678\"});\n   \n```\n## Sending a message with auto detect encoding\nBy using the `MessageBuilder` it is possible to send messages with auto detect encoding, \n\nIt is possible to let our gateway detect the encoding for you by including the type: auto setting. \nIn case it detects characters that are not part of the GSM character set, the message will be delivered as Unicode.\n\nsee our API docs for more info https://developers.cm.com/messaging/\n\n```java\n MessagingClient client = new MessagingClient(\"YourProductToken\");\n MessageBuilder builder = new MessageBuilder(\"Message Text\", \"auto\",  \"TestSender\", new String[] {\"00316012345678\"});\n      \n      Message message = builder.Build();\n\n      client.sendMessage(message);\n```\n\n## Sending a rich message\nBy using the `MessageBuilder` it is possible to create images with media for channels such as WhatsApp and Viber\n```java\n MessagingClient client = new MessagingClient(\"YourProductToken\");\n\n MessageBuilder builder = new MessageBuilder(\"Message Text\", \"TestSender\", new String[] {\"00316012345678\"});\n\n builder.WithAllowedChannels(new Channel[] {Channel.Viber});\n\n    builder.WithRichMessage(new MediaMessage(\n                \"cm.com\",\n                \"https://avatars3.githubusercontent.com/u/8234794?s=200\u0026v=4\",\n                \"image/png\"));\n\n\n       Message message = builder.Build();\n\n       client.sendMessage(message);\n```\n\n## Get the result\nSending an message returns the response body\n```java\n{\n\t\"details\": \"Created 1 message(s)\",\n\t\"errorCode\": 0,\n\t\"messages\": [{\n\t\t\"to\": \"00316012345678\",\n\t\t\"status\": \"Accepted\",\n\t\t\"reference\": null,\n\t\t\"parts\": 1,\n\t\t\"messageDetails\": null,\n\t\t\"messageErrorCode\": 0\n\t}]\n}\n```\n\n## Whatsapp Templates\nSend WhatsApp template messages using the message builder please take a look at our documentation in the [Whatsapp templates section](https://developers.cm.com/messaging/docs/whatsapp#template)\n```java\n\t\t \nMessagingClient client = new MessagingClient(\"YourProductToken\");\n \n MessageBuilder builder = new MessageBuilder(\"Template Test\", \"CM.COM\", new String[] {\"0031636170815\"});\n\n builder.WithAllowedChannels(new Channel[] {Channel.WhatsApp});       \n           \n\t\tTemplateMessage template = new TemplateMessage();\n          \n        template.Content = new TemplateMessageContent();\n          \n        template.Content.WhatsAppTemplate = new WhatsAppTemplate();\n        template.Content.WhatsAppTemplate.Name = \"template-name\";\n        template.Content.WhatsAppTemplate.Namespace = \"the-namespace-of-template\";\n        template.Content.WhatsAppTemplate.Language =  new TemplateLanguage(\"CountryCode\", \"deterministic\");\n        template.Content.WhatsAppTemplate.LocalizableParams = new LocalizableParam[] {};\n        template.Content.WhatsAppTemplate.Components = new TemplateComponents[] {new TemplateComponents(\"header\", \n        new TemplateParameters[] { new TemplateParameters(\"image\",  new MediaContent(\"cm.com\"\", \n\t\t\t\t\t\t\t\t\"https://avatars3.githubusercontent.com/u/8234794?s=200\u0026v=4\", \n\t\t\t\t\t\t\t\t\"image/png\"))}),\n        new TemplateComponents(\"body\", \n                          new TemplateParameters[] { new TemplateParameters(\"text\",  \"TestMessage\"), \n                          new TemplateParameters(\"text\",  \"Dutch GP\")})};  \n         \n                                   \n\t\tbuilder.WithTemplate(template);\n\n\t\tMessage message = builder.Build();\n          \n\t\tclient.sendMessage(message); \n```\n\n\n## Using the OTP API\nSend an OTP code\n```java\n    MessagingClient client = new MessagingClient(yourProductToken);\n\n    OtpRequest request = new OtpRequestBuilder(senderName, recipientNumber)\n    .withMessage(\"Your OTP code is {code}\")\n    .withChannel(\"sms\")\n    .build();\n\n    OtpResponse result = client.sendOtpRequest(request);\n```\n\nVerify the response code\n```java\n    OtpResponse verifyResult = client.verifyOtpRequest(result.getId(), code);\n    verifyResult.isVerified(); //represents whether the check was code was correct  \n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcmdotcom%2Ftext-sdk-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcmdotcom%2Ftext-sdk-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcmdotcom%2Ftext-sdk-java/lists"}