From a6094c7ef2fe75ba0bbb69f0664a536e4986a70a Mon Sep 17 00:00:00 2001 From: Gabriel Odero Date: Sat, 4 Nov 2023 18:20:30 +0300 Subject: [PATCH] Flow message support --- .../Controllers/HomeController.cs | 109 ++++++++++++++++ .../ViewModel/SendFlowMessageViewModel.cs | 17 +++ .../Views/Home/SendWhatsAppFlowMessage.cshtml | 70 +++++++++++ .../Home/SendWhatsAppTemplateMessage.cshtml | 3 +- .../WhatsAppBusinessCloudAPI.Web.csproj | 2 +- .../Interfaces/IWhatsAppBusinessClient.cs | 38 +++++- .../Messages/Requests/FlowMessageRequest.cs | 117 ++++++++++++++++++ .../Requests/FlowTemplateMessageRequest.cs | 74 +++++++++++ .../Response/FlowMessageResponse.cs | 19 +++ .../WhatsAppBusinessClient.cs | 87 ++++++++++++- .../WhatsappBusiness.CloudApi.csproj | 6 +- 11 files changed, 535 insertions(+), 7 deletions(-) create mode 100644 Samples/WhatsAppBusinessCloudAPI.Web/ViewModel/SendFlowMessageViewModel.cs create mode 100644 Samples/WhatsAppBusinessCloudAPI.Web/Views/Home/SendWhatsAppFlowMessage.cshtml create mode 100644 WhatsappBusiness.CloudApi/Messages/Requests/FlowMessageRequest.cs create mode 100644 WhatsappBusiness.CloudApi/Messages/Requests/FlowTemplateMessageRequest.cs create mode 100644 WhatsappBusiness.CloudApi/Response/FlowMessageResponse.cs diff --git a/Samples/WhatsAppBusinessCloudAPI.Web/Controllers/HomeController.cs b/Samples/WhatsAppBusinessCloudAPI.Web/Controllers/HomeController.cs index 628f4f5..f687909 100644 --- a/Samples/WhatsAppBusinessCloudAPI.Web/Controllers/HomeController.cs +++ b/Samples/WhatsAppBusinessCloudAPI.Web/Controllers/HomeController.cs @@ -393,6 +393,64 @@ public async Task SendWhatsAppInteractiveMessage(SendInteractiveM } } + public IActionResult SendWhatsAppFlowMessage() + { + SendFlowMessageViewModel sendFlowMessageViewModel = new SendFlowMessageViewModel(); + sendFlowMessageViewModel.FlowAction = new List() + { + new SelectListItem(){ Text = "Navigate", Value = "navigate" }, + new SelectListItem(){ Text = "Data Exchange", Value = "data_exchange" } + }; + sendFlowMessageViewModel.Mode = new List() + { + new SelectListItem(){ Text = "Draft", Value = "Draft" }, + new SelectListItem(){ Text = "Published", Value = "Published" } + }; + return View(sendFlowMessageViewModel); + } + + [HttpPost] + [ValidateAntiForgeryToken] + public async Task SendWhatsAppFlowMessage(SendFlowMessageViewModel sendFlowMessageViewModel) + { + try + { + FlowMessageRequest flowMessageRequest = new FlowMessageRequest(); + flowMessageRequest.To = sendFlowMessageViewModel.RecipientPhoneNumber; + flowMessageRequest.Interactive = new FlowMessageInteractive(); + + flowMessageRequest.Interactive.Header = new FlowMessageHeader(); + flowMessageRequest.Interactive.Header.Type = "text"; + flowMessageRequest.Interactive.Header.Text = "Header flow"; + + flowMessageRequest.Interactive.Body = new FlowMessageBody(); + flowMessageRequest.Interactive.Body.Text = "Body flow"; + + flowMessageRequest.Interactive.Footer = new FlowMessageFooter(); + flowMessageRequest.Interactive.Footer.Text = "Footer flow"; + + flowMessageRequest.Interactive.Action = new FlowMessageAction(); + flowMessageRequest.Interactive.Action.Parameters = new FlowMessageParameters(); + flowMessageRequest.Interactive.Action.Parameters.FlowToken = sendFlowMessageViewModel.FlowToken; + flowMessageRequest.Interactive.Action.Parameters.FlowId = sendFlowMessageViewModel.FlowId; + flowMessageRequest.Interactive.Action.Parameters.FlowCta = sendFlowMessageViewModel.FlowButtonText; + flowMessageRequest.Interactive.Action.Parameters.FlowAction = sendFlowMessageViewModel.SelectedFlowAction; + flowMessageRequest.Interactive.Action.Parameters.IsInDraftMode = (sendFlowMessageViewModel.SelectedMode.Equals("Draft", StringComparison.OrdinalIgnoreCase)); + + flowMessageRequest.Interactive.Action.Parameters.FlowActionPayload = new FlowActionPayload(); + flowMessageRequest.Interactive.Action.Parameters.FlowActionPayload.Screen = sendFlowMessageViewModel.ScreenId; + + var results = await _whatsAppBusinessClient.SendFlowMessageAsync(flowMessageRequest); + + return RedirectToAction(nameof(Index)).WithSuccess("Success", "Successfully sent flow message"); + } + catch (WhatsappBusinessCloudAPIException ex) + { + _logger.LogError(ex, ex.Message); + return RedirectToAction(nameof(SendWhatsAppFlowMessage)).WithDanger("Error", ex.Message); + } + } + public IActionResult SendWhatsAppTemplateMessage() { return View(); @@ -1156,6 +1214,57 @@ public async Task SendWhatsAppLimitedTimeOfferTemplateMessage(Sen } } + [HttpPost] + [ValidateAntiForgeryToken] + public async Task SendWhatsAppFlowTemplateMessage(SendTemplateMessageViewModel sendTemplateMessageViewModel) + { + try + { + FlowTemplateMessageRequest flowTemplateMessageRequest = new FlowTemplateMessageRequest(); + flowTemplateMessageRequest.To = sendTemplateMessageViewModel.RecipientPhoneNumber; + flowTemplateMessageRequest.Template = new(); + flowTemplateMessageRequest.Template.Name = sendTemplateMessageViewModel.TemplateName; + flowTemplateMessageRequest.Template.Language = new(); + flowTemplateMessageRequest.Template.Language.Code = LanguageCode.English_US; + flowTemplateMessageRequest.Template.Components = new List() + { + new FlowMessageComponent() + { + Type = "button", + SubType = "flow", + Index = 0, + Parameters = new List() + { + new FlowTemplateMessageParameter() + { + Type = "action", + Action = new FlowTemplateMessageAction() + { + FlowToken = "", + } + } + } + } + }; + + var results = await _whatsAppBusinessClient.SendFlowMessageTemplateAsync(flowTemplateMessageRequest); + + if (results != null) + { + return RedirectToAction(nameof(Index)).WithSuccess("Success", "Successfully sent flow template message"); + } + else + { + return RedirectToAction(nameof(SendWhatsAppTemplateMessage)); + } + } + catch (WhatsappBusinessCloudAPIException ex) + { + _logger.LogError(ex, ex.Message); + return RedirectToAction(nameof(SendWhatsAppTemplateMessage)).WithDanger("Error", ex.Message); + } + } + public IActionResult SendWhatsAppContactMessage() { return View(); diff --git a/Samples/WhatsAppBusinessCloudAPI.Web/ViewModel/SendFlowMessageViewModel.cs b/Samples/WhatsAppBusinessCloudAPI.Web/ViewModel/SendFlowMessageViewModel.cs new file mode 100644 index 0000000..e242193 --- /dev/null +++ b/Samples/WhatsAppBusinessCloudAPI.Web/ViewModel/SendFlowMessageViewModel.cs @@ -0,0 +1,17 @@ +using Microsoft.AspNetCore.Mvc.Rendering; + +namespace WhatsAppBusinessCloudAPI.Web.ViewModel +{ + public class SendFlowMessageViewModel + { + public string RecipientPhoneNumber { get; set; } + public List FlowAction { get; set; } + public string SelectedFlowAction { get; set; } + public List Mode { get; set; } + public string SelectedMode { get; set; } + public string ScreenId { get; set; } + public string FlowToken { get; set; } + public string FlowId { get; set; } + public string FlowButtonText { get; set; } + } +} diff --git a/Samples/WhatsAppBusinessCloudAPI.Web/Views/Home/SendWhatsAppFlowMessage.cshtml b/Samples/WhatsAppBusinessCloudAPI.Web/Views/Home/SendWhatsAppFlowMessage.cshtml new file mode 100644 index 0000000..1c7eb9b --- /dev/null +++ b/Samples/WhatsAppBusinessCloudAPI.Web/Views/Home/SendWhatsAppFlowMessage.cshtml @@ -0,0 +1,70 @@ +@model SendFlowMessageViewModel +@{ + ViewData["Title"] = "Send WhatsApp Flow Message Page"; + ViewData["CurrentPage"] = "Send WhatsApp Flow Message"; + Layout = "~/Views/Shared/AdminLTE/_AdminLayout.cshtml"; + ViewData["ControllerName"] = nameof(HomeController).Replace("Controller", ""); + ViewData["ActionName"] = nameof(HomeController.SendWhatsAppTextMessage); +} + +
+
+
+
+
+

Send WhatsApp Text Message

+
+ +
+
+
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ + + +
+
+ +
+
+
+
+
+ +@section Scripts { + @{ + await Html.RenderPartialAsync("_ValidationScriptsPartial"); + } + } \ No newline at end of file diff --git a/Samples/WhatsAppBusinessCloudAPI.Web/Views/Home/SendWhatsAppTemplateMessage.cshtml b/Samples/WhatsAppBusinessCloudAPI.Web/Views/Home/SendWhatsAppTemplateMessage.cshtml index fd90202..d53e13c 100644 --- a/Samples/WhatsAppBusinessCloudAPI.Web/Views/Home/SendWhatsAppTemplateMessage.cshtml +++ b/Samples/WhatsAppBusinessCloudAPI.Web/Views/Home/SendWhatsAppTemplateMessage.cshtml @@ -51,7 +51,8 @@ - + + diff --git a/Samples/WhatsAppBusinessCloudAPI.Web/WhatsAppBusinessCloudAPI.Web.csproj b/Samples/WhatsAppBusinessCloudAPI.Web/WhatsAppBusinessCloudAPI.Web.csproj index db6dff4..8bb187c 100644 --- a/Samples/WhatsAppBusinessCloudAPI.Web/WhatsAppBusinessCloudAPI.Web.csproj +++ b/Samples/WhatsAppBusinessCloudAPI.Web/WhatsAppBusinessCloudAPI.Web.csproj @@ -7,7 +7,7 @@ - + diff --git a/WhatsappBusiness.CloudApi/Interfaces/IWhatsAppBusinessClient.cs b/WhatsappBusiness.CloudApi/Interfaces/IWhatsAppBusinessClient.cs index a0a8c2c..7264184 100644 --- a/WhatsappBusiness.CloudApi/Interfaces/IWhatsAppBusinessClient.cs +++ b/WhatsappBusiness.CloudApi/Interfaces/IWhatsAppBusinessClient.cs @@ -873,7 +873,43 @@ public interface IWhatsAppBusinessClient /// Cancellation token /// WhatsAppResponse WhatsAppResponse SendLimitedTimeOfferMessageTemplate(LimitedTimeOfferTemplateMessageRequest limitedTimeOfferTemplateMessageRequest, WhatsAppBusinessCloudApiConfig? cloudApiConfig = null, CancellationToken cancellationToken = default); - #endregion + + /// + /// Send Whatsapp Flow Messages + /// + /// FlowMessageRequest object + /// Custom WhatsAppBusinessCloudApiConfig + /// Cancellation token + /// FlowMessageResponse + Task SendFlowMessageAsync(FlowMessageRequest flowMessageRequest, WhatsAppBusinessCloudApiConfig? cloudApiConfig = null, CancellationToken cancellationToken = default); + + /// + /// Send Whatsapp Flow Messages + /// + /// FlowMessageRequest object + /// Custom WhatsAppBusinessCloudApiConfig + /// Cancellation token + /// FlowMessageResponse + FlowMessageResponse SendFlowMessage(FlowMessageRequest flowMessageRequest, WhatsAppBusinessCloudApiConfig? cloudApiConfig = null, CancellationToken cancellationToken = default); + + /// + /// Send Whatsapp Flow Template Messages + /// + /// FlowTemplateMessageRequest object + /// Custom WhatsAppBusinessCloudApiConfig + /// Cancellation token + /// WhatsAppResponse + Task SendFlowMessageTemplateAsync(FlowTemplateMessageRequest flowTemplateMessageRequest, WhatsAppBusinessCloudApiConfig? cloudApiConfig = null, CancellationToken cancellationToken = default); + + /// + /// Send Whatsapp Flow Template Messages + /// + /// FlowTemplateMessageRequest object + /// Custom WhatsAppBusinessCloudApiConfig + /// Cancellation token + /// WhatsAppResponse + WhatsAppResponse SendFlowMessageTemplate(FlowTemplateMessageRequest flowTemplateMessageRequest, WhatsAppBusinessCloudApiConfig? cloudApiConfig = null, CancellationToken cancellationToken = default); + #endregion #region Two step verification code function /// diff --git a/WhatsappBusiness.CloudApi/Messages/Requests/FlowMessageRequest.cs b/WhatsappBusiness.CloudApi/Messages/Requests/FlowMessageRequest.cs new file mode 100644 index 0000000..cef286a --- /dev/null +++ b/WhatsappBusiness.CloudApi/Messages/Requests/FlowMessageRequest.cs @@ -0,0 +1,117 @@ +using Newtonsoft.Json; + +namespace WhatsappBusiness.CloudApi.Messages.Requests +{ + public class FlowMessageRequest + { + [JsonProperty("recipient_type")] + public string RecipientType { get; private set; } = "individual"; + + [JsonProperty("messaging_product")] + public string MessagingProduct { get; private set; } = "whatsapp"; + + [JsonProperty("to")] + public string To { get; set; } + + [JsonProperty("type")] + public string Type { get; private set; } = "interactive"; + + [JsonProperty("interactive")] + public FlowMessageInteractive Interactive { get; set; } + } + + public class FlowMessageInteractive + { + [JsonProperty("type")] + public string Type { get; private set; } = "flow"; + + [JsonProperty("header")] + public FlowMessageHeader Header { get; set; } + + [JsonProperty("body")] + public FlowMessageBody Body { get; set; } + + [JsonProperty("footer")] + public FlowMessageFooter Footer { get; set; } + + [JsonProperty("action")] + public FlowMessageAction Action { get; set; } + } + + public class FlowMessageAction + { + [JsonProperty("name")] + public string Name { get; private set; } = "flow"; + + [JsonProperty("parameters")] + public FlowMessageParameters Parameters { get; set; } + } + + public class FlowMessageParameters + { + [JsonProperty("flow_message_version")] + public string FlowMessageVersion { get; private set; } = "3"; + + [JsonProperty("flow_token")] + public string FlowToken { get; set; } + + [JsonProperty("flow_id")] + public string FlowId { get; set; } + + [JsonProperty("flow_cta")] + public string FlowCta { get; set; } + + [JsonProperty("flow_action")] + public string FlowAction { get; set; } + + [JsonProperty("flow_action_payload")] + public FlowActionPayload FlowActionPayload { get; set; } + + [JsonIgnore] + public bool IsInDraftMode { get; set; } + + [JsonProperty("mode", NullValueHandling = NullValueHandling.Ignore)] + public string Mode { get; set; } + + public bool ShouldSerializeMode() + { + // Only to be used for sending flows that have draft mode do not set this property when sending published flow messages + return IsInDraftMode; + } + + public bool ShouldSerializeFlowActionPayload() + { + return FlowAction.Equals("navigate", System.StringComparison.OrdinalIgnoreCase); + } + } + + public class FlowActionPayload + { + [JsonProperty("screen")] + public string Screen { get; set; } + + [JsonProperty("data")] + public object Data { get; set; } + } + + public class FlowMessageBody + { + [JsonProperty("text")] + public string Text { get; set; } + } + + public class FlowMessageFooter + { + [JsonProperty("text")] + public string Text { get; set; } + } + + public class FlowMessageHeader + { + [JsonProperty("type")] + public string Type { get; set; } + + [JsonProperty("text")] + public string Text { get; set; } + } +} diff --git a/WhatsappBusiness.CloudApi/Messages/Requests/FlowTemplateMessageRequest.cs b/WhatsappBusiness.CloudApi/Messages/Requests/FlowTemplateMessageRequest.cs new file mode 100644 index 0000000..8f789ec --- /dev/null +++ b/WhatsappBusiness.CloudApi/Messages/Requests/FlowTemplateMessageRequest.cs @@ -0,0 +1,74 @@ +using Newtonsoft.Json; +using System.Collections.Generic; + +namespace WhatsappBusiness.CloudApi.Messages.Requests +{ + public class FlowTemplateMessageRequest + { + [JsonProperty("messaging_product")] + public string MessagingProduct { get; private set; } = "whatsapp"; + + [JsonProperty("recipient_type")] + public string RecipientType { get; private set; } = "individual"; + + [JsonProperty("to")] + public string To { get; set; } + + [JsonProperty("type")] + public string Type { get; private set; } = "template"; + + [JsonProperty("template")] + public FlowMessageTemplate Template { get; set; } + } + + public class FlowMessageTemplate + { + [JsonProperty("name")] + public string Name { get; set; } + + [JsonProperty("language")] + public FlowMessageLanguage Language { get; set; } + + [JsonProperty("components")] + public List Components { get; set; } + } + + public class FlowMessageComponent + { + [JsonProperty("type")] + public string Type { get; set; } + + [JsonProperty("parameters")] + public List Parameters { get; set; } + + [JsonProperty("sub_type", NullValueHandling = NullValueHandling.Ignore)] + public string SubType { get; set; } + + [JsonProperty("index", NullValueHandling = NullValueHandling.Ignore)] + public long? Index { get; set; } + } + + public class FlowTemplateMessageParameter + { + [JsonProperty("type")] + public string Type { get; set; } + + [JsonProperty("action", NullValueHandling = NullValueHandling.Ignore)] + public FlowTemplateMessageAction Action { get; set; } + } + + public class FlowTemplateMessageAction + { + [JsonProperty("flow_token")] + public string FlowToken { get; set; } + + [JsonProperty("flow_action_data")] + public object FlowActionData { get; set; } + } + + public class FlowMessageLanguage + { + [JsonProperty("code")] + public string Code { get; set; } + } +} diff --git a/WhatsappBusiness.CloudApi/Response/FlowMessageResponse.cs b/WhatsappBusiness.CloudApi/Response/FlowMessageResponse.cs new file mode 100644 index 0000000..bcb0806 --- /dev/null +++ b/WhatsappBusiness.CloudApi/Response/FlowMessageResponse.cs @@ -0,0 +1,19 @@ +using Newtonsoft.Json; + +namespace WhatsappBusiness.CloudApi.Response +{ + public class FlowMessageResponse : WhatsAppResponse + { + [JsonProperty("meta")] + public Meta Meta { get; set; } + } + + public class Meta + { + [JsonProperty("api_status")] + public string ApiStatus { get; set; } + + [JsonProperty("version")] + public string Version { get; set; } + } +} diff --git a/WhatsappBusiness.CloudApi/WhatsAppBusinessClient.cs b/WhatsappBusiness.CloudApi/WhatsAppBusinessClient.cs index d19a1f0..b2e5c69 100644 --- a/WhatsappBusiness.CloudApi/WhatsAppBusinessClient.cs +++ b/WhatsappBusiness.CloudApi/WhatsAppBusinessClient.cs @@ -2014,6 +2014,13 @@ public WhatsAppResponse SendCouponCodeMessageTemplate(CouponCodeTemplateMessageR return WhatsAppBusinessPostAsync(couponCodeTemplateMessageRequest, formattedWhatsAppEndpoint, cancellationToken).GetAwaiter().GetResult(); } + /// + /// Send Limited Time Offer Template Message + /// + /// LimitedTimeOfferTemplateMessageRequest object + /// Custom WhatsAppBusinessCloudApiConfig + /// Cancellation token + /// WhatsAppResponse public async Task SendLimitedTimeOfferMessageTemplateAsync(LimitedTimeOfferTemplateMessageRequest limitedTimeOfferTemplateMessageRequest, WhatsAppBusinessCloudApiConfig? cloudApiConfig = null, CancellationToken cancellationToken = default) { if (cloudApiConfig is not null) @@ -2025,7 +2032,13 @@ public async Task SendLimitedTimeOfferMessageTemplateAsync(Lim return await WhatsAppBusinessPostAsync(limitedTimeOfferTemplateMessageRequest, formattedWhatsAppEndpoint, cancellationToken); } - + /// + /// Send Limited Time Offer Template Message + /// + /// LimitedTimeOfferTemplateMessageRequest object + /// Custom WhatsAppBusinessCloudApiConfig + /// Cancellation token + /// WhatsAppResponse public WhatsAppResponse SendLimitedTimeOfferMessageTemplate(LimitedTimeOfferTemplateMessageRequest limitedTimeOfferTemplateMessageRequest, WhatsAppBusinessCloudApiConfig? cloudApiConfig = null, CancellationToken cancellationToken = default) { if (cloudApiConfig is not null) @@ -2037,6 +2050,78 @@ public WhatsAppResponse SendLimitedTimeOfferMessageTemplate(LimitedTimeOfferTemp return WhatsAppBusinessPostAsync(limitedTimeOfferTemplateMessageRequest, formattedWhatsAppEndpoint, cancellationToken).GetAwaiter().GetResult(); } + /// + /// Send Whatsapp Flow Messages + /// + /// FlowMessageRequest object + /// Custom WhatsAppBusinessCloudApiConfig + /// Cancellation token + /// FlowMessageResponse + public async Task SendFlowMessageAsync(FlowMessageRequest flowMessageRequest, WhatsAppBusinessCloudApiConfig? cloudApiConfig = null, CancellationToken cancellationToken = default) + { + if (cloudApiConfig is not null) + { + _whatsAppConfig = cloudApiConfig; + } + + var formattedWhatsAppEndpoint = WhatsAppBusinessRequestEndpoint.SendMessage.Replace("{{Phone-Number-ID}}", _whatsAppConfig.WhatsAppBusinessPhoneNumberId); + return await WhatsAppBusinessPostAsync(flowMessageRequest, formattedWhatsAppEndpoint, cancellationToken); + } + + /// + /// Send Whatsapp Flow Messages + /// + /// FlowMessageRequest object + /// Custom WhatsAppBusinessCloudApiConfig + /// Cancellation token + /// FlowMessageResponse + public FlowMessageResponse SendFlowMessage(FlowMessageRequest flowMessageRequest, WhatsAppBusinessCloudApiConfig? cloudApiConfig = null, CancellationToken cancellationToken = default) + { + if (cloudApiConfig is not null) + { + _whatsAppConfig = cloudApiConfig; + } + + var formattedWhatsAppEndpoint = WhatsAppBusinessRequestEndpoint.SendMessage.Replace("{{Phone-Number-ID}}", _whatsAppConfig.WhatsAppBusinessPhoneNumberId); + return WhatsAppBusinessPostAsync(flowMessageRequest, formattedWhatsAppEndpoint, cancellationToken).GetAwaiter().GetResult(); + } + + /// + /// Send Whatsapp Flow Template Messages + /// + /// FlowTemplateMessageRequest object + /// Custom WhatsAppBusinessCloudApiConfig + /// Cancellation token + /// WhatsAppResponse + public async Task SendFlowMessageTemplateAsync(FlowTemplateMessageRequest flowTemplateMessageRequest, WhatsAppBusinessCloudApiConfig? cloudApiConfig = null, CancellationToken cancellationToken = default) + { + if (cloudApiConfig is not null) + { + _whatsAppConfig = cloudApiConfig; + } + + var formattedWhatsAppEndpoint = WhatsAppBusinessRequestEndpoint.SendMessage.Replace("{{Phone-Number-ID}}", _whatsAppConfig.WhatsAppBusinessPhoneNumberId); + return await WhatsAppBusinessPostAsync(flowTemplateMessageRequest, formattedWhatsAppEndpoint, cancellationToken); + } + + /// + /// Send Whatsapp Flow Template Messages + /// + /// FlowTemplateMessageRequest object + /// Custom WhatsAppBusinessCloudApiConfig + /// Cancellation token + /// WhatsAppResponse + public WhatsAppResponse SendFlowMessageTemplate(FlowTemplateMessageRequest flowTemplateMessageRequest, WhatsAppBusinessCloudApiConfig? cloudApiConfig = null, CancellationToken cancellationToken = default) + { + if (cloudApiConfig is not null) + { + _whatsAppConfig = cloudApiConfig; + } + + var formattedWhatsAppEndpoint = WhatsAppBusinessRequestEndpoint.SendMessage.Replace("{{Phone-Number-ID}}", _whatsAppConfig.WhatsAppBusinessPhoneNumberId); + return WhatsAppBusinessPostAsync(flowTemplateMessageRequest, formattedWhatsAppEndpoint, cancellationToken).GetAwaiter().GetResult(); + } + /// /// You can use this endpoint to change two-step verification code associated with your account. After you change the verification code, future requests like changing the name, must use the new code. /// You set up two-factor verification and register a phone number in the same API call. diff --git a/WhatsappBusiness.CloudApi/WhatsappBusiness.CloudApi.csproj b/WhatsappBusiness.CloudApi/WhatsappBusiness.CloudApi.csproj index 1521e5c..ff43868 100644 --- a/WhatsappBusiness.CloudApi/WhatsappBusiness.CloudApi.csproj +++ b/WhatsappBusiness.CloudApi/WhatsappBusiness.CloudApi.csproj @@ -12,19 +12,19 @@ https://github.com/gabrieldwight/Whatsapp-Business-Cloud-Api-Net enable latest - 1.0.23 + 1.0.24 - + - +