![]() |
VOOZH | about |
dotnet add package CM.Text --version 2.12.0
NuGet\Install-Package CM.Text -Version 2.12.0
<PackageReference Include="CM.Text" Version="2.12.0" />
<PackageVersion Include="CM.Text" Version="2.12.0" />Directory.Packages.props
<PackageReference Include="CM.Text" />Project file
paket add CM.Text --version 2.12.0
#r "nuget: CM.Text, 2.12.0"
#:package CM.Text@2.12.0
#addin nuget:?package=CM.Text&version=2.12.0Install as a Cake Addin
#tool nuget:?package=CM.Text&version=2.12.0Install as a Cake Tool
👁 .NET build & tests
👁 NuGet Version
👁 NuGet downloads
A software development kit to provide ways to interact with CM.com's Text service. API's used:
Using your unique ApiKey (or product token) which authorizes you on the CM platform.
Always keep this key secret!
The product token can be found in the Channels application on the platform, under the Gateway section.
var client = new TextClient(new Guid(ConfigurationManager.AppSettings["ApiKey"]));
By calling SendMessageAsync and providing message text, sender name, recipient phone number(s) and a reference (optional).
var result = await client.SendMessageAsync("Message_Text", "Sender_Name", new List<string> { "Recipient_PhoneNumber" }, "Your_Reference").ConfigureAwait(false);
SendMessageAsync returns an object of type TextClientResult, example:
{
"statusMessage": "Created 1 message(s)",
"statusCode": 201,
"details": [
{
"reference": "Example_Reference",
"status": "Accepted",
"to": "Example_PhoneNumber",
"parts": 1,
"details": null
},
{
"reference": "Example_Reference2",
"status": "Rejected",
"to": "Example_PhoneNumber2",
"parts": 0,
"details": "A body without content was found"
}
]
}
By using the MessageBuilder it is possible to create images with media for channels such as WhatsApp and RCS
var apiKey = new Guid(ConfigurationManager.AppSettings["ApiKey"]);
var client = new TextClient(apiKey);
var builder = new MessageBuilder("Message Text", "Sender_name", "Recipient_PhoneNumber");
builder
.WithAllowedChannels(Channel.WhatsApp)
.WithRichMessage(
new MediaMessage(
"cm.com",
"https://avatars3.githubusercontent.com/u/8234794?s=200&v=4",
"image/png"
)
);
var message = builder.Build();
var result = await client.SendMessageAsync(message);
For all possible status codes, please reference the TextClientStatusCode enum.
By using the MessageBuilder it is possible to create template messages. Please note that this is WhatsApp only and your template needs to be approved before sending.
For more info please check our documentation: https://www.cm.com/en-en/app/docs/api/business-messaging-api/1.0/index#whatsapp-template-message
var apiKey = new Guid(ConfigurationManager.AppSettings["ApiKey"]);
var client = new TextClient(apiKey);
var builder = new MessageBuilder("Message Text", "Sender_name", "Recipient_PhoneNumber");
builder
.WithAllowedChannels(Channel.WhatsApp)
.WithTemplate(new TemplateMessage() {
Content = new TemplateMessageContent() {
Whatsapp = new WhatsappTemplate() {
Name = "template-name",
Namespace = "the-namespace-of-template",
Language = new Language() {
Code = "en",
Policy = "deterministic"
},
Components = new TemplateComponents[] {
new TemplateComponents() {
Type = "body",
ComponentParameters = new ComponentParameters[] {
new ComponentParameters() {
Type = "text",
Text = "firstname"
}
}
},
}
}
}
});
var message = builder.Build();
var result = await client.SendMessageAsync(message);
It is also possible to send a rich template with an image!
var apiKey = new Guid(ConfigurationManager.AppSettings["ApiKey"]);
var client = new TextClient(apiKey);
var builder = new MessageBuilder("Message Text", "Sender_name", "Recipient_PhoneNumber");
builder
.WithAllowedChannels(Channel.WhatsApp)
.WithTemplate(new TemplateMessage() {
Content = new TemplateMessageContent() {
Whatsapp = new WhatsappTemplate() {
Name = "template-name",
Namespace = "the-namespace-of-template",
Language = new Language() {
Code = "en",
Policy = "deterministic"
},
Components = new TemplateComponents[] {
new TemplateComponents() {
Type = "header",
ComponentParameters = new ComponentParameters[] {
new ComponentParameters() {
Type = "image",
Media = new MediaContent() {
MediaName = "cm.com",
MediaUri = "https://avatars3.githubusercontent.com/u/8234794?s=200&v=4"
}
}
}
},
new TemplateComponents() {
Type = "body",
ComponentParameters = new ComponentParameters[] {
new ComponentParameters() {
Type = "text",
Text = "firstname"
}
}
},
}
}
}
});
var message = builder.Build();
var result = await client.SendMessageAsync(message);
It is also possible to send a rich template with an currency and an date! please note that the timezone is in UTC format
var apiKey = new Guid(ConfigurationManager.AppSettings["ApiKey"]);
var client = new TextClient(apiKey);
var builder = new MessageBuilder("Message Text", "Sender_name", "Recipient_PhoneNumber");
builder
.WithAllowedChannels(Channel.WhatsApp)
.WithTemplate(new TemplateMessage() {
Content = new TemplateMessageContent() {
Whatsapp = new WhatsappTemplate() {
Name = "template-name",
Namespace = "the-namespace-of-template",
Language = new Language()
{
Code = "en",
Policy = "deterministic"
},
Components = new TemplateComponents[] {
new TemplateComponents() {
Type = "header",
ComponentParameters = new ComponentParameters[] {
new ComponentParameters() {
Type = "image",
Media = new MediaContent() {
MediaName = "cm.com",
MediaUri = "https://avatars3.githubusercontent.com/u/8234794?s=200&v=4"
},
}
}
},
new TemplateComponents()
{
Type = "body",
ComponentParameters = new ComponentParameters[]
{
new ComponentParameters()
{
Type = "currency",
Currency = new TemplateCurrency()
{
FallbackValue = "$100.99",
Amount = 100990,
CurrencyCode = "USD"
}
},
new ComponentParameters()
{
Type = "date_time",
DateTime = new TemplateDateTime(DateTime.Now)
}
}}
}
}
}
});
var message = builder.Build();
var result = await client.SendMessageAsync(message);
Interactive templates allows you to send templates that include buttons. For more info please visit https://www.cm.com/app/docs/en/api/business-messaging-api/1.0/index#/whatsapp-template-message
var apiKey = new Guid(ConfigurationManager.AppSettings["ApiKey"]);
var client = new TextClient(apiKey);
var builder = new MessageBuilder("Message Text", "Sender_name", "Recipient_PhoneNumber");
builder.WithAllowedChannels(Channel.WhatsApp).WithTemplate(new TemplateMessage() {
Content = new TemplateMessageContent() {
Whatsapp = new WhatsappTemplate() {
Name = "Template name",
Namespace = "whatsapp template id",
Language = new Language() {
Code = "en",
Policy = "deterministic"
},
Components = new TemplateComponents[] {
new TemplateComponents() {
Type = "body",
ComponentParameters = new ComponentParameters[] {
new ComponentParameters() {
Type = "text",
Text = "your message here"
}
}
},
new TemplateComponents() {
Type = "button",
SubType = "quick_reply",
Index = 0,
ComponentParameters = new ComponentParameters[] {
new ComponentParameters() {
Type = "payload",
Payload = "developer defined payload"
}
}
}
}
}
}
});
var message = builder.Build();
var result = await client.SendMessageAsync(message);
It is now possible to send an apple pay request only possible in Apple Business Chat
var apiKey = new Guid(ConfigurationManager.AppSettings["ApiKey"]);
var client = new TextClient(apiKey);
var builder = new MessageBuilder("Message Text", "Sender_name", "Recipient_PhoneNumber");
builder
.WithAllowedChannels(Channel.iMessage)
.WithApplePay(new ApplePayRequest()
{
ApplePayConfiguration = new ApplePayConfiguration()
{
Total = 1,
RecipientCountryCode = "recipient-country-code",
CurrencyCode = "currency-code",
Description = "product-description",
RecipientEmail = "recipient-email",
languageCountryCode = "language-country-code",
OrderReference = "unique-order-guid",
MerchantName = "merchant-name",
LineItems = new LineItem[]
{
new LineItem()
{
Amount = 1,
Label = "product-name",
Type = "final-or-pending"
},
}
}
});
var message = builder.Build();
var result = await client.SendMessageAsync(message);
It is now possible to send list messages and reply buttons without using templates only supported in WhatsApp
var apiKey = new Guid(ConfigurationManager.AppSettings["ApiKey"]);
var client = new TextClient(apiKey);
var builder = new MessageBuilder("Message Text", "Sender_name", "Recipient_PhoneNumber");
builder.WithAllowedChannels(Channel.WhatsApp).WithInteractive(new CM.Text.BusinessMessaging.Model.MultiChannel.WhatsAppInteractiveMessage()
{
whatsAppInteractiveContent = new CM.Text.BusinessMessaging.Model.MultiChannel.WhatsAppInteractiveContent()
{
Type = "list",
Header = new CM.Text.BusinessMessaging.Model.MultiChannel.InteractiveHeader()
{
Type = "text",
Text = "List message example"
},
Body = new CM.Text.BusinessMessaging.Model.MultiChannel.InteractiveBody()
{
Text = "checkout our list message demo"
},
Action = new CM.Text.BusinessMessaging.Model.MultiChannel.InteractiveAction()
{
Button = "button text",
Sections = new CM.Text.BusinessMessaging.Model.MultiChannel.InteractiveSection[]
{
new CM.Text.BusinessMessaging.Model.MultiChannel.InteractiveSection()
{
Title = "Select an option",
Rows = new CM.Text.BusinessMessaging.Model.MultiChannel.Rows[]
{
new CM.Text.BusinessMessaging.Model.MultiChannel.Rows()
{
Id = "unique Id",
Title = "unique title1",
Description = "description text"
},
new CM.Text.BusinessMessaging.Model.MultiChannel.Rows()
{
Id = "unique Id2",
Title = "unique title2",
Description = "description text"
},
}
}
}
},
Footer = new CM.Text.BusinessMessaging.Model.MultiChannel.InteractiveFooter()
{
Text = "footer text"
}
}
});
var message = builder.Build();
var result = await client.SendMessageAsync(message);
Only with Reply buttons you can send media like image,video or document see following example.
var apiKey = new Guid(ConfigurationManager.AppSettings["ApiKey"]);
var client = new TextClient(apiKey);
var builder = new MessageBuilder("Message Text", "Sender_name", "Recipient_PhoneNumber");
builder.WithAllowedChannels(Channel.WhatsApp).WithInteractive(new CM.Text.BusinessMessaging.Model.MultiChannel.WhatsAppInteractiveMessage()
{
whatsAppInteractiveContent = new CM.Text.BusinessMessaging.Model.MultiChannel.WhatsAppInteractiveContent()
{
Type = "button",
Header = new CM.Text.BusinessMessaging.Model.MultiChannel.InteractiveHeader()
{
Type = "image",
Media = new CM.Text.BusinessMessaging.Model.MultiChannel.MediaContent()
{
MediaUri = "https://www.cm.com/cdn/web/blog/content/logo-cmcom.png"
}
},
Body = new CM.Text.BusinessMessaging.Model.MultiChannel.InteractiveBody()
{
Text = "checkout our reply message demo"
},
Action = new CM.Text.BusinessMessaging.Model.MultiChannel.InteractiveAction()
{
Buttons = new CM.Text.BusinessMessaging.Model.MultiChannel.InteractiveButton[]
{
new CM.Text.BusinessMessaging.Model.MultiChannel.InteractiveButton()
{
Type = "reply",
Reply = new CM.Text.BusinessMessaging.Model.MultiChannel.ReplyMessage()
{
Id = "unique-postback-id1",
Title = "First Button"
}
},
new CM.Text.BusinessMessaging.Model.MultiChannel.InteractiveButton()
{
Type = "reply",
Reply = new CM.Text.BusinessMessaging.Model.MultiChannel.ReplyMessage()
{
Id = "unique-postback-id2",
Title = "Second Button "
}
}
}
}
}
});
var message = builder.Build();
var result = await client.SendMessageAsync(message);
Send a simple OTP code
var client = new TextClient(new Guid(ConfigurationManager.AppSettings["ApiKey"]));
var otpBuilder = new OtpRequestBuilder("Sender_name", "Recipient_PhoneNumber");
otpBuilder.WithMessage("Your otp code is {code}.");
var result = await textClient.SendOtpAsync(otpBuilder.Build());
Verify the response code
var verifyResult = client.VerifyOtp("OTP-ID", "code");
bool isValid = verifyResult.Verified;
For more advanced scenarios see also https://developers.cm.com/identity/docs/one-time-password-create
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 3 NuGet packages that depend on CM.Text:
| Package | Downloads |
|---|---|
|
GeeksCoreLibrary
Geeks Core Library |
|
|
Corprio.Communication
The Corprio.Communication project includes functions for using external communication services such as email and SMS. |
|
|
InvistaCoreLibrary
Geeks Core Library |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.12.0 | 93,078 | 8/1/2025 |
| 2.11.0 | 284,133 | 1/13/2025 |
| 2.10.0 | 9,104 | 12/30/2024 |
| 2.9.0 | 123,690 | 6/20/2024 |
| 2.7.0 | 303,494 | 7/6/2023 |
| 2.6.0 | 87,636 | 12/7/2022 |
| 2.5.2 | 21,141 | 10/14/2022 |
| 2.5.1 | 9,425 | 10/12/2022 |
| 2.5.0 | 41,590 | 6/17/2022 |
| 2.4.1 | 36,328 | 2/1/2022 |
| 2.4.0 | 9,098 | 1/31/2022 |
| 2.3.0 | 203,992 | 10/27/2021 |
| 2.2.1 | 16,404 | 9/10/2021 |
| 2.2.0 | 8,945 | 9/9/2021 |
| 2.1.0 | 10,078 | 7/8/2021 |
| 2.0.6 | 9,097 | 7/8/2021 |
| 2.0.5 | 10,582 | 5/31/2021 |
| 2.0.4 | 18,242 | 5/20/2021 |
| 2.0.3 | 10,380 | 4/14/2021 |
| 2.0.2 | 17,812 | 1/5/2021 |
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [2.12.0] - 2025-08-01
### Updated
- Updated dependencies and .NET version
## [2.11.1] - 2025-01-31
### Added
- Derived type declarations on `SuggestionBase`
## [2.11.0] - 2025-01-10
### Added
- Context.MessageId on RichMessages supporting WhatsApp for referencing a previous message
## [2.10.0] - 2024-12-30
### Added
- Polymorphic type discriminators on IRichMessage for deserialization
### Changed
- Updated `System.Text.Json` to 8.0.5 fixing a [high impact security vulnerability](https://github.com/advisories/GHSA-hh2w-p6rv-4g7w)
## [2.9.0] - 2024-06-20
### Changed
- New global messaging endpoint
## [2.8.0] - 2024-01-08
### Added
- Implementing OTP Request and verify
## [2.7.0] - 2023-06-26
### Added
- Whatsapp Multi-Product Template Messages
## [2.6.0] - 2022-12-07
### Added
- System.Text.Json, replaces Newtsonsoft, possibly breaking
- Add Telegram as tag for the project
- Multi target to .NET 7 and use .NET 7 included System.Text.Json
### Changed
- Enable "Treat Warnings as Errors" to adhere to code guidelines
- Give internal response body messagerrorcode the correct type
- Some internal refactoring
- Changed PackageIconUrl > PackageIcon and added icon manually as it PackageIconUrl was deprecated
- Change RichContent interface to support derived types
### Removed
- Newtsonsoft.Json dependency
## [2.5.2] - 2022-10-14
- Enable nupkg generation in project
## [2.5.1] - 2022-10-12
- Upped Newtonsoft.Json
## [2.5.0] - 2022-06-17
- Add Telegram
## [2.4.1] - 2022-02-01
- Fix support for a custom end point URI in second SendMessage method
## [2.4.0] - 2022-01-31
- Fix failure on body.type set to null
- Add support for a custom end point URI
## [2.3.0] - 2021-10-27
- Add TextClientFactory
## [2.2.1] - 2021-09-10
- Add support for reply buttons with media
## [2.2.0] - 2021-09-09
- Add support for interactive whatsapp messages
## [2.1.0] - 2021-07-08
- Ignore HybridAppKey when null instead of empty, to support Notifire flow of channel MobilePush
- Add DefaultValueHandling to RichContent property of Message model.
- Add Tag property to TextMessage model used within a rich message.
- Add Suggestions property to TextMessage model used within a rich message.
- Add AppleBusinessChat as channel type, and marked iMessage as obsolete.
## [2.0.6] - 2021-07-06
- Add Instagram
## [2.0.5] - 2021-05-25
- Correct JSON formatting of MediaContent
## [2.0.4] - 2021-05-20
- Added media en description to ReplySuggestion
## [2.0.3] - 2021-04-08
- Add Facebook Messenger and Google Business Messages channel
## [2.0.2] - 2020-12-23
- Add MobilePush channel
## [2.0.1] - 2020-11-23
- Add support for interactive templates
## [2.0.0] - 2020-08-26
- Removed Localizable Params because it is Deprecated by Facebook,
- Also updated the WhatsApp Template Signature based on Facebook spec updates.
## [1.8.0] - 2020-06-24
- Add Twitter support
## [1.7.0] - 2020-02-14
- Able to set validity period. (@GuidoNeele)
- Fixed issue when adding suggestions.
- Resolved typo's in documentation.
## [1.6.1] - 2020-02-14
- Version is equal to 1.7.0, due to not working release flow.
## [1.6.0] - 2020-02-07
- Add Rich templates + ApplePay
## [1.5.2] - 2019-12-04
- Fix WhatsApp template signature (@Michel16867)
## [1.5.0] - 2019-11-01
- Added several RichFeatures.
1. TemplateMessage
2. LocationPushMessage
3. ContactMessage
## [1.4.0] - 2019-03-05
- Fix typo in conversation
## [1.3.0] - 2019-02-26
- Add license information
## [1.2.0] - 2019-02-22
- Add multichannel options
## [1.1.0] - 2019-02-22
- Add option to pass http client to constructor
## [1.0.1] - 2018-11-08
- Initial release