Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add azure communication messages sdk #39167

Merged
merged 24 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
ab09c1a
Add Messages SDK
glorialimicrosoft Jul 26, 2023
d59b73a
Work around the issue with nextLink never empty, add more tests
glorialimicrosoft Jul 26, 2023
bfa0337
Update CHANGELOG.md
glorialimicrosoft Jul 26, 2023
c2d65d4
Update autorest and use Github link for input file
glorialimicrosoft Jul 26, 2023
90bb20a
Update README.md
glorialimicrosoft Jul 26, 2023
20cb30f
dropping the Value suffix on everything but the base class (MessageTe…
glorialimicrosoft Jul 26, 2023
4fef905
change the param name from url to uri, filename to fileName
glorialimicrosoft Jul 26, 2023
dcd80dd
Update CHANGELOG.md
glorialimicrosoft Jul 26, 2023
07357a2
revert accidental check in of RecordedTestMode
glorialimicrosoft Jul 26, 2023
07970fb
sanitize session records
glorialimicrosoft Jul 26, 2023
6246b93
remove unneeded import
glorialimicrosoft Jul 26, 2023
58d97b4
update to 2023-08-24-preview api version
glorialimicrosoft Aug 18, 2023
2c0cc8e
update CommunicationMessagesClientOptions api version to 2023-08-24-p…
glorialimicrosoft Aug 18, 2023
7b66185
re-run live test recording
glorialimicrosoft Aug 18, 2023
d1a4ceb
fix broken link
glorialimicrosoft Aug 23, 2023
bbe654d
use latest swagger
glorialimicrosoft Aug 24, 2023
79287f3
Remove unsupported auth type, add more live tests, and re-run the liv…
glorialimicrosoft Aug 25, 2023
f19c5ab
use the swagger that does not have operation-id response header
glorialimicrosoft Aug 25, 2023
6d1cda4
Take Value suffix off MessageTemplateQuickAction
glorialimicrosoft Aug 28, 2023
6788b14
update sdk to latest
glorialimicrosoft Oct 7, 2023
1e13e97
update the source file to the public azure specs repo
glorialimicrosoft Oct 9, 2023
30c4f8b
fix recording
glorialimicrosoft Oct 9, 2023
47e788e
run "eng\scripts\Export-API.ps1 communication"
glorialimicrosoft Oct 10, 2023
c0a8287
run "eng\scripts\CodeChecks.ps1 -ServiceDirectory communication"
glorialimicrosoft Oct 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions sdk/communication/Azure.Communication.Messages/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Release History

## 1.0.0-beta.1 (2023-08-15)

This is the first Public Preview release of Azure Communication Services for advanced messages. For more information, please see the [README][read_me] and [documentation][documentation].

This is a Public Preview version, so breaking changes are possible in subsequent releases as we improve the product. To provide feedback, please submit an issue in our [Azure SDK for .NET GitHub repo](https://github.com/Azure/azure-sdk-for-net/issues).

<!-- LINKS -->
[read_me]: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/communication/Azure.Communication.Messages/README.md
100 changes: 100 additions & 0 deletions sdk/communication/Azure.Communication.Messages/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Azure Communication Messages client library for .NET

This package contains a C# SDK for Azure Communication Messages Services.

[Source code][source] | [Package (NuGet)][package] | [Product documentation][product_docs]


## Getting started

### Install the package
Install the Azure Communication Messages client library for .NET with [NuGet][nuget]:

```dotnetcli
dotnet add package Azure.Communication.Messages --prerelease
```

### Prerequisites
You need an [Azure subscription][azure_sub] and a [Communication Service Resource][communication_resource_docs] to use this package.

To create a new Communication Service, you can use the [Azure Portal][communication_resource_create_portal], the [Azure PowerShell][communication_resource_create_power_shell], or the [.NET management client library][communication_resource_create_net].

### Key concepts
`NotificationMessagesClient` provides the functionality to send notification messages .

### Using statements
```C#
using Azure.Communication.Messages;
```

### Authenticate the client
#### Connection String
Messages clients can be authenticated using the connection string acquired from an Azure Communication Resource in the [Azure Portal][azure_portal].

```C#
var connectionString = "<connection_string>"; // Find your Communication Services resource in the Azure portal
NotificationMessagesClient notificationMessagesClient = new NotificationMessagesClient(connectionString);
MessageTemplateClient messageTemplateClient = new MessageTemplateClient(connectionString);
```

## Examples
### Send an Notification Message
To send a notification message, call the `SendMessage` or `SendMessageAsync` function from the `NotificationMessagesClient`.

#### Send a text message
```C#
// Create the recipient list, currently only one recipient is supported
var recipient = new List<string> { "<to-phone-number>" };
var options = new SendMessageOptions("<channel-registration-id>", recipient, "Come on everyone, let's go for lunch together.");
SendMessageResult result = await notificationMessagesClient.SendMessageAsync(options);
Console.WriteLine($"Message id: {result.Receipts[0].MessageId}");
```

#### Send a template message
```C#
// Create the recipient list, currently only one recipient is supported
var recipient = new List<string> { "<to-phone-number>" };
string templateName = "sample_template";
string templateLanguage = "en_us";
var messageTemplate = new MessageTemplate(templateName, templateLanguage);
var sendTemplateMessageOptions = new SendMessageOptions(channelRegistrationId, recipientList, messageTemplate);
SendMessageResult result = await notificationMessagesClient.SendMessageAsync(sendTemplateMessageOptions);
Console.WriteLine($"Message id: {result.Receipts[0].MessageId}");
```

#### Send a media message
```C#
// Create the recipient list, currently only one recipient is supported
var recipient = new List<string> { "<to-phone-number>" };
var uri = new Uri("https://aka.ms/acsicon1");
var sendMediaMessageOptions = new SendMessageOptions(channelRegistrationId, recipientList, uri);
SendMessageResult result = await notificationMessagesClient.SendMessageAsync(sendMediaMessageOptions);
Console.WriteLine($"Message id: {result.Receipts[0].MessageId}");
```

### Retrieve templates
To retrieve templates, call the `GetMessages` or `GetMessagesAsync` function from the `MessageTemplateClient`.


```C#
AsyncPageable<MessageTemplateItem> templates = messageTemplateClient.GetTemplatesAsync(channelId);
await foreach (MessageTemplateItem template in templates)
{
Console.WriteLine($"{template.Name}");
}
```

## Troubleshooting
A `RequestFailedException` is thrown as a service response for any unsuccessful requests. The exception contains information about what response code was returned from the service.

## Next steps
- Read more about Messages in Azure Communication Services (Link to be added).
- Read more about how to set up Event Grid subscription for new message and message delivery status (Link to be added).


## Contributing
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit [cla.microsoft.com][cla].

This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For more information see the [Code of Conduct FAQ][coc_faq] or contact [[email protected]][coc_contact] with any additional questions or comments.


Loading
Loading