diff --git a/CHANGELOG.md b/CHANGELOG.md index 53224527..923cf3d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +## [5.46.0](https://github.com/plivo/plivo-dotnet/tree/v5.46.0) (2024-05-20) +**Feature - Adding support for location whatsapp messages** +- Added new param `location` to [send message API](https://www.plivo.com/docs/sms/api/message#send-a-message) to support location `whatsapp` messages +- Added new param `location` in templates to support location based templated messages + ## [5.45.0](https://github.com/plivo/plivo-dotnet/tree/v5.45.0) (2024-05-07) **Feature - Adding support for interactive whatsapp messages** - Added new param `interactive` to [send message API](https://www.plivo.com/docs/sms/api/message#send-a-message) to support interactive `whatsapp` messages diff --git a/README.md b/README.md index 79ad7e6a..6fe56df0 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ You can install this SDK either by referencing the .dll file or using NuGet. Use the following line to install the latest SDK using the NuGet CLI. ``` -PM> Install-Package Plivo -Version 5.45.0 +PM> Install-Package Plivo -Version 5.46.0 ``` You can also use the .NET CLI to install this package as follows @@ -119,6 +119,478 @@ This generates the following XML: ``` + +## WhatsApp Messaging +Plivo's WhatsApp API allows you to send different types of messages over WhatsApp, including templated messages, free form messages and interactive messages. Below are some examples on how to use the Plivo Go SDK to send these types of messages. + +### Templated Messages +Templated messages are a crucial to your WhatsApp messaging experience, as businesses can only initiate WhatsApp conversation with their customers using templated messages. + +WhatsApp templates support 4 components: `header` , `body`, `footer` and `button`. At the point of sending messages, the template object you see in the code acts as a way to pass the dynamic values within these components. `header` can accomodate `text` or `media` (images, video, documents) content. `body` can accomodate text content. `button` can support dynamic values in a `url` button or to specify a developer-defined payload which will be returned when the WhatsApp user clicks on the `quick_reply` button. `footer` cannot have any dynamic variables. + +Example 1: +```csharp +using System; +using System.Collections.Generic; +using Plivo; + +namespace PlivoExamples +{ + internal class Program + { + public static void Main(string[] args) + { + var api = new PlivoApi("", ""); + + string jsonString = "{\"name\":\"plivo_movieticket_confirmation\",\"language\":\"en_US\",\"components\":[{\"type\":\"header\",\"parameters\":[{\"type\":\"media\",\"media\":\"https://media.geeksforgeeks.org/wp-content/uploads/20190712220639/ybearoutput-300x225.png\"}]},{\"type\":\"body\",\"parameters\":[{\"type\":\"text\",\"text\":\"Harry Potter\"},{\"type\":\"text\",\"text\":\"06:00 PM\"},{\"type\":\"text\",\"text\":\"Bengaluru\"},{\"type\":\"text\",\"text\":\"2\"}]}]}"; + + var response = api.Message.Create( + src: "14156667778", + dst: "14156667777", + type: "whatsapp", + template_json_string: jsonString); + Console.WriteLine(response); + } + } +} +``` +Example 2: +```csharp +using System; +using System.Collections.Generic; +using Plivo; +using Plivo.Resource.Message; + +namespace PlivoExamples +{ + internal class Program + { + public static void Main(string[] args) + { + var api = new PlivoApi("", ""); + + var template = new Template + { + Name = "plivo_movieticket_confirmation", + Language = "en_US", + Components = new List + { + new Component + { + Type = "header", + Parameters = new List + { + new Parameter + { + Type = "media", + Media = "https://media.geeksforgeeks.org/wp-content/uploads/20190712220639/ybearoutput-300x225.png" + } + } + }, + new Component + { + Type = "body", + Parameters = new List + { + new Parameter + { + Type = "text", + Text = "Harry Potter" + }, + new Parameter + { + Type = "text", + Text = "06:00 PM" + }, + new Parameter + { + Type = "text", + Text = "Bengaluru" + }, + new Parameter + { + Type = "text", + Text = "2" + } + } + } + } + }; + + var response = api.Message.Create( + src: "14156667778", + dst: "14156667777", + type: "whatsapp", + template: template); + Console.WriteLine(response); + } + } +} +``` + +### Free Form Messages +Non-templated or Free Form WhatsApp messages can be sent as a reply to a user-initiated conversation (Service conversation) or if there is an existing ongoing conversation created previously by sending a templated WhatsApp message. + +#### Free Form Text Message +Example: +```csharp +using System; +using System.Collections.Generic; +using Plivo; + +namespace PlivoExamples +{ + internal class Program + { + public static void Main(string[] args) + { + var api = new PlivoApi("",""); + var response = api.Message.Create( + src: "+14151112221", + dst: "+14151112222", + type: "whatsapp", + text: "Hello, this is sample text", + url: "https://.com/wa_status/"); + Console.WriteLine(response); + } + } +} +``` + +#### Free Form Media Message +Example: +```csharp +using System; +using System.Collections.Generic; +using Plivo; + +namespace PlivoExamples +{ + internal class Program + { + public static void Main(string[] args) + { + var api = new PlivoApi("",""); + var response = api.Message.Create( + src: "+14151112221", + dst: "+14151112222", + type: "whatsapp", + text: "Hello, this is sample text", + media_urls: new string[] { "https://sample-videos.com/img/Sample-png-image-1mb.png"}, + url: "https://.com/wa_status/"); + Console.WriteLine(response); + } + } +} +``` + +### Interactive Messages +This guide shows how to send non-templated interactive messages to recipients using Plivo’s APIs. + +#### Quick Reply Buttons +Quick reply buttons allow customers to quickly respond to your message with predefined options. + +Example: +```csharp +using System; +using System.Collections.Generic; +using Plivo; +using Plivo.Resource.Message; + +namespace PlivoExamples +{ + internal class Program + { + public static void Main(string[] args) + { + var api = new PlivoApi("", ""); + + var interactive = new Interactive + { + Type = "button", + Header = new Header + { + Type = "media", + Media = "https://media.geeksforgeeks.org/wp-content/uploads/20190712220639/ybearoutput-300x225.png" + }, + Body = new Body + { + Text = "Make your selection" + }, + Action = new MessageAction + { + Buttons = new List