├── Samples └── WhatsAppBusinessCloudAPI.Web │ ├── Views │ ├── _ViewStart.cshtml │ ├── Shared │ │ ├── _ValidationScriptsPartial.cshtml │ │ ├── AdminLTE │ │ │ ├── _Footer.cshtml │ │ │ ├── _TopNavigation.cshtml │ │ │ ├── _Styles.cshtml │ │ │ ├── _Scripts.cshtml │ │ │ └── _AdminLayout.cshtml │ │ ├── _ToastStatusMessages.cshtml │ │ ├── Error.cshtml │ │ └── _Layout.cshtml.css │ ├── _ViewImports.cshtml │ └── Home │ │ ├── Index.cshtml │ │ ├── Privacy.cshtml │ │ ├── Analytics.cshtml │ │ ├── ConversationAnalytics.cshtml │ │ ├── QRCodeMessageList.cshtml │ │ ├── SendWhatsAppTextMessage.cshtml │ │ ├── BulkSendWhatsApps.cshtml │ │ ├── SendWhatsAppInteractiveMessage.cshtml │ │ ├── CreateQRCodeMessage.cshtml │ │ ├── SendWhatsAppLocationMessage.cshtml │ │ ├── UploadMedia.cshtml │ │ ├── SendWhatsAppContactMessage.cshtml │ │ └── SendWhatsAppMediaMessage.cshtml │ ├── wwwroot │ ├── favicon.ico │ ├── whatsapp-logo.png │ ├── css │ │ ├── bootstrap │ │ │ └── fonts │ │ │ │ ├── bootstrap-icons.woff │ │ │ │ └── bootstrap-icons.woff2 │ │ └── site.css │ ├── lib │ │ ├── font-awesome │ │ │ └── webfonts │ │ │ │ ├── fa-brands-400.ttf │ │ │ │ ├── fa-solid-900.ttf │ │ │ │ ├── fa-brands-400.woff2 │ │ │ │ ├── fa-regular-400.ttf │ │ │ │ ├── fa-regular-400.woff2 │ │ │ │ └── fa-solid-900.woff2 │ │ ├── jquery-validation-unobtrusive │ │ │ └── LICENSE.txt │ │ ├── jquery-validation │ │ │ └── LICENSE.md │ │ ├── bootstrap │ │ │ └── LICENSE │ │ └── jquery │ │ │ └── LICENSE.txt │ └── js │ │ ├── site.js │ │ └── swagger-collapse.js │ ├── ViewModel │ ├── BulkSendWhatsAppsViewModel.cs │ ├── UploadMediaViewModel.cs │ ├── QRCodeMessageViewModel.cs │ ├── ExchangeTokenRequestViewModel.cs │ ├── SendLocationMessageViewModel.cs │ ├── SendTextMessageViewModel.cs │ ├── SendContactMessageViewModel.cs │ ├── SendInteractiveMessageViewModel.cs │ ├── SendTemplateMessageViewModel.cs │ ├── SendMediaMessageViewModel.cs │ └── SendFlowMessageViewModel.cs │ ├── Models │ ├── ErrorViewModel.cs │ └── WhatsAppMessageDisplay.cs │ ├── Hubs │ └── WhatsAppMessagesHub.cs │ ├── WhatsAppBusinessCloudAPI.Web.csproj │ ├── Properties │ └── launchSettings.json │ ├── web.config │ ├── Extensions │ ├── Alerts │ │ ├── AlertExtension.cs │ │ └── AlertDecoratorResult.cs │ └── ActiveRouteTagHelper.cs │ └── libman.json ├── WhatsappBusiness.CloudApi ├── Response │ ├── MarkMessageResponse.cs │ ├── RegistrationResponse.cs │ ├── VerificationResponse.cs │ ├── MediaUploadResponse.cs │ ├── TemplateResponse.cs │ ├── TemplateByNameResponse.cs │ ├── QRCodeMessageFilterResponse.cs │ ├── MessageHistoryResponse.cs │ ├── TemplateNamespaceResponse.cs │ ├── WhatsAppGroupInviteLinkResponse.cs │ ├── TemplateMessageCreationResponse.cs │ ├── BaseSuccessResponse.cs │ ├── ResumableUploadResponse.cs │ ├── FlowMessageResponse.cs │ ├── WhatsAppCallResponse.cs │ ├── QRCodeMessageResponse.cs │ ├── PhoneNumberByIdResponse.cs │ ├── WhatsappBusinessEncryptionResponse.cs │ ├── MediaUrlResponse.cs │ ├── SubscribedAppsResponse.cs │ ├── TemplateByIdResponse.cs │ ├── WhatsAppResponse.cs │ ├── BusinessProfileResponse.cs │ ├── ConversationalComponentResponse.cs │ ├── AnalyticsResponse.cs │ ├── WhatsAppErrorResponse.cs │ ├── WhatsAppBusinessHSMWhatsAppHSMComponentGet.cs │ ├── CallPermissionStateResponse.cs │ ├── GetBlockedUserResponse.cs │ ├── ConversationAnalyticsResponse.cs │ ├── WhatsAppGroupJoinRequestResponse.cs │ ├── WABADetailsResponse.cs │ ├── SharedWABAIDResponse.cs │ ├── BlockUserResponse.cs │ ├── WhatsAppGroupResponse.cs │ └── ExchangeTokenResponse.cs ├── AccountMetrics │ ├── MetricType.cs │ ├── ConversationDirection.cs │ ├── ConversationType.cs │ ├── Dimension.cs │ └── Granularity.cs ├── PhoneNumbers │ └── Requests │ │ ├── VerifyCodeRequest.cs │ │ └── RequestVerificationCode.cs ├── Interfaces │ ├── IWhatsAppBusinessClientFactory.cs │ ├── IGenericMessage.cs │ └── IGenericStatus.cs ├── Webhook │ ├── BusinessReplyToUserMessageSentStatus.cs │ ├── BusinessInitiatedMessageSentStatus.cs │ ├── BusinessDeliveredFromUserMessageStatus.cs │ ├── BusinessFromUserInitiatedMessageDeliveredStatus.cs │ ├── TextMessageReceived.cs │ ├── ReactionMessageReceived.cs │ ├── UnknownMessageReceived.cs │ ├── QuickReplyButtonMessageReceived.cs │ ├── UserDeletedMessageStatus.cs │ ├── StaticLocationMessageReceived.cs │ ├── AudioMessageReceived.cs │ ├── FlowMessageReceived.cs │ ├── ListReplyButtonMessageReceived.cs │ ├── AccountUpdateEvent.cs │ ├── ProductEnquiryMessageReceived.cs │ ├── ReplyButtonMessageReceived.cs │ ├── ImageMessageReceived.cs │ ├── ProductOrderMessageReceived.cs │ ├── StickerMessageReceived.cs │ ├── VideoMessageReceived.cs │ ├── DocumentMessageReceived.cs │ ├── UserFailedMessageStatus.cs │ └── WhatsAppAdsClickReceived.cs ├── TwoStepVerification │ └── Requests │ │ └── TwoStepVerificationRequest.cs ├── WhatsAppBusinessClientFactory.cs ├── Configurations │ ├── EmbeddedSignupConfiguration.cs │ └── WhatsAppBusinessCloudApiConfig.cs ├── MessageHistory │ └── Requests │ │ └── MessageHistoryRequest.cs ├── Registration │ └── Requests │ │ └── RegisterPhoneRequest.cs ├── Messages │ ├── ReplyRequests │ │ ├── TextMessageReplyRequest.cs │ │ ├── ContactMessageReplyRequest.cs │ │ ├── AudioMessageByIdReplyRequest.cs │ │ ├── ImageMessageByIdReplyRequest.cs │ │ ├── ListMessageReplyRequest.cs │ │ ├── VideoMessageByIdReplyRequest.cs │ │ ├── AudioMessageByUrlReplyRequest.cs │ │ ├── ImageMessageByUrlReplyRequest.cs │ │ ├── LocationMessageReplyRequest.cs │ │ ├── VideoMessageByUrlReplyRequest.cs │ │ ├── StickerMessageByIdReplyRequest.cs │ │ ├── DocumentMessageByIdReplyRequest.cs │ │ ├── StickerMessageByUrlReplyRequest.cs │ │ ├── DocumentMessageByUrlReplyRequest.cs │ │ └── ReactionMessageReplyRequest.cs │ └── Requests │ │ ├── QRCodeMessageRequest.cs │ │ ├── MarkMessageRequest.cs │ │ ├── ConversationalComponentRequest.cs │ │ ├── ImageMessageByIdRequest.cs │ │ ├── TextMessageRequest.cs │ │ ├── VideoMessageByIdRequest.cs │ │ ├── ImageMessageByUrlRequest.cs │ │ ├── VideoMessageByUrlRequest.cs │ │ ├── AudioMessageByUrlRequest.cs │ │ ├── AudioMessageByIdRequest.cs │ │ ├── StickerMessageByIdRequest.cs │ │ ├── DocumentMessageByIdRequest.cs │ │ ├── StickerMessageByUrlRequest.cs │ │ ├── DocumentMessageByUrlRequest.cs │ │ ├── BaseCreateTemplateMessageRequest.cs │ │ ├── LocationMessageRequest.cs │ │ ├── FreeFormCallPermissionMessageRequest.cs │ │ ├── InteractiveLocationMessageRequest.cs │ │ ├── CallPermissionTemplateMessageRequest.cs │ │ ├── SingleProductMessageRequest.cs │ │ ├── CatalogMessageRequest.cs │ │ ├── VoiceCallMessageRequest.cs │ │ ├── CouponCodeTemplateMessageRequest.cs │ │ ├── InteractiveCTAButtonMessageRequest.cs │ │ ├── FlowTemplateMessageRequest.cs │ │ ├── MultiProductMessageRequest.cs │ │ └── CatalogTemplateMessageRequest.cs ├── BlockUser │ └── Requests │ │ └── BlockUserRequest.cs ├── Groups │ └── Requests │ │ ├── GroupJoinRequest.cs │ │ ├── PinGroupMessageRequest.cs │ │ └── GroupRequest.cs ├── Media │ └── Requests │ │ ├── UploadMediaRequest.cs │ │ └── UploadMediaDataRequest.cs ├── AccountMigration │ └── Requests │ │ └── MigrateAccountRequest.cs ├── OAuth │ └── Requests │ │ └── ExchangeTokenRequest.cs ├── Exceptions │ └── WhatsappBusinessCloudAPIException.cs ├── BusinessProfile │ └── Requests │ │ └── UpdateBusinessProfileRequest.cs ├── Calls │ └── Requests │ │ └── CallRequest.cs └── Extensions │ └── FacebookWebhookHelper.cs ├── WhatsappBusiness.CloudApi.NetFramework ├── Properties │ └── AssemblyInfo.cs ├── WhatsappBusiness.CloudApi.NetFramework.csproj └── WhatsApp │ ├── Requests │ └── ExchangeTokenRequest.cs │ ├── Configuration │ └── WhatsAppBusinessCloudApiConfig.cs │ └── Interfaces │ └── IWhatsAppBusinessCloudApiClient.cs ├── .github └── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md ├── WhatsappBusiness.CloudApi.NetFramework.Tests ├── appsettings.json ├── TestSetup.cs └── WhatsappBusiness.CloudApi.NetFramework.Tests.csproj ├── WhatsappBusiness.CloudApi.Tests ├── TestSetup.cs ├── appsettings.json └── WhatsappBusiness.CloudApi.Tests.csproj ├── License └── .gitattributes /Samples/WhatsAppBusinessCloudAPI.Web/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "_Layout"; 3 | } 4 | -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrieldwight/Whatsapp-Business-Cloud-Api-Net/HEAD/Samples/WhatsAppBusinessCloudAPI.Web/wwwroot/favicon.ico -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Response/MarkMessageResponse.cs: -------------------------------------------------------------------------------- 1 | namespace WhatsappBusiness.CloudApi.Response 2 | { 3 | public class MarkMessageResponse : BaseSuccessResponse 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Response/RegistrationResponse.cs: -------------------------------------------------------------------------------- 1 | namespace WhatsappBusiness.CloudApi.Response 2 | { 3 | public class RegistrationResponse : BaseSuccessResponse 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Response/VerificationResponse.cs: -------------------------------------------------------------------------------- 1 | namespace WhatsappBusiness.CloudApi.Response 2 | { 3 | public class VerificationResponse : BaseSuccessResponse 4 | { 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/wwwroot/whatsapp-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrieldwight/Whatsapp-Business-Cloud-Api-Net/HEAD/Samples/WhatsAppBusinessCloudAPI.Web/wwwroot/whatsapp-logo.png -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi.NetFramework/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrieldwight/Whatsapp-Business-Cloud-Api-Net/HEAD/WhatsappBusiness.CloudApi.NetFramework/Properties/AssemblyInfo.cs -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/wwwroot/css/bootstrap/fonts/bootstrap-icons.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrieldwight/Whatsapp-Business-Cloud-Api-Net/HEAD/Samples/WhatsAppBusinessCloudAPI.Web/wwwroot/css/bootstrap/fonts/bootstrap-icons.woff -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/wwwroot/css/bootstrap/fonts/bootstrap-icons.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrieldwight/Whatsapp-Business-Cloud-Api-Net/HEAD/Samples/WhatsAppBusinessCloudAPI.Web/wwwroot/css/bootstrap/fonts/bootstrap-icons.woff2 -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi.NetFramework/WhatsappBusiness.CloudApi.NetFramework.csproj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrieldwight/Whatsapp-Business-Cloud-Api-Net/HEAD/WhatsappBusiness.CloudApi.NetFramework/WhatsappBusiness.CloudApi.NetFramework.csproj -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/wwwroot/lib/font-awesome/webfonts/fa-brands-400.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrieldwight/Whatsapp-Business-Cloud-Api-Net/HEAD/Samples/WhatsAppBusinessCloudAPI.Web/wwwroot/lib/font-awesome/webfonts/fa-brands-400.ttf -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/wwwroot/lib/font-awesome/webfonts/fa-solid-900.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrieldwight/Whatsapp-Business-Cloud-Api-Net/HEAD/Samples/WhatsAppBusinessCloudAPI.Web/wwwroot/lib/font-awesome/webfonts/fa-solid-900.ttf -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/Views/Shared/_ValidationScriptsPartial.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/wwwroot/lib/font-awesome/webfonts/fa-brands-400.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrieldwight/Whatsapp-Business-Cloud-Api-Net/HEAD/Samples/WhatsAppBusinessCloudAPI.Web/wwwroot/lib/font-awesome/webfonts/fa-brands-400.woff2 -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/wwwroot/lib/font-awesome/webfonts/fa-regular-400.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrieldwight/Whatsapp-Business-Cloud-Api-Net/HEAD/Samples/WhatsAppBusinessCloudAPI.Web/wwwroot/lib/font-awesome/webfonts/fa-regular-400.ttf -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/wwwroot/lib/font-awesome/webfonts/fa-regular-400.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrieldwight/Whatsapp-Business-Cloud-Api-Net/HEAD/Samples/WhatsAppBusinessCloudAPI.Web/wwwroot/lib/font-awesome/webfonts/fa-regular-400.woff2 -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/wwwroot/lib/font-awesome/webfonts/fa-solid-900.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gabrieldwight/Whatsapp-Business-Cloud-Api-Net/HEAD/Samples/WhatsAppBusinessCloudAPI.Web/wwwroot/lib/font-awesome/webfonts/fa-solid-900.woff2 -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/ViewModel/BulkSendWhatsAppsViewModel.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc.Rendering; 2 | 3 | namespace WhatsAppBusinessCloudAPI.Web.ViewModel 4 | { 5 | public class BulkSendWhatsAppsViewModel 6 | { 7 | 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/AccountMetrics/MetricType.cs: -------------------------------------------------------------------------------- 1 | namespace WhatsappBusiness.CloudApi.AccountMetrics 2 | { 3 | public static class MetricType 4 | { 5 | public const string COST = "COST"; 6 | public const string CONVERSATION = "CONVERSATION"; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/wwwroot/js/site.js: -------------------------------------------------------------------------------- 1 | // Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | // for details on configuring this project to bundle and minify static web assets. 3 | 4 | // Write your JavaScript code. 5 | -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/Views/Shared/AdminLTE/_Footer.cshtml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/Models/ErrorViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace WhatsAppBusinessCloudAPI.Web.Models 2 | { 3 | public class ErrorViewModel 4 | { 5 | public string? RequestId { get; set; } 6 | 7 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 8 | } 9 | } -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | html { 2 | font-size: 14px; 3 | } 4 | 5 | @media (min-width: 768px) { 6 | html { 7 | font-size: 16px; 8 | } 9 | } 10 | 11 | html { 12 | position: relative; 13 | min-height: 100%; 14 | } 15 | 16 | body { 17 | margin-bottom: 60px; 18 | } -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/wwwroot/js/swagger-collapse.js: -------------------------------------------------------------------------------- 1 | // Wait a second then collapse all Swagger accordions. 2 | setTimeout(() => { 3 | var all = document.getElementsByClassName('expand-operation'); 4 | for (var i = 0; i < all.length; i++) { 5 | all[i].click(); 6 | } 7 | }, 1000); 8 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Response/MediaUploadResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.Response 4 | { 5 | public class MediaUploadResponse 6 | { 7 | [JsonPropertyName("id")] 8 | public string MediaId { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Response/TemplateResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace WhatsappBusiness.CloudApi.Response 4 | { 5 | public class TemplateResponse : TemplateBaseResponse 6 | { 7 | public Dictionary AdditionalFields { get; set; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Response/TemplateByNameResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace WhatsappBusiness.CloudApi.Response 4 | { 5 | public class TemplateByNameResponse : TemplateBaseResponse 6 | { 7 | public Dictionary AdditionalFields { get; set; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/AccountMetrics/ConversationDirection.cs: -------------------------------------------------------------------------------- 1 | namespace WhatsappBusiness.CloudApi.AccountMetrics 2 | { 3 | public static class ConversationDirection 4 | { 5 | public const string BusinessInitiated = "business_initiated"; 6 | public const string UserInitiated = "user_initiated"; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/PhoneNumbers/Requests/VerifyCodeRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.PhoneNumbers.Requests 4 | { 5 | public class VerifyCodeRequest 6 | { 7 | [JsonPropertyName("code")] 8 | public string Code { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Interfaces/IWhatsAppBusinessClientFactory.cs: -------------------------------------------------------------------------------- 1 | using WhatsappBusiness.CloudApi.Configurations; 2 | 3 | namespace WhatsappBusiness.CloudApi.Interfaces 4 | { 5 | public interface IWhatsAppBusinessClientFactory 6 | { 7 | IWhatsAppBusinessClient Create(WhatsAppBusinessCloudApiConfig config); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Webhook/BusinessReplyToUserMessageSentStatus.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Webhook 5 | { 6 | 7 | 8 | public class BusinessReplyToUserStatus:GenericStatus 9 | { 10 | 11 | } 12 | 13 | 14 | } -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/ViewModel/UploadMediaViewModel.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc.Rendering; 2 | 3 | namespace WhatsAppBusinessCloudAPI.Web.ViewModel 4 | { 5 | public class UploadMediaViewModel 6 | { 7 | public List UploadType { get; set; } 8 | public string SelectedUploadType { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/AccountMetrics/ConversationType.cs: -------------------------------------------------------------------------------- 1 | namespace WhatsappBusiness.CloudApi.AccountMetrics 2 | { 3 | public static class ConversationType 4 | { 5 | public const string FREE_ENTRY = "FREE_ENTRY"; 6 | public const string FREE_TIER = "FREE_TIER"; 7 | public const string REGULAR = "REGULAR"; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/TwoStepVerification/Requests/TwoStepVerificationRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.TwoStepVerification.Requests 4 | { 5 | public class TwoStepVerificationRequest 6 | { 7 | [JsonPropertyName("pin")] 8 | public string Pin { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using WhatsAppBusinessCloudAPI.Web 2 | @using WhatsAppBusinessCloudAPI.Web.Controllers 3 | @using WhatsAppBusinessCloudAPI.Web.Extensions 4 | @using WhatsAppBusinessCloudAPI.Web.Models 5 | @using WhatsAppBusinessCloudAPI.Web.ViewModel 6 | @using System.Text.Json 7 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Response/QRCodeMessageFilterResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Response 5 | { 6 | public class QRCodeMessageFilterResponse 7 | { 8 | [JsonPropertyName("data")] 9 | public List Data { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/ViewModel/QRCodeMessageViewModel.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc.Rendering; 2 | 3 | namespace WhatsAppBusinessCloudAPI.Web.ViewModel 4 | { 5 | public class QRCodeMessageViewModel 6 | { 7 | public string Message { get; set; } 8 | public List ImageFormat { get; set; } 9 | public string SelectedImageFormat { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/ViewModel/ExchangeTokenRequestViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace WhatsAppBusinessCloudAPI.Web.ViewModel 2 | { 3 | public class ExchangeTokenRequestViewModel 4 | { 5 | public string? Code { get; set; } 6 | public string? ClientId { get; set; } 7 | public string? ClientSecret { get; set; } 8 | public string? RedirectUri { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Response/MessageHistoryResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.Response 4 | { 5 | public class MessageHistoryResponse 6 | { 7 | [JsonPropertyName("messaging_product")] 8 | public string MessagingProduct { get; set; } 9 | 10 | [JsonPropertyName("request_id")] 11 | public string RequestId { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/ViewModel/SendLocationMessageViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace WhatsAppBusinessCloudAPI.Web.ViewModel 2 | { 3 | public class SendLocationMessageViewModel 4 | { 5 | public string RecipientPhoneNumber { get; set; } 6 | public string Message { get; set; } 7 | public double Longitude { get; set; } 8 | public double Latitude { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Response/TemplateNamespaceResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.Response 4 | { 5 | public class TemplateNamespaceResponse 6 | { 7 | [JsonPropertyName("message_template_namespace")] 8 | public string MessageTemplateNamespace { get; set; } 9 | 10 | [JsonPropertyName("id")] 11 | public string Id { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Interfaces/IGenericMessage.cs: -------------------------------------------------------------------------------- 1 | using WhatsappBusiness.CloudApi.Webhook; 2 | 3 | namespace WhatsappBusiness.CloudApi.Interfaces; 4 | public interface IGenericMessage 5 | { 6 | string From { get; set; } 7 | string GroupId { get; set; } 8 | string Id { get; set; } 9 | string Timestamp { get; set; } 10 | string Type { get; set; } 11 | 12 | public MessageContext? Context { get; set; } 13 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Response/WhatsAppGroupInviteLinkResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.Response 4 | { 5 | public class WhatsAppGroupInviteLinkResponse 6 | { 7 | [JsonPropertyName("messaging_product")] 8 | public string MessagingProduct { get; set; } 9 | 10 | [JsonPropertyName("invite_link")] 11 | public string InviteLink { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/AccountMetrics/Dimension.cs: -------------------------------------------------------------------------------- 1 | namespace WhatsappBusiness.CloudApi.AccountMetrics 2 | { 3 | public static class Dimension 4 | { 5 | public const string Phone = "phone"; 6 | public const string Country = "country"; 7 | public const string ConversationType = "conversation_type"; 8 | public const string COnversationDirection = "conversation_direction"; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/ViewModel/SendTextMessageViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace WhatsAppBusinessCloudAPI.Web.ViewModel 2 | { 3 | 4 | /// 5 | /// DO NOT USE THIS 6 | /// rather use SendTemplateMessageModel 7 | /// 8 | public class SendTextMessageViewModel 9 | { 10 | public string RecipientPhoneNumber { get; set; } 11 | public string Message { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/Views/Shared/AdminLTE/_TopNavigation.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 10 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/PhoneNumbers/Requests/RequestVerificationCode.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.PhoneNumbers.Requests 4 | { 5 | public class RequestVerificationCode 6 | { 7 | [JsonPropertyName("code_method")] 8 | public string CodeMethod { get; set; } 9 | 10 | [JsonPropertyName("locale")] 11 | public string Locale { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/WhatsAppBusinessClientFactory.cs: -------------------------------------------------------------------------------- 1 | using WhatsappBusiness.CloudApi.Configurations; 2 | using WhatsappBusiness.CloudApi.Interfaces; 3 | 4 | namespace WhatsappBusiness.CloudApi 5 | { 6 | public class WhatsAppBusinessClientFactory : IWhatsAppBusinessClientFactory 7 | { 8 | public IWhatsAppBusinessClient Create(WhatsAppBusinessCloudApiConfig config) 9 | { 10 | return new WhatsAppBusinessClient(config); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Configurations/EmbeddedSignupConfiguration.cs: -------------------------------------------------------------------------------- 1 | namespace WhatsappBusiness.CloudApi.Configurations 2 | { 3 | public class EmbeddedSignupConfiguration 4 | { 5 | public string AppId { get; set; } 6 | public string AppSecret { get; set; } 7 | public string ConfigurationId { get; set; } 8 | public string GraphApiVersion { get; set; } 9 | public string BaseUrl { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Home Page"; 3 | ViewData["CurrentPage"] = "Home Page"; 4 | Layout = "~/Views/Shared/AdminLTE/_AdminLayout.cshtml"; 5 | ViewData["ControllerName"] = nameof(HomeController).Replace("Controller", ""); 6 | ViewData["ActionName"] = nameof(HomeController.Index); 7 | } 8 | 9 |
10 |

Test WhatsApp Send Messsage functions

11 |
12 | -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/Views/Shared/AdminLTE/_Styles.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/ViewModel/SendContactMessageViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace WhatsAppBusinessCloudAPI.Web.ViewModel 2 | { 3 | public class SendContactMessageViewModel 4 | { 5 | public string RecipientPhoneNumber { get; set; } 6 | public string FirstName { get; set; } 7 | public string MiddleName { get; set; } 8 | public string LastName { get; set; } 9 | public string ContactPhoneNumber { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/Views/Home/Privacy.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | ViewData["Title"] = "Privacy Policy"; 3 | ViewData["CurrentPage"] = "Privacy Policy"; 4 | Layout = "~/Views/Shared/AdminLTE/_AdminLayout.cshtml"; 5 | ViewData["ControllerName"] = nameof(HomeController).Replace("Controller", ""); 6 | ViewData["ActionName"] = nameof(HomeController.Privacy); 7 | } 8 |

@ViewData["Title"]

9 | 10 |

Use this page to detail your site's privacy policy.

11 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/MessageHistory/Requests/MessageHistoryRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.MessageHistory.Requests 4 | { 5 | public class MessageHistoryRequest 6 | { 7 | [JsonPropertyName("messaging_product")] 8 | [JsonInclude] 9 | public string MessagingProduct { get; private set; } = "whatsapp"; 10 | 11 | [JsonPropertyName("sync_type")] 12 | public string SyncType { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Response/TemplateMessageCreationResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.Response 4 | { 5 | public class TemplateMessageCreationResponse 6 | { 7 | [JsonPropertyName("id")] 8 | public string Id { get; set; } 9 | 10 | [JsonPropertyName("status")] 11 | public string Status { get; set; } 12 | 13 | [JsonPropertyName("category")] 14 | public string Category { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Response/BaseSuccessResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.Response 4 | { 5 | public class BaseSuccessResponse 6 | { 7 | [JsonPropertyName("messaging_product")] 8 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 9 | public string MessagingProduct { get; set; } 10 | 11 | [JsonPropertyName("success")] 12 | public bool Success { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Registration/Requests/RegisterPhoneRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.Registration.Requests 4 | { 5 | public class RegisterPhoneRequest 6 | { 7 | [JsonPropertyName("messaging_product")] 8 | [JsonInclude] 9 | public string MessagingProduct { get; private set; } = "whatsapp"; 10 | 11 | [JsonPropertyName("pin")] 12 | public string Pin { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Response/ResumableUploadResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.Response 4 | { 5 | public class ResumableUploadResponse 6 | { 7 | [JsonPropertyName("id")] 8 | public string Id { get; set; } 9 | 10 | [JsonPropertyName("file_offset")] 11 | public long FileOffset { get; set; } 12 | 13 | [JsonPropertyName("h")] 14 | public string H { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Webhook/BusinessInitiatedMessageSentStatus.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Webhook 5 | { 6 | /// 7 | /// The following notification is received when a business sends a message as part of a business-initiated conversation 8 | /// 9 | 10 | public class BusinessInitiatedStatus:GenericStatus 11 | { 12 | 13 | } 14 | 15 | 16 | } -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/ViewModel/SendInteractiveMessageViewModel.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc.Rendering; 2 | 3 | namespace WhatsAppBusinessCloudAPI.Web.ViewModel 4 | { 5 | public class SendInteractiveMessageViewModel 6 | { 7 | public string RecipientPhoneNumber { get; set; } 8 | public List InteractiveType { get; set; } 9 | public string SelectedInteractiveType { get; set; } 10 | public string Message { get; set;} 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Response/FlowMessageResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.Response 4 | { 5 | public class FlowMessageResponse : WhatsAppResponse 6 | { 7 | [JsonPropertyName("meta")] 8 | public Meta Meta { get; set; } 9 | } 10 | 11 | public class Meta 12 | { 13 | [JsonPropertyName("api_status")] 14 | public string ApiStatus { get; set; } 15 | 16 | [JsonPropertyName("version")] 17 | public string Version { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Webhook/BusinessDeliveredFromUserMessageStatus.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Webhook 5 | { 6 | /// 7 | /// The following notification is received when a business’ message is delivered and that message is part of a user-initiated conversation originating from a free entry point 8 | /// 9 | public class BusinessDeliveredFromUserStatus:GenericStatus 10 | { 11 | 12 | } 13 | 14 | 15 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Response/WhatsAppCallResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Response 5 | { 6 | public class WhatsAppCallResponse 7 | { 8 | [JsonPropertyName("messaging_product")] 9 | public string MessagingProduct { get; set; } 10 | 11 | [JsonPropertyName("calls")] 12 | public List Calls { get; set; } 13 | } 14 | 15 | public class WhatsAppCall 16 | { 17 | [JsonPropertyName("id")] 18 | public string Id { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/Hubs/WhatsAppMessagesHub.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.SignalR; 2 | 3 | namespace WhatsAppBusinessCloudAPI.Web.Hubs 4 | { 5 | public class WhatsAppMessagesHub : Hub 6 | { 7 | public async Task JoinGroup(string groupName) 8 | { 9 | await Groups.AddToGroupAsync(Context.ConnectionId, groupName); 10 | } 11 | 12 | public async Task LeaveGroup(string groupName) 13 | { 14 | await Groups.RemoveFromGroupAsync(Context.ConnectionId, groupName); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/ViewModel/SendTemplateMessageViewModel.cs: -------------------------------------------------------------------------------- 1 | namespace WhatsAppBusinessCloudAPI.Web.ViewModel 2 | { 3 | public class SendTemplateMessageViewModel 4 | { // 5 | public string RecipientPhoneNumber { get; set; } 6 | public string Message { get; set; } // This may be ignored when sending a Template 7 | public string TemplateName { get; set; } 8 | public string? MediaId { get; set; } 9 | public string? LinkUrl { get; set; } 10 | public string? TemplateParams { get; set; } 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/Models/WhatsAppMessageDisplay.cs: -------------------------------------------------------------------------------- 1 | namespace WhatsAppBusinessCloudAPI.Web.Models 2 | { 3 | public class WhatsAppMessageDisplay 4 | { 5 | public DateTime Timestamp { get; set; } = DateTime.Now; 6 | public string MessageType { get; set; } = string.Empty; 7 | public string From { get; set; } = string.Empty; 8 | public string MessageContent { get; set; } = string.Empty; 9 | public string RawJson { get; set; } = string.Empty; 10 | public string Status { get; set; } = string.Empty; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/ViewModel/SendMediaMessageViewModel.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc.Rendering; 2 | 3 | namespace WhatsAppBusinessCloudAPI.Web.ViewModel 4 | { 5 | public class SendMediaMessageViewModel 6 | { 7 | public string RecipientPhoneNumber { get; set; } 8 | public List MediaType { get; set; } 9 | public string SelectedMediaType { get; set; } 10 | public string Message { get; set; } 11 | public string? MediaLink { get; set; } 12 | public string? MediaId { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Messages/ReplyRequests/TextMessageReplyRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | using WhatsappBusiness.CloudApi.Messages.Requests; 3 | 4 | namespace WhatsappBusiness.CloudApi.Messages.ReplyRequests 5 | { 6 | public class TextMessageReplyRequest : TextMessageRequest 7 | { 8 | [JsonPropertyName("context")] 9 | public TextMessageContext Context { get; set; } 10 | } 11 | 12 | public class TextMessageContext 13 | { 14 | [JsonPropertyName("message_id")] 15 | public string MessageId { get; set; } 16 | } 17 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Messages/ReplyRequests/ContactMessageReplyRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | using WhatsappBusiness.CloudApi.Messages.Requests; 3 | 4 | namespace WhatsappBusiness.CloudApi.Messages.ReplyRequests 5 | { 6 | public class ContactMessageReplyRequest : ContactMessageRequest 7 | { 8 | [JsonPropertyName("context")] 9 | public ContactMessageContext Context { get; set; } 10 | } 11 | 12 | public class ContactMessageContext 13 | { 14 | [JsonPropertyName("message_id")] 15 | public string MessageId { get; set; } 16 | } 17 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Webhook/BusinessFromUserInitiatedMessageDeliveredStatus.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Webhook 5 | { 6 | /// 7 | /// The following notification is received when a business’ message is delivered and that message is part of a user-initiated conversation (if that conversation did not originate in a free entry point) 8 | /// 9 | public class BusinessFromUserInitiatedStatus:GenericStatus 10 | { 11 | 12 | } 13 | 14 | 15 | 16 | 17 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Messages/ReplyRequests/AudioMessageByIdReplyRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | using WhatsappBusiness.CloudApi.Messages.Requests; 3 | 4 | namespace WhatsappBusiness.CloudApi.Messages.ReplyRequests 5 | { 6 | public class AudioMessageByIdReplyRequest : AudioMessageByIdRequest 7 | { 8 | [JsonPropertyName("context")] 9 | public AudioMessageContext Context { get; set; } 10 | } 11 | 12 | public class AudioMessageContext 13 | { 14 | [JsonPropertyName("message_id")] 15 | public string MessageId { get; set; } 16 | } 17 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Messages/ReplyRequests/ImageMessageByIdReplyRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | using WhatsappBusiness.CloudApi.Messages.Requests; 3 | 4 | namespace WhatsappBusiness.CloudApi.Messages.ReplyRequests 5 | { 6 | public class ImageMessageByIdReplyRequest : ImageMessageByIdRequest 7 | { 8 | [JsonPropertyName("context")] 9 | public ImageMessageContext Context { get; set; } 10 | } 11 | 12 | public class ImageMessageContext 13 | { 14 | [JsonPropertyName("message_id")] 15 | public string MessageId { get; set; } 16 | } 17 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Messages/ReplyRequests/ListMessageReplyRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | using WhatsappBusiness.CloudApi.Messages.Requests; 3 | 4 | namespace WhatsappBusiness.CloudApi.Messages.ReplyRequests 5 | { 6 | public class ListMessageReplyRequest : InteractiveListMessageRequest 7 | { 8 | [JsonPropertyName("context")] 9 | public ListMessageContext Context { get; set; } 10 | } 11 | 12 | public class ListMessageContext 13 | { 14 | [JsonPropertyName("message_id")] 15 | public string MessageId { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Messages/ReplyRequests/VideoMessageByIdReplyRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | using WhatsappBusiness.CloudApi.Messages.Requests; 3 | 4 | namespace WhatsappBusiness.CloudApi.Messages.ReplyRequests 5 | { 6 | public class VideoMessageByIdReplyRequest : VideoMessageByIdRequest 7 | { 8 | [JsonPropertyName("context")] 9 | public VideoMessageContext Context { get; set; } 10 | } 11 | 12 | public class VideoMessageContext 13 | { 14 | [JsonPropertyName("message_id")] 15 | public string MessageId { get; set; } 16 | } 17 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Messages/ReplyRequests/AudioMessageByUrlReplyRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | using WhatsappBusiness.CloudApi.Messages.Requests; 3 | 4 | namespace WhatsappBusiness.CloudApi.Messages.ReplyRequests 5 | { 6 | public class AudioMessageByUrlReplyRequest : AudioMessageByUrlRequest 7 | { 8 | [JsonPropertyName("context")] 9 | public AudioMessageUrlContext Context { get; set; } 10 | } 11 | 12 | public class AudioMessageUrlContext 13 | { 14 | [JsonPropertyName("message_id")] 15 | public string MessageId { get; set; } 16 | } 17 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Messages/ReplyRequests/ImageMessageByUrlReplyRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | using WhatsappBusiness.CloudApi.Messages.Requests; 3 | 4 | namespace WhatsappBusiness.CloudApi.Messages.ReplyRequests 5 | { 6 | public class ImageMessageByUrlReplyRequest : ImageMessageByUrlRequest 7 | { 8 | [JsonPropertyName("context")] 9 | public ImageMessageUrlContext Context { get; set; } 10 | } 11 | 12 | public class ImageMessageUrlContext 13 | { 14 | [JsonPropertyName("message_id")] 15 | public string MessageId { get; set; } 16 | } 17 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Messages/ReplyRequests/LocationMessageReplyRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | using WhatsappBusiness.CloudApi.Messages.Requests; 3 | 4 | namespace WhatsappBusiness.CloudApi.Messages.ReplyRequests 5 | { 6 | public class LocationMessageReplyRequest : LocationMessageRequest 7 | { 8 | [JsonPropertyName("context")] 9 | public LocationMessageContext Context { get; set; } 10 | } 11 | 12 | public class LocationMessageContext 13 | { 14 | [JsonPropertyName("message_id")] 15 | public string MessageId { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Messages/ReplyRequests/VideoMessageByUrlReplyRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | using WhatsappBusiness.CloudApi.Messages.Requests; 3 | 4 | namespace WhatsappBusiness.CloudApi.Messages.ReplyRequests 5 | { 6 | public class VideoMessageByUrlReplyRequest : VideoMessageByUrlRequest 7 | { 8 | [JsonPropertyName("context")] 9 | public VideoMessageUrlContext Context { get; set; } 10 | } 11 | 12 | public class VideoMessageUrlContext 13 | { 14 | [JsonPropertyName("message_id")] 15 | public string MessageId { get; set; } 16 | } 17 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Messages/ReplyRequests/StickerMessageByIdReplyRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | using WhatsappBusiness.CloudApi.Messages.Requests; 3 | 4 | namespace WhatsappBusiness.CloudApi.Messages.ReplyRequests 5 | { 6 | public class StickerMessageByIdReplyRequest : StickerMessageByIdRequest 7 | { 8 | [JsonPropertyName("context")] 9 | public StickerMessageContext Context { get; set; } 10 | } 11 | 12 | public class StickerMessageContext 13 | { 14 | [JsonPropertyName("message_id")] 15 | public string MessageId { get; set; } 16 | } 17 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Webhook/TextMessageReceived.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Webhook 5 | { 6 | public class TextMessage : GenericMessage 7 | { 8 | [JsonPropertyName("text")] 9 | public TextMessageText Text { get; set; } 10 | 11 | [JsonPropertyName("context")] 12 | public MessageContext? Context { get; set; } 13 | } 14 | 15 | public class TextMessageText 16 | { 17 | [JsonPropertyName("body")] 18 | public string Body { get; set; } 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/BlockUser/Requests/BlockUserRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.BlockUser.Requests 5 | { 6 | public class BlockUserRequest 7 | { 8 | [JsonPropertyName("messaging_product")] 9 | [JsonInclude] 10 | public string MessagingProduct { get; private set; } = "whatsapp"; 11 | 12 | [JsonPropertyName("block_users")] 13 | public List BlockUsers { get; set; } 14 | } 15 | 16 | public class BlockUser 17 | { 18 | [JsonPropertyName("user")] 19 | public string User { get; set; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Messages/ReplyRequests/DocumentMessageByIdReplyRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | using WhatsappBusiness.CloudApi.Messages.Requests; 3 | 4 | namespace WhatsappBusiness.CloudApi.Messages.ReplyRequests 5 | { 6 | public class DocumentMessageByIdReplyRequest : DocumentMessageByIdRequest 7 | { 8 | [JsonPropertyName("context")] 9 | public DocumentMessageContext Context { get; set; } 10 | } 11 | 12 | public class DocumentMessageContext 13 | { 14 | [JsonPropertyName("message_id")] 15 | public string MessageId { get; set; } 16 | } 17 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Messages/ReplyRequests/StickerMessageByUrlReplyRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | using WhatsappBusiness.CloudApi.Messages.Requests; 3 | 4 | namespace WhatsappBusiness.CloudApi.Messages.ReplyRequests 5 | { 6 | public class StickerMessageByUrlReplyRequest : StickerMessageByUrlRequest 7 | { 8 | [JsonPropertyName("context")] 9 | public StickerMessageUrlContext Context { get; set; } 10 | } 11 | 12 | public class StickerMessageUrlContext 13 | { 14 | [JsonPropertyName("message_id")] 15 | public string MessageId { get; set; } 16 | } 17 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Messages/ReplyRequests/DocumentMessageByUrlReplyRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | using WhatsappBusiness.CloudApi.Messages.Requests; 3 | 4 | namespace WhatsappBusiness.CloudApi.Messages.ReplyRequests 5 | { 6 | public class DocumentMessageByUrlReplyRequest : DocumentMessageByUrlRequest 7 | { 8 | [JsonPropertyName("context")] 9 | public DocumentMessageUrlContext Context { get; set; } 10 | } 11 | 12 | public class DocumentMessageUrlContext 13 | { 14 | [JsonPropertyName("message_id")] 15 | public string MessageId { get; set; } 16 | } 17 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Response/QRCodeMessageResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.Response 4 | { 5 | public class QRCodeMessageResponse 6 | { 7 | [JsonPropertyName("code")] 8 | public string Code { get; set; } 9 | 10 | [JsonPropertyName("prefilled_message")] 11 | public string PrefilledMessage { get; set; } 12 | 13 | [JsonPropertyName("deep_link_url")] 14 | public string DeepLinkUrl { get; set; } 15 | 16 | [JsonPropertyName("qr_image_url")] 17 | public string QrImageUrl { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Messages/Requests/QRCodeMessageRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.Messages.Requests 4 | { 5 | public class QRCodeMessageRequest 6 | { 7 | [JsonPropertyName("prefilled_message")] 8 | public string PrefilledMessage { get; set; } 9 | 10 | [JsonPropertyName("generate_qr_image")] 11 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 12 | public string GenerateQRImage { get; set; } 13 | 14 | [JsonPropertyName("code")] 15 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 16 | public string Code { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Response/PhoneNumberByIdResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.Response 4 | { 5 | public class PhoneNumberByIdResponse 6 | { 7 | [JsonPropertyName("verified_name")] 8 | public string VerifiedName { get; set; } 9 | 10 | [JsonPropertyName("display_phone_number")] 11 | public string DisplayPhoneNumber { get; set; } 12 | 13 | [JsonPropertyName("id")] 14 | public string Id { get; set; } 15 | 16 | [JsonPropertyName("quality_rating")] 17 | public string QualityRating { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/AccountMetrics/Granularity.cs: -------------------------------------------------------------------------------- 1 | namespace WhatsappBusiness.CloudApi.AccountMetrics 2 | { 3 | public static class Granularity 4 | { 5 | public static class AnalyticsGranularity 6 | { 7 | public const string HALF_HOUR = "HALF_HOUR"; 8 | public const string DAY = "DAY"; 9 | public const string MONTH = "MONTH"; 10 | } 11 | 12 | public static class ConversationGranularity 13 | { 14 | public const string HALF_HOUR = "HALF_HOUR"; 15 | public const string DAILY = "DAILY"; 16 | public const string MONTHLY = "MONTHLY"; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Configurations/WhatsAppBusinessCloudApiConfig.cs: -------------------------------------------------------------------------------- 1 | namespace WhatsappBusiness.CloudApi.Configurations 2 | { 3 | public class WhatsAppBusinessCloudApiConfig 4 | { 5 | public string WhatsAppBusinessPhoneNumberId { get; set; } 6 | public string WhatsAppBusinessAccountId { get; set; } 7 | public string WhatsAppBusinessId { get; set; } 8 | public string GroupId { get; set; } 9 | public string AccessToken { get; set; } 10 | public string AppName { get; set; } 11 | public string Version { get; set; } 12 | public string WebhookVerifyToken { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/Views/Shared/AdminLTE/_Scripts.cshtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/Views/Shared/_ToastStatusMessages.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | var type = (string)TempData["_alert.type"]; 3 | var title = (string)TempData["_alert.title"]; 4 | var body = (string)TempData["_alert.body"]; 5 | } 6 | @if (!string.IsNullOrEmpty(type)) 7 | { 8 | 19 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Interfaces/IGenericStatus.cs: -------------------------------------------------------------------------------- 1 | using WhatsappBusiness.CloudApi.Webhook; 2 | 3 | namespace WhatsappBusiness.CloudApi.Interfaces; 4 | public interface IGenericStatus 5 | { 6 | 7 | public string Id { get; set; } 8 | 9 | public string Type { get; set; } // To be used in WhatsApp Cloud API to get WhatsApp Call Status 10 | 11 | public string Status { get; set; } 12 | 13 | public string Timestamp { get; set; } 14 | 15 | public string RecipientId { get; set; } 16 | 17 | public string BizOpaqueCallbackData { get; set; } 18 | 19 | public Conversation Conversation { get; set; } 20 | 21 | 22 | public Pricing Pricing { get; set; } 23 | } -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/WhatsAppBusinessCloudAPI.Web.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net10.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Groups/Requests/GroupJoinRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Groups.Requests 5 | { 6 | public class GroupJoinRequest 7 | { 8 | [JsonPropertyName("messaging_product")] 9 | [JsonInclude] 10 | public string MessagingProduct { get; private set; } = "whatsapp"; 11 | 12 | [JsonPropertyName("join_requests")] 13 | public List JoinRequests { get; set; } 14 | 15 | [JsonPropertyName("rejected_join_requests")] 16 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 17 | public List RejectedJoinRequests { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Response/WhatsappBusinessEncryptionResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Response; 5 | 6 | public class WhatsappBusinessEncryptionResponse 7 | { 8 | [JsonPropertyName("data")] 9 | public List Data { get; set; } 10 | } 11 | 12 | public class WhatsappBusinessEncryptionData 13 | { 14 | [JsonPropertyName("business_public_key")] 15 | public string BusinessPublicKey { get; set; } 16 | 17 | [JsonPropertyName("business_public_key_signature_status")] 18 | public string BusinessPublicKeySignatureStatus { get; set; } 19 | } -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/ViewModel/SendFlowMessageViewModel.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc.Rendering; 2 | 3 | namespace WhatsAppBusinessCloudAPI.Web.ViewModel 4 | { 5 | public class SendFlowMessageViewModel 6 | { 7 | public string RecipientPhoneNumber { get; set; } 8 | public List FlowAction { get; set; } 9 | public string SelectedFlowAction { get; set; } 10 | public List Mode { get; set; } 11 | public string SelectedMode { get; set; } 12 | public string ScreenId { get; set; } 13 | public string FlowToken { get; set; } 14 | public string FlowId { get; set; } 15 | public string FlowButtonText { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/wwwroot/lib/jquery-validation-unobtrusive/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) .NET Foundation. All rights reserved. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use 4 | these files except in compliance with the License. You may obtain a copy of the 5 | License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software distributed 10 | under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 11 | CONDITIONS OF ANY KIND, either express or implied. See the License for the 12 | specific language governing permissions and limitations under the License. 13 | -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/Views/Home/Analytics.cshtml: -------------------------------------------------------------------------------- 1 | @model WhatsappBusiness.CloudApi.Response.AnalyticsResponse 2 | @{ 3 | ViewData["Title"] = "Account Metrics - Analytics"; 4 | ViewData["CurrentPage"] = "Account Metrics - Analytics"; 5 | Layout = "~/Views/Shared/AdminLTE/_AdminLayout.cshtml"; 6 | ViewData["ControllerName"] = nameof(HomeController).Replace("Controller", ""); 7 | ViewData["ActionName"] = nameof(HomeController.Analytics); 8 | } 9 | 10 |
11 |
12 |

@JsonSerializer.Serialize(Model)

13 |
14 |
15 | 16 | @section Scripts { 17 | @{ 18 | await Html.RenderPartialAsync("_ValidationScriptsPartial"); 19 | } 20 | } -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Webhook/ReactionMessageReceived.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Webhook 5 | { 6 | /// 7 | /// A reaction message you received from a customer 8 | /// 9 | 10 | public class ReactionMessage:GenericMessage 11 | { 12 | [JsonPropertyName("reaction")] 13 | public ReactionMessageText Reaction { get; set; } 14 | } 15 | 16 | public class ReactionMessageText 17 | { 18 | [JsonPropertyName("message_id")] 19 | public string MessageId { get; set; } 20 | 21 | [JsonPropertyName("emoji")] 22 | public string Emoji { get; set; } 23 | } 24 | 25 | 26 | } -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/Views/Home/ConversationAnalytics.cshtml: -------------------------------------------------------------------------------- 1 | @model WhatsappBusiness.CloudApi.Response.ConversationAnalyticsResponse 2 | @{ 3 | ViewData["Title"] = "Account Metrics - Conversation Analytics"; 4 | ViewData["CurrentPage"] = "Account Metrics - Conversation Analytics"; 5 | Layout = "~/Views/Shared/AdminLTE/_AdminLayout.cshtml"; 6 | ViewData["ControllerName"] = nameof(HomeController).Replace("Controller", ""); 7 | ViewData["ActionName"] = nameof(HomeController.ConversationAnalytics); 8 | } 9 | 10 |
11 |
12 |

@JsonSerializer.Serialize(Model)

13 |
14 |
15 | 16 | @section Scripts { 17 | @{ 18 | await Html.RenderPartialAsync("_ValidationScriptsPartial"); 19 | } 20 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Messages/Requests/MarkMessageRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.Messages.Requests 4 | { 5 | public class MarkMessageRequest 6 | { 7 | [JsonPropertyName("messaging_product")] 8 | public string MessagingProduct { get; private set; } = "whatsapp"; 9 | 10 | [JsonPropertyName("status")] 11 | public string Status { get; set; } 12 | 13 | [JsonPropertyName("message_id")] 14 | public string MessageId { get; set; } 15 | 16 | [JsonPropertyName("typing_indicator")] 17 | public TypingIndicator TypingIndicator { get; set; } 18 | } 19 | 20 | public class TypingIndicator 21 | { 22 | [JsonPropertyName("type")] 23 | public string Type { get; private set; } = "text"; 24 | } 25 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Response/MediaUrlResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.Response 4 | { 5 | public class MediaUrlResponse 6 | { 7 | [JsonPropertyName("messaging_product")] 8 | public string MessagingProduct { get; set; } 9 | 10 | [JsonPropertyName("url")] 11 | public string Url { get; set; } 12 | 13 | [JsonPropertyName("mime_type")] 14 | public string MimeType { get; set; } 15 | 16 | [JsonPropertyName("sha256")] 17 | public string Sha256 { get; set; } 18 | 19 | [JsonPropertyName("file_size")] 20 | public long FileSize { get; set; } 21 | 22 | [JsonPropertyName("id")] 23 | public string Id { get; set; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Media/Requests/UploadMediaRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.Media.Requests 4 | { 5 | public class UploadMediaRequest 6 | { 7 | [JsonPropertyName("messaging_product")] 8 | public string MessagingProduct { get; private set; } = "whatsapp"; 9 | 10 | /// 11 | /// Path to the file stored in your local directory. For example: "@/local/path/file.jpg". 12 | /// 13 | [JsonPropertyName("file")] 14 | public string File { get; set; } 15 | 16 | /// 17 | /// Type of media file being uploaded. 18 | /// 19 | [JsonPropertyName("type")] 20 | public string Type { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/AccountMigration/Requests/MigrateAccountRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.AccountMigration.Requests 4 | { 5 | public class MigrateAccountRequest 6 | { 7 | [JsonPropertyName("messaging_product")] 8 | public string MessagingProduct { get; private set; } = "whatsapp"; 9 | 10 | [JsonPropertyName("pin")] 11 | public string Pin { get; set; } 12 | 13 | [JsonPropertyName("backup")] 14 | public Backup Backup { get; set; } 15 | } 16 | 17 | public class Backup 18 | { 19 | [JsonPropertyName("data")] 20 | public string Data { get; set; } 21 | 22 | [JsonPropertyName("password")] 23 | public string Password { get; set; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Webhook/UnknownMessageReceived.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Webhook 5 | { 6 | /// 7 | /// A message you received from a customer that is not supported. 8 | /// 9 | public class UnknownMessage : GenericMessage 10 | { 11 | 12 | [JsonPropertyName("errors")] 13 | public List Errors { get; set; } 14 | 15 | } 16 | 17 | public class Error 18 | { 19 | [JsonPropertyName("code")] 20 | public long Code { get; set; } 21 | 22 | [JsonPropertyName("details")] 23 | public string Details { get; set; } 24 | 25 | [JsonPropertyName("title")] 26 | public string Title { get; set; } 27 | } 28 | 29 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/OAuth/Requests/ExchangeTokenRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.OAuth.Requests 4 | { 5 | public class ExchangeTokenRequest 6 | { 7 | [JsonPropertyName("grant_type")] 8 | public string GrantType { get; set; } = "authorization_code"; 9 | 10 | [JsonPropertyName("client_id")] 11 | public string ClientId { get; set; } 12 | 13 | [JsonPropertyName("client_secret")] 14 | public string ClientSecret { get; set; } 15 | 16 | [JsonPropertyName("code")] 17 | public string Code { get; set; } 18 | 19 | [JsonPropertyName("redirect_uri")] 20 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 21 | public string? RedirectUri { get; set; } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:33382", 7 | "sslPort": 44349 8 | } 9 | }, 10 | "profiles": { 11 | "WhatsAppBusinessCloudAPI.Web": { 12 | "commandName": "Project", 13 | "dotnetRunMessages": true, 14 | "launchBrowser": true, 15 | "applicationUrl": "https://localhost:7150;http://localhost:5150", 16 | "environmentVariables": { 17 | "ASPNETCORE_ENVIRONMENT": "Development" 18 | } 19 | }, 20 | "IIS Express": { 21 | "commandName": "IISExpress", 22 | "launchBrowser": true, 23 | "environmentVariables": { 24 | "ASPNETCORE_ENVIRONMENT": "Development" 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/web.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi.NetFramework.Tests/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "WhatsAppBusinessCloudApiNetFrameworkConfiguration": { 3 | "WhatsAppBusinessId": "YOUR_BUSINESS_ID", 4 | "WhatsAppAccessToken": "YOUR_ACCESS_TOKEN", 5 | "WhatsAppGraphApiVersion": "v23.0", 6 | "WhatsAppEmbeddedSignupMetaAppId": "YOUR_APP_ID", 7 | "WhatsAppEmbeddedSignupMetaAppSecret": "YOUR_APP_SECRET", 8 | "WhatsAppEmbeddedSignupMetaConfigurationId": "YOUR_EMBEDDED_SIGNUP_CONFIGURATION_ID", 9 | "WhatsAppEmbeddedSignupPartnerSolutionId": "" 10 | }, 11 | "TestWABAIds": { 12 | "PrimaryWABAId": "YOUR_PRIMARY_WABA_ID", 13 | "SharedWABAId": "YOUR_SHARED_WABA_ID" 14 | }, 15 | "TestTokens": { 16 | "InputTokenForSharedWABA": "SHARED_ACCESS_TOKEN" 17 | }, 18 | "Logging": { 19 | "LogLevel": { 20 | "Default": "Information", 21 | "Microsoft.AspNetCore": "Warning" 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Response/SubscribedAppsResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Response 5 | { 6 | public class SubscribedAppsResponse 7 | { 8 | [JsonPropertyName("data")] 9 | public List Data { get; set; } 10 | } 11 | 12 | public class SubscribedAppsData 13 | { 14 | [JsonPropertyName("whatsapp_business_api_data")] 15 | public WhatsappBusinessApiData WhatsappBusinessApiData { get; set; } 16 | } 17 | 18 | public partial class WhatsappBusinessApiData 19 | { 20 | [JsonPropertyName("link")] 21 | public string Link { get; set; } 22 | 23 | [JsonPropertyName("name")] 24 | public string Name { get; set; } 25 | 26 | [JsonPropertyName("id")] 27 | public string Id { get; set; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Messages/Requests/ConversationalComponentRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Messages.Requests 5 | { 6 | public class ConversationalComponentRequest 7 | { 8 | [JsonPropertyName("enable_welcome_message")] 9 | public bool EnableWelcomeMessage { get; set; } 10 | 11 | [JsonPropertyName("commands")] 12 | public List Commands { get; set; } 13 | 14 | [JsonPropertyName("prompts")] 15 | public List Prompts { get; set; } 16 | } 17 | 18 | public class ConversationalComponentCommand 19 | { 20 | [JsonPropertyName("command_name")] 21 | public string CommandName { get; set; } 22 | 23 | [JsonPropertyName("command_description")] 24 | public string CommandDescription { get; set; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Response/TemplateByIdResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Response 5 | { 6 | public class TemplateByIdResponse 7 | { 8 | [JsonPropertyName("name")] 9 | public string Name { get; set; } 10 | 11 | [JsonPropertyName("components")] 12 | public List Components { get; set; } 13 | 14 | [JsonPropertyName("language")] 15 | public string Language { get; set; } 16 | 17 | [JsonPropertyName("status")] 18 | public string Status { get; set; } 19 | 20 | [JsonPropertyName("category")] 21 | public string Category { get; set; } 22 | 23 | [JsonPropertyName("parameter_format")] // named or positional 24 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 25 | public string ParameterFormat { get; set; } 26 | 27 | [JsonPropertyName("id")] 28 | public string Id { get; set; } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Response/WhatsAppResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Response 5 | { 6 | public class WhatsAppResponse 7 | { 8 | [JsonPropertyName("messaging_product")] 9 | public string MessagingProduct { get; set; } 10 | 11 | [JsonPropertyName("contacts")] 12 | public List Contacts { get; set; } 13 | 14 | [JsonPropertyName("messages")] 15 | public List Messages { get; set; } 16 | } 17 | 18 | public class Contact 19 | { 20 | [JsonPropertyName("input")] 21 | public string Input { get; set; } 22 | 23 | [JsonPropertyName("wa_id")] 24 | public string WaId { get; set; } 25 | } 26 | 27 | public class Message 28 | { 29 | [JsonPropertyName("id")] 30 | public string Id { get; set; } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Webhook/QuickReplyButtonMessageReceived.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Webhook 5 | { 6 | /// 7 | /// When your customer clicks on a quick reply button in an interactive message template, a response is sent. 8 | /// 9 | 10 | public class QuickReplyButtonMessage : GenericMessage 11 | { 12 | [JsonPropertyName("context")] 13 | public MessageContext Context { get; set; } 14 | 15 | 16 | [JsonPropertyName("button")] 17 | public QuickReplyButtonMessageButton Button { get; set; } 18 | } 19 | 20 | public class QuickReplyButtonMessageButton 21 | { 22 | [JsonPropertyName("text")] 23 | public string Text { get; set; } 24 | 25 | [JsonPropertyName("payload")] 26 | public string Payload { get; set; } 27 | } 28 | 29 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Media/Requests/UploadMediaDataRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.Media.Requests 4 | { 5 | public class UploadMediaDataRequest 6 | { 7 | [JsonPropertyName("messaging_product")] 8 | public string MessagingProduct { get; private set; } = "whatsapp"; 9 | 10 | /// 11 | /// Name of the file. For example: "file.jpg". 12 | /// 13 | [JsonPropertyName("fileName")] 14 | public string FileName { get; set; } 15 | 16 | /// 17 | /// Type of media file being uploaded. 18 | /// 19 | [JsonPropertyName("type")] 20 | public string Type { get; set; } 21 | 22 | /// 23 | /// Full file content data. 24 | /// 25 | [JsonPropertyName("data")] 26 | public byte[] Data { get; set; } 27 | } 28 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi.Tests/TestSetup.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Configuration; 2 | using Microsoft.Extensions.DependencyInjection; 3 | using System.IO; 4 | 5 | namespace WhatsappBusiness.CloudApi.Tests 6 | { 7 | public class TestSetup 8 | { 9 | public TestSetup() 10 | { 11 | var serviceCollection = new ServiceCollection(); 12 | var configuration = new ConfigurationBuilder() 13 | .SetBasePath(Directory.GetCurrentDirectory()) 14 | .AddJsonFile( 15 | path: "appsettings.json", 16 | optional: false, 17 | reloadOnChange: true) 18 | .Build(); 19 | serviceCollection.AddSingleton(configuration); 20 | 21 | ServiceProvider = serviceCollection.BuildServiceProvider(); 22 | } 23 | 24 | public ServiceProvider ServiceProvider { get; private set; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi.NetFramework.Tests/TestSetup.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Configuration; 2 | using Microsoft.Extensions.DependencyInjection; 3 | using System.IO; 4 | 5 | namespace WhatsappBusiness.CloudApi.NetFramework.Tests 6 | { 7 | public class TestSetup 8 | { 9 | public TestSetup() 10 | { 11 | var serviceCollection = new ServiceCollection(); 12 | var configuration = new ConfigurationBuilder() 13 | .SetBasePath(Directory.GetCurrentDirectory()) 14 | .AddJsonFile( 15 | path: "appsettings.json", 16 | optional: false, 17 | reloadOnChange: true) 18 | .Build(); 19 | serviceCollection.AddSingleton(configuration); 20 | 21 | ServiceProvider = serviceCollection.BuildServiceProvider(); 22 | } 23 | 24 | public ServiceProvider ServiceProvider { get; private set; } 25 | } 26 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Groups/Requests/PinGroupMessageRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.Groups.Requests 4 | { 5 | public class PinGroupMessageRequest 6 | { 7 | [JsonPropertyName("messaging_product")] 8 | public string MessagingProduct { get; private set; } = "whatsapp"; 9 | 10 | [JsonPropertyName("recipient_type")] 11 | public string RecipientType { get; private set; } = "group"; 12 | 13 | [JsonPropertyName("to")] 14 | public string To { get; set; } 15 | 16 | [JsonPropertyName("type")] 17 | public string Type { get; set; } 18 | 19 | [JsonPropertyName("pin")] 20 | public Pin Pin { get; set; } 21 | } 22 | 23 | public class Pin 24 | { 25 | [JsonPropertyName("type")] 26 | public string Type { get; set; } 27 | 28 | [JsonPropertyName("message_id")] 29 | public string MessageId { get; set; } 30 | 31 | [JsonPropertyName("expiration_days")] 32 | public string ExpirationDays { get; set; } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Webhook/UserDeletedMessageStatus.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Webhook 5 | { 6 | /// 7 | /// Currently, the Cloud API does not support webhook status updates for deleted messages. If a user deletes a message, you will receive a webhook with an error code for an unsupported message type 8 | /// 9 | 10 | public class UserDeletedMessage : GenericMessage 11 | { 12 | 13 | [JsonPropertyName("errors")] 14 | public List Errors { get; set; } 15 | } 16 | 17 | public class UserDeletedMessageError 18 | { 19 | [JsonPropertyName("code")] 20 | public long Code { get; set; } 21 | 22 | [JsonPropertyName("details")] 23 | public string Details { get; set; } 24 | 25 | [JsonPropertyName("title")] 26 | public string Title { get; set; } 27 | } 28 | 29 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Webhook/StaticLocationMessageReceived.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.Webhook 4 | { 5 | /// 6 | /// A static location message you received from a customer. 7 | /// 8 | public class LocationMessage:GenericMessage 9 | { 10 | 11 | [JsonPropertyName("location")] 12 | public Location Location { get; set; } 13 | 14 | [JsonPropertyName("context")] 15 | public MessageContext? Context { get; set; } 16 | } 17 | 18 | public class Location 19 | { 20 | [JsonPropertyName("latitude")] 21 | public double Latitude { get; set; } 22 | 23 | [JsonPropertyName("longitude")] 24 | public double Longitude { get; set; } 25 | 26 | [JsonPropertyName("name")] 27 | public string Name { get; set; } 28 | 29 | [JsonPropertyName("address")] 30 | public string Address { get; set; } 31 | } 32 | 33 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Exceptions/WhatsappBusinessCloudAPIException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Net; 3 | using WhatsappBusiness.CloudApi.Response; 4 | 5 | namespace WhatsappBusiness.CloudApi.Exceptions 6 | { 7 | public class WhatsappBusinessCloudAPIException : Exception 8 | { 9 | public HttpStatusCode StatusCode { get; set; } 10 | 11 | public WhatsAppErrorResponse whatsAppErrorResponse { get; set; } 12 | 13 | public WhatsappBusinessCloudAPIException() 14 | { 15 | 16 | } 17 | 18 | public WhatsappBusinessCloudAPIException(HttpStatusCode statusCode, string message) : base(message) 19 | { 20 | StatusCode = statusCode; 21 | } 22 | 23 | public WhatsappBusinessCloudAPIException(Exception ex, HttpStatusCode statusCode, WhatsAppErrorResponse whatsAppError) : base(ex.Message) 24 | { 25 | StatusCode = statusCode; 26 | whatsAppErrorResponse = whatsAppError; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @model ErrorViewModel 2 | @{ 3 | ViewData["Title"] = "Error"; 4 | } 5 | 6 |

Error.

7 |

An error occurred while processing your request.

8 | 9 | @if (Model.ShowRequestId) 10 | { 11 |

12 | Request ID: @Model.RequestId 13 |

14 | } 15 | 16 |

Development Mode

17 |

18 | Swapping to Development environment will display more detailed information about the error that occurred. 19 |

20 |

21 | The Development environment shouldn't be enabled for deployed applications. 22 | It can result in displaying sensitive information from exceptions to end users. 23 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 24 | and restarting the app. 25 |

26 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Webhook/AudioMessageReceived.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.Webhook 4 | { 5 | public class AudioMessage : GenericMessage 6 | { 7 | [JsonPropertyName("audio")] 8 | public Audio Audio { get; set; } 9 | 10 | [JsonPropertyName("context")] 11 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 12 | public MessageContext? Context { get; set; } 13 | } 14 | 15 | public class Audio 16 | { 17 | [JsonPropertyName("mime_type")] 18 | public string MimeType { get; set; } 19 | 20 | [JsonPropertyName("sha256")] 21 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 22 | public string Sha256 { get; set; } 23 | 24 | [JsonPropertyName("id")] 25 | public string Id { get; set; } 26 | 27 | [JsonPropertyName("voice")] 28 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] 29 | public bool Voice { get; set; } 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Messages/ReplyRequests/ReactionMessageReplyRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.Messages.ReplyRequests 4 | { 5 | public class ReactionMessageReplyRequest 6 | { 7 | [JsonPropertyName("messaging_product")] 8 | public string MessagingProduct { get; private set; } = "whatsapp"; 9 | 10 | [JsonPropertyName("recipient_type")] 11 | public string RecipientType { get; private set; } = "individual"; 12 | 13 | [JsonPropertyName("to")] 14 | public string To { get; set; } 15 | 16 | [JsonPropertyName("type")] 17 | public string Type { get; private set; } = "reaction"; 18 | 19 | [JsonPropertyName("reaction")] 20 | public Reaction Reaction { get; set; } 21 | } 22 | 23 | public class Reaction 24 | { 25 | [JsonPropertyName("message_id")] 26 | public string MessageId { get; set; } 27 | 28 | [JsonPropertyName("emoji")] 29 | public string Emoji { get; set; } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Webhook/FlowMessageReceived.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Webhook 5 | { 6 | public class FlowMessageReceived 7 | { 8 | [JsonPropertyName("messages")] 9 | public List Messages { get; set; } 10 | } 11 | 12 | public class FlowMessage : GenericMessage 13 | { 14 | [JsonPropertyName("context")] 15 | public MessageContext Context { get; set; } 16 | 17 | [JsonPropertyName("interactive")] 18 | public FlowInteractive Interactive { get; set; } 19 | } 20 | 21 | public class FlowInteractive 22 | { 23 | [JsonPropertyName("type")] 24 | public string Type { get; set; } 25 | 26 | [JsonPropertyName("nfm_reply")] 27 | public NfmReply NfmReply { get; set; } 28 | } 29 | 30 | public partial class NfmReply 31 | { 32 | [JsonPropertyName("name")] 33 | public string Name { get; set; } 34 | 35 | [JsonPropertyName("body")] 36 | public string Body { get; set; } 37 | 38 | [JsonPropertyName("response_json")] 39 | public string ResponseJson { get; set; } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Webhook/ListReplyButtonMessageReceived.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Webhook 5 | { 6 | 7 | public class ListReplyButtonMessage : GenericMessage 8 | { 9 | [JsonPropertyName("context")] 10 | public MessageContext Context { get; set; } 11 | 12 | [JsonPropertyName("interactive")] 13 | public Interactive Interactive { get; set; } 14 | } 15 | 16 | 17 | public partial class Interactive 18 | { 19 | [JsonPropertyName("type")] 20 | public string Type { get; set; } 21 | 22 | [JsonPropertyName("list_reply")] 23 | public ListReply ListReply { get; set; } 24 | } 25 | 26 | public partial class ListReply 27 | { 28 | [JsonPropertyName("id")] 29 | public string Id { get; set; } 30 | 31 | [JsonPropertyName("title")] 32 | public string Title { get; set; } 33 | 34 | [JsonPropertyName("description")] 35 | public string Description { get; set; } 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Webhook/AccountUpdateEvent.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Webhook 5 | { 6 | public class AccountUpdateEvent 7 | { 8 | [JsonPropertyName("object")] 9 | public string Object { get; set; } 10 | 11 | [JsonPropertyName("entry")] 12 | public List Entry { get; set; } 13 | } 14 | 15 | public class AccountEntry 16 | { 17 | [JsonPropertyName("id")] 18 | public string Id { get; set; } 19 | 20 | [JsonPropertyName("time")] 21 | public long Time { get; set; } 22 | 23 | [JsonPropertyName("changes")] 24 | public List Changes { get; set; } 25 | } 26 | 27 | public class AccountChange 28 | { 29 | [JsonPropertyName("value")] 30 | public Value Value { get; set; } 31 | 32 | [JsonPropertyName("field")] 33 | public string Field { get; set; } 34 | } 35 | 36 | public class Value 37 | { 38 | [JsonPropertyName("phone_number")] 39 | public string PhoneNumber { get; set; } 40 | 41 | [JsonPropertyName("event")] 42 | public string Event { get; set; } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/BusinessProfile/Requests/UpdateBusinessProfileRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.BusinessProfile.Requests 5 | { 6 | public class UpdateBusinessProfileRequest 7 | { 8 | [JsonPropertyName("messaging_product")] 9 | [JsonInclude] 10 | public string MessagingProduct { get; private set; } = "whatsapp"; 11 | 12 | [JsonPropertyName("address")] 13 | public string Address { get; set; } 14 | 15 | [JsonPropertyName("description")] 16 | public string Description { get; set; } 17 | 18 | [JsonPropertyName("vertical")] 19 | public string Vertical { get; set; } 20 | 21 | [JsonPropertyName("email")] 22 | public string Email { get; set; } 23 | 24 | [JsonPropertyName("websites")] 25 | public List Websites { get; set; } 26 | 27 | [JsonPropertyName("profile_picture_handle")] 28 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 29 | public string ProfilePictureHandle { get; set; } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /License: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Gabriel Odero 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/Views/Shared/_Layout.cshtml.css: -------------------------------------------------------------------------------- 1 | /* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2 | for details on configuring this project to bundle and minify static web assets. */ 3 | 4 | a.navbar-brand { 5 | white-space: normal; 6 | text-align: center; 7 | word-break: break-all; 8 | } 9 | 10 | a { 11 | color: #0077cc; 12 | } 13 | 14 | .btn-primary { 15 | color: #fff; 16 | background-color: #1b6ec2; 17 | border-color: #1861ac; 18 | } 19 | 20 | .nav-pills .nav-link.active, .nav-pills .show > .nav-link { 21 | color: #fff; 22 | background-color: #1b6ec2; 23 | border-color: #1861ac; 24 | } 25 | 26 | .border-top { 27 | border-top: 1px solid #e5e5e5; 28 | } 29 | .border-bottom { 30 | border-bottom: 1px solid #e5e5e5; 31 | } 32 | 33 | .box-shadow { 34 | box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05); 35 | } 36 | 37 | button.accept-policy { 38 | font-size: 1rem; 39 | line-height: inherit; 40 | } 41 | 42 | .footer { 43 | position: absolute; 44 | bottom: 0; 45 | width: 100%; 46 | white-space: nowrap; 47 | line-height: 60px; 48 | } 49 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Response/BusinessProfileResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Response 5 | { 6 | public class BusinessProfileResponse 7 | { 8 | [JsonPropertyName("data")] 9 | public List Data { get; set; } 10 | } 11 | 12 | public class BusinessProfileData 13 | { 14 | [JsonPropertyName("messaging_product")] 15 | public string MessagingProduct { get; set; } 16 | 17 | [JsonPropertyName("address")] 18 | public string Address { get; set; } 19 | 20 | [JsonPropertyName("description")] 21 | public string Description { get; set; } 22 | 23 | [JsonPropertyName("vertical")] 24 | public string Vertical { get; set; } 25 | 26 | [JsonPropertyName("about")] 27 | public string About { get; set; } 28 | 29 | [JsonPropertyName("email")] 30 | public string Email { get; set; } 31 | 32 | [JsonPropertyName("websites")] 33 | public List Websites { get; set; } 34 | 35 | [JsonPropertyName("profile_picture_url")] 36 | public string ProfilePictureUrl { get; set; } 37 | } 38 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Webhook/ProductEnquiryMessageReceived.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Webhook 5 | { 6 | 7 | 8 | public class ProductEnquiryMessage : GenericMessage 9 | { 10 | [JsonPropertyName("context")] 11 | public ProductEnquiryContext Context { get; set; } 12 | 13 | [JsonPropertyName("text")] 14 | public ProductEnquiryText Text { get; set; } 15 | 16 | } 17 | 18 | public class ProductEnquiryContext : MessageContext 19 | { 20 | [JsonPropertyName("referred_product")] 21 | public ReferredProduct ReferredProduct { get; set; } 22 | } 23 | 24 | public partial class ReferredProduct 25 | { 26 | [JsonPropertyName("catalog_id")] 27 | public string CatalogId { get; set; } 28 | 29 | [JsonPropertyName("product_retailer_id")] 30 | public string ProductRetailerId { get; set; } 31 | } 32 | 33 | public class ProductEnquiryText 34 | { 35 | [JsonPropertyName("body")] 36 | public string Body { get; set; } 37 | } 38 | 39 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi.Tests/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "WhatsAppBusinessCloudApiConfiguration": { 3 | "WhatsAppBusinessPhoneNumberId": "YOUR_PHONE_NUMBER_ID", 4 | "WhatsAppBusinessAccountId": "YOUR_WABA_ID", 5 | "WhatsAppBusinessId": "YOUR_BUSINESS_ID", 6 | "AccessToken": "YOUR_ACCESS_TOKEN", 7 | "Version": "v23.0", 8 | "WebhookVerifyToken": "" 9 | }, 10 | "SharedWhatsAppBusinessCloudApiConfigurations": [ 11 | { 12 | "WhatsAppBusinessPhoneNumberId": "SHARED_PHONE_NUMBER_ID", 13 | "WhatsAppBusinessAccountId": "SHARED_WABA_ID", 14 | "WhatsAppBusinessId": "", 15 | "AccessToken": "BUSINESS_INTEGRATION_SYSTEM_USER_ACCESS_TOKEN", 16 | "Version": "v23.0", 17 | "WebhookVerifyToken": "" 18 | } 19 | ], 20 | "EmbeddedSignupConfiguration": { 21 | "AppId": "YOUR_APP_ID", 22 | "AppSecret": "YOUR_APP_SECRET", 23 | "ConfigurationId": "YOUR_EMBEDDED_SIGNUP_CONFIGURATION_ID", 24 | "GraphApiVersion": "v23.0", 25 | "BaseUrl": "" 26 | }, 27 | "Logging": { 28 | "LogLevel": { 29 | "Default": "Information", 30 | "Microsoft.AspNetCore": "Warning" 31 | } 32 | }, 33 | "AllowedHosts": "*" 34 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Webhook/ReplyButtonMessageReceived.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Webhook 5 | { 6 | /// 7 | /// When your customer clicks on a quick reply button in an interactive message template, a response is sent. 8 | /// 9 | public class ReplyButtonMessage:GenericMessage 10 | { 11 | [JsonPropertyName("context")] 12 | public MessageContext Context { get; set; } 13 | 14 | 15 | [JsonPropertyName("interactive")] 16 | public ReplyButtonMessageInteractive Interactive { get; set; } 17 | } 18 | 19 | 20 | public class ReplyButtonMessageInteractive 21 | { 22 | [JsonPropertyName("type")] 23 | public string Type { get; set; } 24 | 25 | [JsonPropertyName("button_reply")] 26 | public ButtonReply ButtonReply { get; set; } 27 | } 28 | 29 | public class ButtonReply 30 | { 31 | [JsonPropertyName("id")] 32 | public string Id { get; set; } 33 | 34 | [JsonPropertyName("title")] 35 | public string Title { get; set; } 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Response/ConversationalComponentResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Response 5 | { 6 | public class ConversationalComponentResponse 7 | { 8 | [JsonPropertyName("conversational_automation")] 9 | public ConversationalAutomation ConversationalAutomation { get; set; } 10 | 11 | [JsonPropertyName("id")] 12 | public string Id { get; set; } 13 | } 14 | 15 | public class ConversationalAutomation 16 | { 17 | [JsonPropertyName("enable_welcome_message")] 18 | public bool EnableWelcomeMessage { get; set; } 19 | 20 | [JsonPropertyName("prompts")] 21 | public List Prompts { get; set; } 22 | 23 | [JsonPropertyName("commands")] 24 | public List Commands { get; set; } 25 | } 26 | 27 | public class ConversationalCommand 28 | { 29 | [JsonPropertyName("command_name")] 30 | public string CommandName { get; set; } 31 | 32 | [JsonPropertyName("command_description")] 33 | public string CommandDescription { get; set; } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/wwwroot/lib/jquery-validation/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright Jörn Zaefferer 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/Extensions/Alerts/AlertExtension.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | 3 | namespace WhatsAppBusinessCloudAPI.Web.Extensions.Alerts 4 | { 5 | public static class AlertExtension 6 | { 7 | public static IActionResult WithSuccess(this IActionResult result, string title, string body) 8 | { 9 | return Alert(result, "success", title, body); 10 | } 11 | 12 | public static IActionResult WithInfo(this IActionResult result, string title, string body) 13 | { 14 | return Alert(result, "info", title, body); 15 | } 16 | 17 | public static IActionResult WithWarning(this IActionResult result, string title, string body) 18 | { 19 | return Alert(result, "warning", title, body); 20 | } 21 | 22 | public static IActionResult WithDanger(this IActionResult result, string title, string body) 23 | { 24 | return Alert(result, "danger", title, body); 25 | } 26 | 27 | private static IActionResult Alert(IActionResult result, string type, string title, string body) 28 | { 29 | return new AlertDecoratorResult(result, type, title, body); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Messages/Requests/ImageMessageByIdRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.Messages.Requests 4 | { 5 | public class ImageMessageByIdRequest 6 | { 7 | [JsonPropertyName("messaging_product")] 8 | [JsonInclude] 9 | public string MessagingProduct { get; private set; } = "whatsapp"; 10 | 11 | [JsonPropertyName("recipient_type")] 12 | [JsonInclude] 13 | public string RecipientType { get; set; } = "individual"; 14 | 15 | [JsonPropertyName("to")] 16 | public string To { get; set; } 17 | 18 | [JsonPropertyName("type")] 19 | [JsonInclude] 20 | public string Type { get; private set; } = "image"; 21 | 22 | [JsonPropertyName("image")] 23 | public MediaImage Image { get; set; } 24 | 25 | [JsonPropertyName("biz_opaque_callback_data")] 26 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 27 | public string BizOpaqueCallbackData { get; set; } 28 | } 29 | 30 | public class MediaImage 31 | { 32 | [JsonPropertyName("id")] 33 | public string Id { get; set; } 34 | 35 | [JsonPropertyName("caption")] 36 | public string Caption { get; set; } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Messages/Requests/TextMessageRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.Messages.Requests 4 | { 5 | public class TextMessageRequest 6 | { 7 | [JsonPropertyName("messaging_product")] 8 | [JsonInclude] 9 | public string MessagingProduct { get; private set; } = "whatsapp"; 10 | 11 | [JsonPropertyName("recipient_type")] 12 | [JsonInclude] 13 | public string RecipientType { get; set; } = "individual"; 14 | 15 | [JsonPropertyName("to")] 16 | public string To { get; set; } 17 | 18 | [JsonPropertyName("type")] 19 | [JsonInclude] 20 | public string Type { get; private set; } = "text"; 21 | 22 | [JsonPropertyName("text")] 23 | public WhatsAppText Text { get; set; } 24 | 25 | [JsonPropertyName("biz_opaque_callback_data")] 26 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 27 | public string BizOpaqueCallbackData { get; set; } 28 | } 29 | 30 | public class WhatsAppText 31 | { 32 | [JsonPropertyName("preview_url")] 33 | public bool PreviewUrl { get; set; } 34 | 35 | [JsonPropertyName("body")] 36 | public string Body { get; set; } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Messages/Requests/VideoMessageByIdRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.Messages.Requests 4 | { 5 | public class VideoMessageByIdRequest 6 | { 7 | [JsonPropertyName("messaging_product")] 8 | [JsonInclude] 9 | public string MessagingProduct { get; private set; } = "whatsapp"; 10 | 11 | [JsonPropertyName("recipient_type")] 12 | [JsonInclude] 13 | public string RecipientType { get; set; } = "individual"; 14 | 15 | [JsonPropertyName("to")] 16 | public string To { get; set; } 17 | 18 | [JsonPropertyName("type")] 19 | [JsonInclude] 20 | public string Type { get; private set; } = "video"; 21 | 22 | [JsonPropertyName("video")] 23 | public MediaVideo Video { get; set; } 24 | 25 | [JsonPropertyName("biz_opaque_callback_data")] 26 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 27 | public string BizOpaqueCallbackData { get; set; } 28 | } 29 | 30 | public class MediaVideo 31 | { 32 | [JsonPropertyName("caption")] 33 | public string Caption { get; set; } 34 | 35 | [JsonPropertyName("id")] 36 | public string Id { get; set; } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/wwwroot/lib/bootstrap/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2011-2021 Twitter, Inc. 4 | Copyright (c) 2011-2021 The Bootstrap Authors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Messages/Requests/ImageMessageByUrlRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.Messages.Requests 4 | { 5 | public class ImageMessageByUrlRequest 6 | { 7 | [JsonPropertyName("messaging_product")] 8 | [JsonInclude] 9 | public string MessagingProduct { get; private set; } = "whatsapp"; 10 | 11 | [JsonPropertyName("recipient_type")] 12 | [JsonInclude] 13 | public string RecipientType { get; set; } = "individual"; 14 | 15 | [JsonPropertyName("to")] 16 | public string To { get; set; } 17 | 18 | [JsonPropertyName("type")] 19 | [JsonInclude] 20 | public string Type { get; private set; } = "image"; 21 | 22 | [JsonPropertyName("image")] 23 | public MediaImageUrl Image { get; set; } 24 | 25 | [JsonPropertyName("biz_opaque_callback_data")] 26 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 27 | public string BizOpaqueCallbackData { get; set; } 28 | } 29 | 30 | public class MediaImageUrl 31 | { 32 | [JsonPropertyName("link")] 33 | public string Link { get; set; } 34 | 35 | [JsonPropertyName("caption")] 36 | public string Caption { get; set; } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Messages/Requests/VideoMessageByUrlRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.Messages.Requests 4 | { 5 | public class VideoMessageByUrlRequest 6 | { 7 | [JsonPropertyName("messaging_product")] 8 | [JsonInclude] 9 | public string MessagingProduct { get; private set; } = "whatsapp"; 10 | 11 | [JsonPropertyName("recipient_type")] 12 | [JsonInclude] 13 | public string RecipientType { get; set; } = "individual"; 14 | 15 | [JsonPropertyName("to")] 16 | public string To { get; set; } 17 | 18 | [JsonPropertyName("type")] 19 | [JsonInclude] 20 | public string Type { get; private set; } = "video"; 21 | 22 | [JsonPropertyName("video")] 23 | public MediaVideoUrl Video { get; set; } 24 | 25 | [JsonPropertyName("biz_opaque_callback_data")] 26 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 27 | public string BizOpaqueCallbackData { get; set; } 28 | } 29 | 30 | public class MediaVideoUrl 31 | { 32 | [JsonPropertyName("link")] 33 | public string Link { get; set; } 34 | 35 | [JsonPropertyName("caption")] 36 | public string Caption { get; set; } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Calls/Requests/CallRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.Calls.Requests 4 | { 5 | public class CallRequest 6 | { 7 | [JsonPropertyName("messaging_product")] 8 | [JsonInclude] 9 | public string MessagingProduct { get; private set; } = "whatsapp"; 10 | 11 | [JsonPropertyName("to")] 12 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 13 | public string To { get; set; } 14 | 15 | [JsonPropertyName("call_id")] 16 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 17 | public string CallId { get; set; } 18 | 19 | [JsonPropertyName("action")] 20 | public string Action { get; set; } 21 | 22 | [JsonPropertyName("session")] 23 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 24 | public CallSession Session { get; set; } 25 | 26 | [JsonPropertyName("biz_opaque_callback_data")] 27 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 28 | public string BizOpaqueCallbackData { get; set; } 29 | } 30 | 31 | public class CallSession 32 | { 33 | [JsonPropertyName("sdp_type")] 34 | [JsonInclude] 35 | public string SdpType { get; private set; } = "offer"; 36 | 37 | [JsonPropertyName("sdp")] 38 | public string Sdp { get; set; } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Webhook/ImageMessageReceived.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | 5 | namespace WhatsappBusiness.CloudApi.Webhook 6 | { 7 | /// 8 | /// When a message with media is received, the WhatsApp Business API downloads the media. A notification is sent to your Webhook once the media is downloaded. 9 | /// The Webhook notification contains information that identifies the media object and enables you to find and retrieve the object. Use the media endpoints to retrieve the media. 10 | /// 11 | 12 | 13 | 14 | public class ImageMessage: GenericMessage 15 | { 16 | 17 | [JsonPropertyName("image")] 18 | public Image Image { get; set; } 19 | 20 | [JsonPropertyName("context")] 21 | public MessageContext? Context { get; set; } 22 | } 23 | 24 | public class Image 25 | { 26 | [JsonPropertyName("caption")] 27 | public string Caption { get; set; } 28 | 29 | [JsonPropertyName("mime_type")] 30 | public string MimeType { get; set; } 31 | 32 | [JsonPropertyName("sha256")] 33 | public string Sha256 { get; set; } 34 | 35 | [JsonPropertyName("id")] 36 | public string Id { get; set; } 37 | } 38 | 39 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Messages/Requests/AudioMessageByUrlRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.Messages.Requests 4 | { 5 | public class AudioMessageByUrlRequest 6 | { 7 | [JsonPropertyName("messaging_product")] 8 | [JsonInclude] 9 | public string MessagingProduct { get; private set; } = "whatsapp"; 10 | 11 | [JsonPropertyName("recipient_type")] 12 | [JsonInclude] 13 | public string RecipientType { get; set; } = "individual"; 14 | 15 | [JsonPropertyName("to")] 16 | public string To { get; set; } 17 | 18 | [JsonPropertyName("type")] 19 | [JsonInclude] 20 | public string Type { get; private set; } = "audio"; 21 | 22 | [JsonPropertyName("audio")] 23 | public MediaAudioUrl Audio { get; set; } 24 | 25 | [JsonPropertyName("biz_opaque_callback_data")] 26 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 27 | public string BizOpaqueCallbackData { get; set; } 28 | } 29 | 30 | public class MediaAudioUrl 31 | { 32 | [JsonPropertyName("link")] 33 | public string Link { get; set; } 34 | 35 | [JsonPropertyName("voice")] 36 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] 37 | public bool Voice { get; set; } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Webhook/ProductOrderMessageReceived.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Webhook 5 | { 6 | 7 | public class ProductOrderMessageMessage:GenericMessage 8 | { 9 | 10 | [JsonPropertyName("order")] 11 | public Order Order { get; set; } 12 | 13 | [JsonPropertyName("context")] 14 | public MessageContext Context { get; set; } 15 | } 16 | 17 | public class Order 18 | { 19 | [JsonPropertyName("catalog_id")] 20 | public string CatalogId { get; set; } 21 | 22 | [JsonPropertyName("product_items")] 23 | public List ProductItems { get; set; } 24 | 25 | [JsonPropertyName("text")] 26 | public string Text { get; set; } 27 | } 28 | 29 | public class ProductItem 30 | { 31 | [JsonPropertyName("product_retailer_id")] 32 | public string ProductRetailerId { get; set; } 33 | 34 | [JsonPropertyName("quantity")] 35 | public string Quantity { get; set; } 36 | 37 | [JsonPropertyName("item_price")] 38 | public string ItemPrice { get; set; } 39 | 40 | [JsonPropertyName("currency")] 41 | public string Currency { get; set; } 42 | } 43 | 44 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Messages/Requests/AudioMessageByIdRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.Messages.Requests 4 | { 5 | public class AudioMessageByIdRequest 6 | { 7 | [JsonPropertyName("messaging_product")] 8 | [JsonInclude] 9 | public string MessagingProduct { get; private set; } = "whatsapp"; 10 | 11 | [JsonPropertyName("recipient_type")] 12 | [JsonInclude] 13 | public string RecipientType { get; set; } = "individual"; 14 | 15 | [JsonPropertyName("to")] 16 | public string To { get; set; } 17 | 18 | [JsonPropertyName("type")] 19 | [JsonInclude] 20 | public string Type { get; private set; } = "audio"; 21 | 22 | [JsonPropertyName("audio")] 23 | public MediaAudio Audio { get; set; } 24 | 25 | [JsonPropertyName("biz_opaque_callback_data")] 26 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 27 | public string BizOpaqueCallbackData { get; set; } 28 | } 29 | 30 | public class MediaAudio 31 | { 32 | [JsonPropertyName("id")] 33 | public string Id { get; set; } 34 | 35 | [JsonPropertyName("voice")] 36 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] 37 | public bool Voice { get; set; } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Messages/Requests/StickerMessageByIdRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.Messages.Requests 4 | { 5 | public class StickerMessageByIdRequest 6 | { 7 | [JsonPropertyName("messaging_product")] 8 | [JsonInclude] 9 | public string MessagingProduct { get; private set; } = "whatsapp"; 10 | 11 | [JsonPropertyName("recipient_type")] 12 | [JsonInclude] 13 | public string RecipientType { get; set; } = "individual"; 14 | 15 | [JsonPropertyName("to")] 16 | public string To { get; set; } 17 | 18 | [JsonPropertyName("type")] 19 | [JsonInclude] 20 | public string Type { get; private set; } = "sticker"; 21 | 22 | [JsonPropertyName("sticker")] 23 | public MediaSticker Sticker { get; set; } 24 | 25 | [JsonPropertyName("biz_opaque_callback_data")] 26 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 27 | public string BizOpaqueCallbackData { get; set; } 28 | } 29 | 30 | public class MediaSticker 31 | { 32 | [JsonPropertyName("id")] 33 | public string Id { get; set; } 34 | 35 | [JsonPropertyName("animated")] 36 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] 37 | public bool Animated { get; set; } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Messages/Requests/DocumentMessageByIdRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.Messages.Requests 4 | { 5 | public class DocumentMessageByIdRequest 6 | { 7 | [JsonPropertyName("messaging_product")] 8 | public string MessagingProduct { get; private set; } = "whatsapp"; 9 | 10 | [JsonPropertyName("recipient_type")] 11 | public string RecipientType { get; set; } = "individual"; 12 | 13 | [JsonPropertyName("to")] 14 | public string To { get; set; } 15 | 16 | [JsonPropertyName("type")] 17 | public string Type { get; private set; } = "document"; 18 | 19 | [JsonPropertyName("document")] 20 | public MediaDocument Document { get; set; } 21 | 22 | [JsonPropertyName("biz_opaque_callback_data")] 23 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 24 | public string BizOpaqueCallbackData { get; set; } 25 | } 26 | 27 | public class MediaDocument 28 | { 29 | [JsonPropertyName("id")] 30 | public string Id { get; set; } 31 | 32 | [JsonPropertyName("caption")] 33 | public string Caption { get; set; } 34 | 35 | [JsonPropertyName("filename")] 36 | public string Filename { get; set; } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Messages/Requests/StickerMessageByUrlRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.Messages.Requests 4 | { 5 | public class StickerMessageByUrlRequest 6 | { 7 | [JsonPropertyName("messaging_product")] 8 | [JsonInclude] 9 | public string MessagingProduct { get; private set; } = "whatsapp"; 10 | 11 | [JsonPropertyName("recipient_type")] 12 | [JsonInclude] 13 | public string RecipientType { get; set; } = "individual"; 14 | 15 | [JsonPropertyName("to")] 16 | public string To { get; set; } 17 | 18 | [JsonPropertyName("type")] 19 | [JsonInclude] 20 | public string Type { get; private set; } = "sticker"; 21 | 22 | [JsonPropertyName("sticker")] 23 | public MediaStickerUrl Sticker { get; set; } 24 | 25 | [JsonPropertyName("biz_opaque_callback_data")] 26 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 27 | public string BizOpaqueCallbackData { get; set; } 28 | } 29 | 30 | public class MediaStickerUrl 31 | { 32 | [JsonPropertyName("link")] 33 | public string Link { get; set; } 34 | 35 | [JsonPropertyName("animated")] 36 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] 37 | public bool Animated { get; set; } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Groups/Requests/GroupRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Groups.Requests 5 | { 6 | public class GroupRequest 7 | { 8 | [JsonPropertyName("messaging_product")] 9 | [JsonInclude] 10 | public string MessagingProduct { get; private set; } = "whatsapp"; 11 | 12 | [JsonPropertyName("subject")] 13 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 14 | public string Subject { get; set; } 15 | 16 | [JsonPropertyName("description")] 17 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 18 | public string Description { get; set; } 19 | 20 | [JsonPropertyName("profile_picture_file")] 21 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 22 | public string profilePictureFile { get; set; } 23 | 24 | [JsonPropertyName("join_approval_mode")] 25 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 26 | public string JoinApprovalMode { get; set; } 27 | 28 | [JsonPropertyName("participants")] 29 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 30 | public List Participants { get; set; } 31 | } 32 | 33 | public class Participant 34 | { 35 | [JsonPropertyName("user")] 36 | public string User { get; set; } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Response/AnalyticsResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Response 5 | { 6 | public class AnalyticsResponse 7 | { 8 | [JsonPropertyName("analytics")] 9 | public Analytics Analytics { get; set; } 10 | 11 | [JsonPropertyName("id")] 12 | public string Id { get; set; } 13 | } 14 | 15 | public class Analytics 16 | { 17 | [JsonPropertyName("phone_numbers")] 18 | public List PhoneNumbers { get; set; } 19 | 20 | [JsonPropertyName("country_codes")] 21 | public List CountryCodes { get; set; } 22 | 23 | [JsonPropertyName("granularity")] 24 | public string Granularity { get; set; } 25 | 26 | [JsonPropertyName("data_points")] 27 | public List DataPoints { get; set; } 28 | } 29 | 30 | public class AnalyticsDataPoint 31 | { 32 | [JsonPropertyName("start")] 33 | public long Start { get; set; } 34 | 35 | [JsonPropertyName("end")] 36 | public long End { get; set; } 37 | 38 | [JsonPropertyName("sent")] 39 | public long Sent { get; set; } 40 | 41 | [JsonPropertyName("delivered")] 42 | public long Delivered { get; set; } 43 | } 44 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Messages/Requests/DocumentMessageByUrlRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.Messages.Requests 4 | { 5 | public class DocumentMessageByUrlRequest 6 | { 7 | [JsonPropertyName("messaging_product")] 8 | [JsonInclude] 9 | public string MessagingProduct { get; private set; } = "whatsapp"; 10 | 11 | [JsonPropertyName("recipient_type")] 12 | [JsonInclude] 13 | public string RecipientType { get; set; } = "individual"; 14 | 15 | [JsonPropertyName("to")] 16 | public string To { get; set; } 17 | 18 | [JsonPropertyName("type")] 19 | [JsonInclude] 20 | public string Type { get; private set; } = "document"; 21 | 22 | [JsonPropertyName("document")] 23 | public MediaDocumentUrl Document { get; set; } 24 | 25 | [JsonPropertyName("biz_opaque_callback_data")] 26 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 27 | public string BizOpaqueCallbackData { get; set; } 28 | } 29 | 30 | public class MediaDocumentUrl 31 | { 32 | [JsonPropertyName("link")] 33 | public string Link { get; set; } 34 | 35 | [JsonPropertyName("caption")] 36 | public string Caption { get; set; } 37 | 38 | [JsonPropertyName("filename")] 39 | public string Filename { get; set; } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Webhook/StickerMessageReceived.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Webhook 5 | { 6 | /// 7 | /// When you receive a media message containing a sticker, WhatsApp Business API downloads the sticker and a notification is sent to your Webhook once the sticker is downloaded. 8 | /// The Webhook notification contains information that identifies the media object and allows you to find and retrieve the object. Use the media endpoints to retrieve the media. 9 | /// 10 | 11 | 12 | public class StickerMessage : GenericMessage 13 | { 14 | 15 | [JsonPropertyName("sticker")] 16 | public Sticker Sticker { get; set; } 17 | 18 | [JsonPropertyName("context")] 19 | public MessageContext? Context { get; set; } 20 | } 21 | 22 | public class Sticker 23 | { 24 | [JsonPropertyName("id")] 25 | public string Id { get; set; } 26 | 27 | [JsonPropertyName("mime_type")] 28 | public string MimeType { get; set; } 29 | 30 | [JsonPropertyName("sha256")] 31 | public string Sha256 { get; set; } 32 | 33 | [JsonPropertyName("animated")] 34 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] 35 | public bool Animated { get; set; } 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/Views/Home/QRCodeMessageList.cshtml: -------------------------------------------------------------------------------- 1 | @model IEnumerable 2 | @{ 3 | ViewData["Title"] = "QR Code Message List"; 4 | ViewData["CurrentPage"] = "QR Code Message List"; 5 | Layout = "~/Views/Shared/AdminLTE/_AdminLayout.cshtml"; 6 | ViewData["ControllerName"] = nameof(HomeController).Replace("Controller", ""); 7 | ViewData["ActionName"] = nameof(HomeController.QRCodeMessageList); 8 | int counter = 0; 9 | } 10 | 11 |
12 |
13 | @if (Model.Any()) 14 | { 15 | @foreach (var item in Model) 16 | { 17 | if (counter != 0 && counter % 3 == 0) 18 | { 19 | @:
20 | @:
21 | @:
22 | } 23 |
24 |
25 |
26 |

QR Code Message List

27 |
28 |
29 |
@item.Code
30 |
31 |
@item.PrefilledMessage
32 |
33 |
34 |
35 |
36 | counter++; 37 | } 38 | } 39 |
40 |
41 | 42 | @section Scripts { 43 | @{ 44 | await Html.RenderPartialAsync("_ValidationScriptsPartial"); 45 | } 46 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Messages/Requests/BaseCreateTemplateMessageRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Messages.Requests 5 | { 6 | public class BaseCreateTemplateMessageRequest 7 | { 8 | [JsonPropertyName("name")] 9 | public string Name { get; set; } 10 | 11 | [JsonPropertyName("category")] 12 | public string Category { get; set; } 13 | 14 | [JsonPropertyName("parameter_format")] // named or positional 15 | public string ParameterFormat { get; set; } 16 | 17 | [JsonPropertyName("allow_category_change")] 18 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] 19 | public bool? AllowCategoryChange { get; set; } 20 | 21 | [JsonPropertyName("language")] 22 | public string Language { get; set; } 23 | 24 | [JsonPropertyName("library_template_name")] 25 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 26 | public string? LibraryTemplateName { get; set; } 27 | 28 | [JsonPropertyName("LIBRARY_TEMPLATE_BUTTON_INPUTS")] 29 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 30 | public List? LibraryTemplateButtonInputs { get; set; } 31 | 32 | [JsonPropertyName("components")] 33 | public List Components { get; set; } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Webhook/VideoMessageReceived.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Webhook 5 | { 6 | /// 7 | /// When a message with media is received, the WhatsApp Business API downloads the media. A notification is sent to your Webhook once the media is downloaded. 8 | /// The Webhook notification contains information that identifies the media object and enables you to find and retrieve the object. Use the media endpoints to retrieve the media. 9 | /// 10 | 11 | public class VideoMessage : GenericMessage 12 | { 13 | 14 | [JsonPropertyName("video")] 15 | public Video Video { get; set; } 16 | 17 | [JsonPropertyName("context")] 18 | public MessageContext? Context { get; set; } 19 | } 20 | 21 | public class Video 22 | { 23 | [JsonPropertyName("caption")] 24 | public string Caption { get; set; } 25 | 26 | [JsonPropertyName("filename")] 27 | public string Filename { get; set; } 28 | 29 | [JsonPropertyName("mime_type")] 30 | public string MimeType { get; set; } 31 | 32 | [JsonPropertyName("sha256")] 33 | public string Sha256 { get; set; } 34 | 35 | [JsonPropertyName("id")] 36 | public string Id { get; set; } 37 | } 38 | 39 | } 40 | 41 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Response/WhatsAppErrorResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.Response 4 | { 5 | public class WhatsAppErrorResponse 6 | { 7 | [JsonPropertyName("error")] 8 | public Error Error { get; set; } 9 | } 10 | 11 | public class Error 12 | { 13 | [JsonPropertyName("message")] 14 | public string Message { get; set; } 15 | 16 | [JsonPropertyName("type")] 17 | public string Type { get; set; } 18 | 19 | [JsonPropertyName("code")] 20 | public long Code { get; set; } 21 | 22 | [JsonPropertyName("error_user_title")] 23 | public string? ErrorUserTitle { get; set; } 24 | 25 | [JsonPropertyName("error_user_msg")] 26 | public string? ErrorUserMsg { get; set; } 27 | 28 | [JsonPropertyName("error_data")] 29 | public ErrorData? ErrorData { get; set; } 30 | 31 | [JsonPropertyName("error_subcode")] 32 | public long? ErrorSubcode { get; set; } 33 | 34 | [JsonPropertyName("fbtrace_id")] 35 | public string FbtraceId { get; set; } 36 | } 37 | 38 | public class ErrorData 39 | { 40 | [JsonPropertyName("messaging_product")] 41 | public string MessagingProduct { get; set; } 42 | 43 | [JsonPropertyName("details")] 44 | public string Details { get; set; } 45 | } 46 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Webhook/DocumentMessageReceived.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Webhook 5 | { 6 | /// 7 | /// When a message with media is received, the WhatsApp Business API downloads the media. A notification is sent to your Webhook once the media is downloaded. 8 | /// The Webhook notification contains information that identifies the media object and enables you to find and retrieve the object. Use the media endpoints to retrieve the media. 9 | /// 10 | 11 | 12 | public class DocumentMessage : GenericMessage 13 | { 14 | 15 | [JsonPropertyName("document")] 16 | public Document Document { get; set; } 17 | 18 | [JsonPropertyName("context")] 19 | public MessageContext? Context { get; set; } 20 | } 21 | 22 | public class Document 23 | { 24 | [JsonPropertyName("caption")] 25 | public string Caption { get; set; } 26 | 27 | [JsonPropertyName("filename")] 28 | public string Filename { get; set; } 29 | 30 | [JsonPropertyName("mime_type")] 31 | public string MimeType { get; set; } 32 | 33 | [JsonPropertyName("sha256")] 34 | public string Sha256 { get; set; } 35 | 36 | [JsonPropertyName("id")] 37 | public string Id { get; set; } 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Response/WhatsAppBusinessHSMWhatsAppHSMComponentGet.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Response 5 | { 6 | public class WhatsAppBusinessHSMWhatsAppHSMComponentGet 7 | { 8 | [JsonPropertyName("add_security_recommendation")] 9 | public bool AddSecurityRecommendation { get; set; } 10 | 11 | [JsonPropertyName("code_expiration_minutes")] 12 | public int CodeExpirationMinutes { get; set; } 13 | 14 | [JsonPropertyName("example")] 15 | public object Example { get; set; } 16 | 17 | [JsonPropertyName("format")] 18 | public string Format { get; set; } 19 | 20 | [JsonPropertyName("text")] 21 | public string Text { get; set; } 22 | 23 | [JsonPropertyName("type")] 24 | public string Type { get; set; } 25 | 26 | [JsonPropertyName("buttons")] 27 | public List Buttons { get; set; } 28 | } 29 | 30 | public class TemplateButton 31 | { 32 | [JsonPropertyName("type")] 33 | public string Type { get; set; } 34 | 35 | [JsonPropertyName("text")] 36 | public string Text { get; set; } 37 | 38 | [JsonPropertyName("url")] 39 | public string Url { get; set; } // For URL type buttons 40 | 41 | [JsonPropertyName("phone_number")] 42 | public string PhoneNumber { get; set; } // For PHONE_NUMBER type buttons 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi.NetFramework/WhatsApp/Requests/ExchangeTokenRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.NetFramework.WhatsApp.Requests 4 | { 5 | /// 6 | /// Request model for exchanging authorization code for access token 7 | /// 8 | public class ExchangeTokenRequest 9 | { 10 | /// 11 | /// Grant type for OAuth flow 12 | /// 13 | [JsonPropertyName("grant_type")] 14 | public string GrantType { get; set; } = "authorization_code"; 15 | 16 | /// 17 | /// Client ID (App ID) 18 | /// 19 | [JsonPropertyName("client_id")] 20 | public string ClientId { get; set; } 21 | 22 | /// 23 | /// Client Secret (App Secret) 24 | /// 25 | [JsonPropertyName("client_secret")] 26 | public string ClientSecret { get; set; } 27 | 28 | /// 29 | /// Authorization code received from OAuth flow 30 | /// 31 | [JsonPropertyName("code")] 32 | public string Code { get; set; } 33 | 34 | /// 35 | /// Redirect URI used in OAuth flow 36 | /// 37 | [JsonPropertyName("redirect_uri")] 38 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 39 | public string RedirectUri { get; set; } 40 | } 41 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Messages/Requests/LocationMessageRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.Messages.Requests 4 | { 5 | public class LocationMessageRequest 6 | { 7 | [JsonPropertyName("messaging_product")] 8 | [JsonInclude] 9 | public string MessagingProduct { get; private set; } = "whatsapp"; 10 | 11 | [JsonPropertyName("recipient_type")] 12 | [JsonInclude] 13 | public string RecipientType { get; private set; } = "individual"; 14 | 15 | [JsonPropertyName("to")] 16 | public string To { get; set; } 17 | 18 | [JsonPropertyName("type")] 19 | [JsonInclude] 20 | public string Type { get; private set; } = "location"; 21 | 22 | [JsonPropertyName("location")] 23 | public Location Location { get; set; } 24 | 25 | [JsonPropertyName("biz_opaque_callback_data")] 26 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 27 | public string BizOpaqueCallbackData { get; set; } 28 | } 29 | 30 | public class Location 31 | { 32 | [JsonPropertyName("longitude")] 33 | public double Longitude { get; set; } 34 | 35 | [JsonPropertyName("latitude")] 36 | public double Latitude { get; set; } 37 | 38 | [JsonPropertyName("name")] 39 | public string Name { get; set; } 40 | 41 | [JsonPropertyName("address")] 42 | public string Address { get; set; } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi.Tests/WhatsappBusiness.CloudApi.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net472 5 | false 6 | 7 | 8 | 9 | 10 | PreserveNewest 11 | true 12 | PreserveNewest 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi.NetFramework.Tests/WhatsappBusiness.CloudApi.NetFramework.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net472 5 | false 6 | 7.3 7 | 8 | 9 | 10 | 11 | PreserveNewest 12 | true 13 | PreserveNewest 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/libman.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0", 3 | "defaultProvider": "cdnjs", 4 | "libraries": [ 5 | { 6 | "library": "font-awesome@6.7.2", 7 | "destination": "wwwroot/lib/font-awesome/", 8 | "files": [ 9 | "css/all.min.css", 10 | "webfonts/fa-brands-400.ttf", 11 | "webfonts/fa-brands-400.woff2", 12 | "webfonts/fa-regular-400.ttf", 13 | "webfonts/fa-regular-400.woff2", 14 | "webfonts/fa-solid-900.ttf", 15 | "webfonts/fa-solid-900.woff2" 16 | ] 17 | }, 18 | { 19 | "library": "admin-lte@3.2.0", 20 | "destination": "wwwroot/lib/admin-lte/", 21 | "files": [ 22 | "js/adminlte.min.js", 23 | "css/adminlte.min.css" 24 | ] 25 | }, 26 | { 27 | "library": "select2@4.0.13", 28 | "destination": "wwwroot/lib/select2/", 29 | "files": [ 30 | "css/select2.min.css", 31 | "js/select2.full.min.js" 32 | ] 33 | }, 34 | { 35 | "library": "select2-bootstrap-theme@0.1.0-beta.10", 36 | "destination": "wwwroot/lib/select2-bootstrap-theme/", 37 | "files": [ 38 | "select2-bootstrap.min.css" 39 | ] 40 | }, 41 | { 42 | "provider": "unpkg", 43 | "library": "@microsoft/signalr@8.0.0", 44 | "destination": "wwwroot/lib/signalr/", 45 | "files": [ 46 | "dist/browser/signalr.min.js", 47 | "dist/browser/signalr.js" 48 | ] 49 | } 50 | ] 51 | } -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/Extensions/ActiveRouteTagHelper.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc.Rendering; 2 | 3 | namespace WhatsAppBusinessCloudAPI.Web.Extensions 4 | { 5 | public static class ActiveRouteTagHelper 6 | { 7 | public static string IsActive(this IHtmlHelper html, string controller, string action, string cssClass = "active") 8 | { 9 | var routeData = html.ViewContext.RouteData; 10 | 11 | var currentRouteAction = routeData.Values["action"] as string; 12 | var currentRouteController = routeData.Values["controller"] as string; 13 | 14 | IEnumerable acceptedActions = (action ?? currentRouteAction).Split(','); 15 | IEnumerable acceptedControllers = (controller ?? currentRouteController).Split(','); 16 | 17 | return acceptedActions.Contains(currentRouteAction) && acceptedControllers.Contains(currentRouteController) ? 18 | cssClass : string.Empty; 19 | } 20 | 21 | public static string IsActive(this IHtmlHelper html, string controller) 22 | { 23 | string cssClass = "active"; 24 | var routeData = html.ViewContext.RouteData; 25 | 26 | var currentRouteController = routeData.Values["controller"] as string; 27 | 28 | IEnumerable acceptedControllers = (controller ?? currentRouteController).Split(','); 29 | 30 | return acceptedControllers.Contains(currentRouteController) ? 31 | cssClass : string.Empty; 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Response/CallPermissionStateResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Response 5 | { 6 | public class CallPermissionStateResponse 7 | { 8 | [JsonPropertyName("messaging_product")] 9 | public string MessagingProduct { get; set; } 10 | 11 | [JsonPropertyName("permission")] 12 | public Permission Permission { get; set; } 13 | 14 | [JsonPropertyName("actions")] 15 | public List Actions { get; set; } 16 | } 17 | 18 | public class Permission 19 | { 20 | [JsonPropertyName("status")] 21 | public string Status { get; set; } 22 | 23 | [JsonPropertyName("expiration_time")] 24 | public int ExpirationTime { get; set; } 25 | } 26 | 27 | public class CallPermissionAction 28 | { 29 | [JsonPropertyName("action_name")] 30 | public string ActionName { get; set; } 31 | 32 | [JsonPropertyName("can_perform_action")] 33 | public bool CanPerformAction { get; set; } 34 | 35 | [JsonPropertyName("limits")] 36 | public List Limits { get; set; } 37 | } 38 | 39 | public class Limit 40 | { 41 | [JsonPropertyName("time_period")] 42 | public string TimePeriod { get; set; } 43 | 44 | [JsonPropertyName("max_allowed")] 45 | public int MaxAllowed { get; set; } 46 | 47 | [JsonPropertyName("current_usage")] 48 | public int CurrentUsage { get; set; } 49 | 50 | [JsonPropertyName("limit_expiration_time")] 51 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] 52 | public int? LimitExpirationTime { get; set; } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Messages/Requests/FreeFormCallPermissionMessageRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.Messages.Requests 4 | { 5 | public class FreeFormCallPermissionMessageRequest 6 | { 7 | [JsonPropertyName("messaging_product")] 8 | [JsonInclude] 9 | public string MessagingProduct { get; private set; } = "whatsapp"; 10 | 11 | [JsonPropertyName("recipient_type")] 12 | [JsonInclude] 13 | public string RecipientType { get; private set; } = "individual"; 14 | 15 | [JsonPropertyName("type")] 16 | [JsonInclude] 17 | public string Type { get; private set; } = "interactive"; 18 | 19 | [JsonPropertyName("to")] 20 | public string To { get; set; } 21 | 22 | [JsonPropertyName("interactive")] 23 | public InteractiveCallPermissionRequestMessage Interactive { get; set; } 24 | } 25 | 26 | public class InteractiveCallPermissionRequestMessage 27 | { 28 | [JsonPropertyName("type")] 29 | [JsonInclude] 30 | public string Type { get; private set; } = "call_permission_request"; 31 | [JsonPropertyName("body")] 32 | public InteractiveCallPermissionBody Body { get; set; } 33 | [JsonPropertyName("action")] 34 | public InteractiveCallPermissionAction Action { get; set; } 35 | } 36 | 37 | public class InteractiveCallPermissionBody 38 | { 39 | [JsonPropertyName("text")] 40 | public string Text { get; set; } 41 | } 42 | 43 | public class InteractiveCallPermissionAction 44 | { 45 | [JsonPropertyName("name")] 46 | [JsonInclude] 47 | public string Name { get; private set; } = "call_permission_request"; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi.NetFramework/WhatsApp/Configuration/WhatsAppBusinessCloudApiConfig.cs: -------------------------------------------------------------------------------- 1 | namespace WhatsappBusiness.CloudApi.NetFramework.WhatsApp.Configuration 2 | { 3 | /// 4 | /// Configuration class for WhatsApp Business Cloud API 5 | /// 6 | public class WhatsAppBusinessCloudApiConfig 7 | { 8 | /// 9 | /// WhatsApp Business ID 10 | /// 11 | public string WhatsAppBusinessId { get; set; } 12 | 13 | /// 14 | /// WhatsApp Access Token 15 | /// 16 | public string WhatsAppAccessToken { get; set; } 17 | 18 | /// 19 | /// WhatsApp Graph API Version (e.g., "v19.0") 20 | /// 21 | public string WhatsAppGraphApiVersion { get; set; } = "v23.0"; 22 | 23 | /// 24 | /// WhatsApp Embedded Signup Meta App ID 25 | /// 26 | public string WhatsAppEmbeddedSignupMetaAppId { get; set; } 27 | 28 | /// 29 | /// WhatsApp Embedded Signup Meta App Secret 30 | /// 31 | public string WhatsAppEmbeddedSignupMetaAppSecret { get; set; } 32 | 33 | /// 34 | /// WhatsApp Embedded Signup Meta Configuration ID 35 | /// 36 | public string WhatsAppEmbeddedSignupMetaConfigurationId { get; set; } 37 | 38 | /// 39 | /// WhatsApp Embedded Signup Partner Solution ID 40 | /// 41 | public string WhatsAppEmbeddedSignupPartnerSolutionId { get; set; } 42 | } 43 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Response/GetBlockedUserResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Response 5 | { 6 | public class GetBlockedUserResponse 7 | { 8 | [JsonPropertyName("data")] 9 | public List Data { get; set; } 10 | 11 | [JsonPropertyName("paging")] 12 | public BlockedUserPaging Paging { get; set; } 13 | } 14 | 15 | public class BlockedUserData 16 | { 17 | [JsonPropertyName("block_users")] 18 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 19 | public List BlockUsers { get; set; } 20 | 21 | [JsonPropertyName("messaging_product")] 22 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 23 | public string MessagingProduct { get; set; } 24 | 25 | [JsonPropertyName("wa_id")] 26 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 27 | public string WaId { get; set; } 28 | } 29 | 30 | public class BlockUser : BaseUser 31 | { 32 | 33 | } 34 | 35 | public class BlockedUserPaging 36 | { 37 | [JsonPropertyName("cursors")] 38 | public BlockedUserCursors Cursors { get; set; } 39 | 40 | [JsonPropertyName("previous")] 41 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 42 | public string Previous { get; set; } 43 | 44 | [JsonPropertyName("next")] 45 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 46 | public string Next { get; set; } 47 | } 48 | 49 | public class BlockedUserCursors 50 | { 51 | [JsonPropertyName("after")] 52 | public string After { get; set; } 53 | 54 | [JsonPropertyName("before")] 55 | public string Before { get; set; } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Response/ConversationAnalyticsResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Response 5 | { 6 | public class ConversationAnalyticsResponse 7 | { 8 | [JsonPropertyName("conversation_analytics")] 9 | public ConversationAnalytics ConversationAnalytics { get; set; } 10 | 11 | [JsonPropertyName("id")] 12 | public string Id { get; set; } 13 | } 14 | 15 | public class ConversationAnalytics 16 | { 17 | [JsonPropertyName("data")] 18 | public List Data { get; set; } 19 | } 20 | 21 | public class ConversationAnalyticsData 22 | { 23 | [JsonPropertyName("data_points")] 24 | public List DataPoints { get; set; } 25 | } 26 | 27 | public class ConversationAnalyticsDataPoint 28 | { 29 | [JsonPropertyName("start")] 30 | public long Start { get; set; } 31 | 32 | [JsonPropertyName("end")] 33 | public long End { get; set; } 34 | 35 | [JsonPropertyName("conversation")] 36 | public long Conversation { get; set; } 37 | 38 | [JsonPropertyName("phone_number")] 39 | public string PhoneNumber { get; set; } 40 | 41 | [JsonPropertyName("country")] 42 | public string Country { get; set; } 43 | 44 | [JsonPropertyName("conversation_type")] 45 | public string ConversationType { get; set; } 46 | 47 | [JsonPropertyName("conversation_direction")] 48 | public string ConversationDirection { get; set; } 49 | 50 | [JsonPropertyName("cost")] 51 | public double Cost { get; set; } 52 | } 53 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Messages/Requests/InteractiveLocationMessageRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.Messages.Requests 4 | { 5 | public class InteractiveLocationMessageRequest 6 | { 7 | [JsonPropertyName("messaging_product")] 8 | [JsonInclude] 9 | public string MessagingProduct { get; private set; } = "whatsapp"; 10 | 11 | [JsonPropertyName("recipient_type")] 12 | [JsonInclude] 13 | public string RecipientType { get; private set; } = "individual"; 14 | 15 | [JsonPropertyName("type")] 16 | [JsonInclude] 17 | public string Type { get; private set; } = "interactive"; 18 | 19 | [JsonPropertyName("to")] 20 | public string To { get; set; } 21 | 22 | [JsonPropertyName("interactive")] 23 | public InteractiveLocationRequestMessage Interactive { get; set; } 24 | 25 | [JsonPropertyName("biz_opaque_callback_data")] 26 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 27 | public string BizOpaqueCallbackData { get; set; } 28 | } 29 | 30 | public class InteractiveLocationRequestMessage 31 | { 32 | [JsonPropertyName("type")] 33 | [JsonInclude] 34 | public string Type { get; private set; } = "location_request_message"; 35 | 36 | [JsonPropertyName("body")] 37 | public InteractiveLocationBody Body { get; set; } 38 | 39 | [JsonPropertyName("action")] 40 | public InteractiveLocationAction Action { get; set; } 41 | } 42 | 43 | public class InteractiveLocationAction 44 | { 45 | [JsonPropertyName("name")] 46 | [JsonInclude] 47 | public string Name { get; private set; } = "send_location"; 48 | } 49 | 50 | public class InteractiveLocationBody 51 | { 52 | [JsonPropertyName("text")] 53 | public string Text { get; set; } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Response/WhatsAppGroupJoinRequestResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Response 5 | { 6 | public class WhatsAppGroupJoinRequestResponse 7 | { 8 | [JsonPropertyName("messaging_product")] 9 | public string MessagingProduct { get; set; } 10 | 11 | [JsonPropertyName("approved_join_requests")] 12 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 13 | public List ApprovedJoinRequests { get; set; } 14 | 15 | [JsonPropertyName("rejected_join_requests")] 16 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 17 | public List RejectedJoinRequests { get; set; } 18 | 19 | [JsonPropertyName("failed_join_requests")] 20 | public List FailedJoinRequests { get; set; } 21 | 22 | [JsonPropertyName("errors")] 23 | public List Errors { get; set; } 24 | } 25 | 26 | public class WhatsAppGroupJoinError 27 | { 28 | [JsonPropertyName("code")] 29 | public string Code { get; set; } 30 | 31 | [JsonPropertyName("message")] 32 | public string Message { get; set; } 33 | 34 | [JsonPropertyName("title")] 35 | public string Title { get; set; } 36 | 37 | [JsonPropertyName("error_data")] 38 | public WhatsAppGroupJoinErrorData ErrorData { get; set; } 39 | } 40 | 41 | public class WhatsAppGroupJoinErrorData 42 | { 43 | [JsonPropertyName("details")] 44 | public string Details { get; set; } 45 | } 46 | 47 | public class FailedJoinRequest 48 | { 49 | [JsonPropertyName("join_request_id")] 50 | public string JoinRequestId { get; set; } 51 | 52 | [JsonPropertyName("errors")] 53 | public List Errors { get; set; } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Response/WABADetailsResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.Response 4 | { 5 | /// 6 | /// Response for getting detailed WhatsApp Business Account information 7 | /// 8 | public class WABADetailsResponse 9 | { 10 | [JsonPropertyName("id")] 11 | public string Id { get; set; } 12 | 13 | [JsonPropertyName("name")] 14 | public string? Name { get; set; } 15 | 16 | [JsonPropertyName("currency")] 17 | public string? Currency { get; set; } 18 | 19 | [JsonPropertyName("timezone_id")] 20 | public string? TimezoneId { get; set; } 21 | 22 | [JsonPropertyName("message_template_namespace")] 23 | public string? MessageTemplateNamespace { get; set; } 24 | 25 | [JsonPropertyName("account_review_status")] 26 | public string? AccountReviewStatus { get; set; } 27 | 28 | [JsonPropertyName("business_verification_status")] 29 | public string? BusinessVerificationStatus { get; set; } 30 | 31 | [JsonPropertyName("country")] 32 | public string? Country { get; set; } 33 | 34 | [JsonPropertyName("owner_business_info")] 35 | public OwnerBusinessInfo? OwnerBusinessInfo { get; set; } 36 | 37 | [JsonPropertyName("primary_business_location")] 38 | public string? PrimaryBusinessLocation { get; set; } 39 | 40 | [JsonPropertyName("purchase_order_number")] 41 | public string? PurchaseOrderNumber { get; set; } 42 | 43 | [JsonPropertyName("status")] 44 | public string? Status { get; set; } 45 | 46 | [JsonPropertyName("health_status")] 47 | public HealthStatus? HealthStatus { get; set; } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/wwwroot/lib/jquery/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright JS Foundation and other contributors, https://js.foundation/ 2 | 3 | This software consists of voluntary contributions made by many 4 | individuals. For exact contribution history, see the revision history 5 | available at https://github.com/jquery/jquery 6 | 7 | The following license applies to all parts of this software except as 8 | documented below: 9 | 10 | ==== 11 | 12 | Permission is hereby granted, free of charge, to any person obtaining 13 | a copy of this software and associated documentation files (the 14 | "Software"), to deal in the Software without restriction, including 15 | without limitation the rights to use, copy, modify, merge, publish, 16 | distribute, sublicense, and/or sell copies of the Software, and to 17 | permit persons to whom the Software is furnished to do so, subject to 18 | the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be 21 | included in all copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 27 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 28 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 29 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30 | 31 | ==== 32 | 33 | All files located in the node_modules and external directories are 34 | externally maintained libraries used by this software which have their 35 | own licenses; we recommend you read them, as their terms may differ from 36 | the terms above. 37 | -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/Views/Home/SendWhatsAppTextMessage.cshtml: -------------------------------------------------------------------------------- 1 | @model SendTemplateMessageViewModel 2 | @{ 3 | ViewData["Title"] = "Send WhatsApp Text Message Page"; 4 | ViewData["CurrentPage"] = "Send WhatsApp Text Message"; 5 | Layout = "~/Views/Shared/AdminLTE/_AdminLayout.cshtml"; 6 | ViewData["ControllerName"] = nameof(HomeController).Replace("Controller", ""); 7 | ViewData["ActionName"] = nameof(HomeController.SendWhatsAppTextMessage); 8 | } 9 | 10 |
11 |
12 |
13 |
14 |
15 |

Send WhatsApp Text Message

16 |
17 | 18 |
19 |
20 |
21 |
22 | 23 | 24 | 25 |
26 |
27 | 28 | 29 | 30 |
31 |
32 | 35 |
36 |
37 |
38 |
39 |
40 | 41 | @section Scripts { 42 | @{ 43 | await Html.RenderPartialAsync("_ValidationScriptsPartial"); 44 | } 45 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Extensions/FacebookWebhookHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Security.Cryptography; 3 | using System.Text; 4 | 5 | namespace WhatsappBusiness.CloudApi.Extensions 6 | { 7 | /// 8 | /// Facebook Webhook Helper class helps to verify the integrity and origin of the payload request 9 | /// 10 | public static class FacebookWebhookHelper 11 | { 12 | /// 13 | /// The HTTP request will contain an X-Hub-Signature header which contains the SHA1 signature of the request payload, 14 | /// using the app secret as the key, and prefixed with sha1=. 15 | /// Your callback endpoint can verify this signature to validate the integrity and origin of the payload 16 | /// 17 | /// facebook app secret 18 | /// body of webhook post request 19 | /// calculated signature 20 | public static string CalculateSignature(string appSecret, string payload) 21 | { 22 | /* 23 | Please note that the calculation is made on the escaped unicode version of the payload, with lower case hex digits. 24 | If you just calculate against the decoded bytes, you will end up with a different signature. 25 | For example, the string äöå should be escaped to \u00e4\u00f6\u00e5. 26 | */ 27 | 28 | using HMACSHA256 hmac = new HMACSHA256(Encoding.UTF8.GetBytes(appSecret)); 29 | hmac.Initialize(); 30 | byte[] hashArray = hmac.ComputeHash(Encoding.UTF8.GetBytes(payload)); 31 | string hash = $"SHA256={BitConverter.ToString(hashArray).Replace("-", string.Empty)}"; 32 | 33 | return hash; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Messages/Requests/CallPermissionTemplateMessageRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Messages.Requests 5 | { 6 | public class CallPermissionTemplateMessageRequest 7 | { 8 | [JsonPropertyName("messaging_product")] 9 | [JsonInclude] 10 | public string MessagingProduct { get; private set; } = "whatsapp"; 11 | 12 | [JsonPropertyName("recipient_type")] 13 | [JsonInclude] 14 | public string RecipientType { get; private set; } = "individual"; 15 | 16 | [JsonPropertyName("to")] 17 | public string To { get; set; } 18 | 19 | [JsonPropertyName("type")] 20 | [JsonInclude] 21 | public string Type { get; private set; } = "template"; 22 | 23 | [JsonPropertyName("template")] 24 | public CallPermissionMessageTemplate Template { get; set; } 25 | } 26 | 27 | public class CallPermissionMessageTemplate 28 | { 29 | [JsonPropertyName("name")] 30 | public string Name { get; set; } 31 | 32 | [JsonPropertyName("language")] 33 | public CallPermissionMessageLanguage Language { get; set; } 34 | 35 | [JsonPropertyName("components")] 36 | public List Components { get; set; } 37 | } 38 | 39 | public class CallPermissionMessageComponent 40 | { 41 | [JsonPropertyName("type")] 42 | public string Type { get; set; } 43 | 44 | [JsonPropertyName("parameters")] 45 | public List Parameters { get; set; } 46 | } 47 | 48 | public class CallPermissionMessageParameter 49 | { 50 | [JsonPropertyName("type")] 51 | public string Type { get; set; } 52 | 53 | [JsonPropertyName("text")] 54 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 55 | public string Text { get; set; } 56 | } 57 | 58 | public class CallPermissionMessageLanguage 59 | { 60 | [JsonPropertyName("code")] 61 | public string Code { get; set; } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/Extensions/Alerts/AlertDecoratorResult.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.AspNetCore.Mvc.ViewFeatures; 3 | 4 | namespace WhatsAppBusinessCloudAPI.Web.Extensions.Alerts 5 | { 6 | public class AlertDecoratorResult : IActionResult 7 | { 8 | public IActionResult Result { get; } 9 | public string Type { get; } 10 | public string Title { get; } 11 | public string Body { get; } 12 | 13 | public AlertDecoratorResult(IActionResult result, string type, string title, string body) 14 | { 15 | Result = result; 16 | Type = type; 17 | Title = title; 18 | Body = body; 19 | } 20 | 21 | 22 | public async Task ExecuteResultAsync(ActionContext context) 23 | { 24 | if (Result is StatusCodeResult || Result is OkObjectResult) 25 | { 26 | AddAlertMessageToApiResult(context); 27 | } 28 | else 29 | { 30 | AddAlertMessageToMvcResult(context); 31 | } 32 | 33 | await Result.ExecuteResultAsync(context); 34 | } 35 | 36 | private void AddAlertMessageToApiResult(ActionContext context) 37 | { 38 | context.HttpContext.Response.Headers.Add("x-alert-type", Type); 39 | context.HttpContext.Response.Headers.Add("x-alert-title", Title); 40 | context.HttpContext.Response.Headers.Add("x-alert-body", Body); 41 | } 42 | 43 | private void AddAlertMessageToMvcResult(ActionContext context) 44 | { 45 | var factory = context.HttpContext.RequestServices.GetService(); 46 | 47 | var tempData = factory.GetTempData(context.HttpContext); 48 | tempData["_alert.type"] = Type; 49 | tempData["_alert.title"] = Title; 50 | tempData["_alert.body"] = Body; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Messages/Requests/SingleProductMessageRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.Messages.Requests 4 | { 5 | public class SingleProductMessageRequest 6 | { 7 | [JsonPropertyName("messaging_product")] 8 | [JsonInclude] 9 | public string MessagingProduct { get; private set; } = "whatsapp"; 10 | 11 | [JsonPropertyName("recipient_type")] 12 | [JsonInclude] 13 | public string RecipientType { get; private set; } = "individual"; 14 | 15 | [JsonPropertyName("to")] 16 | public string To { get; set; } 17 | 18 | [JsonPropertyName("type")] 19 | [JsonInclude] 20 | public string Type { get; private set; } = "interactive"; 21 | 22 | [JsonPropertyName("interactive")] 23 | public SingleProductInteractive Interactive { get; set; } 24 | 25 | [JsonPropertyName("biz_opaque_callback_data")] 26 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 27 | public string BizOpaqueCallbackData { get; set; } 28 | } 29 | 30 | public class SingleProductInteractive 31 | { 32 | [JsonPropertyName("type")] 33 | [JsonInclude] 34 | public string Type { get; private set; } = "product"; 35 | 36 | [JsonPropertyName("body")] 37 | public SingleProductBody Body { get; set; } 38 | 39 | [JsonPropertyName("footer")] 40 | public SingleProductBody Footer { get; set; } 41 | 42 | [JsonPropertyName("action")] 43 | public SingleProductAction Action { get; set; } 44 | } 45 | 46 | public class SingleProductAction 47 | { 48 | [JsonPropertyName("catalog_id")] 49 | public string CatalogId { get; set; } 50 | 51 | [JsonPropertyName("product_retailer_id")] 52 | public string ProductRetailerId { get; set; } 53 | } 54 | 55 | public class SingleProductBody 56 | { 57 | [JsonPropertyName("text")] 58 | public string Text { get; set; } 59 | } 60 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Messages/Requests/CatalogMessageRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.Messages.Requests 4 | { 5 | public class CatalogMessageRequest 6 | { 7 | [JsonPropertyName("messaging_product")] 8 | [JsonInclude] 9 | public string MessagingProduct { get; private set; } = "whatsapp"; 10 | 11 | [JsonPropertyName("recipient_type")] 12 | [JsonInclude] 13 | public string RecipientType { get; private set; } = "individual"; 14 | 15 | [JsonPropertyName("to")] 16 | public string To { get; set; } 17 | 18 | [JsonPropertyName("type")] 19 | public string Type { get; set; } 20 | 21 | [JsonPropertyName("interactive")] 22 | public CatalogMessageInteractive Interactive { get; set; } 23 | 24 | [JsonPropertyName("biz_opaque_callback_data")] 25 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 26 | public string BizOpaqueCallbackData { get; set; } 27 | } 28 | 29 | public class CatalogMessageInteractive 30 | { 31 | [JsonPropertyName("type")] 32 | public string Type { get; set; } 33 | 34 | [JsonPropertyName("body")] 35 | public CatalogMessageBody Body { get; set; } 36 | 37 | [JsonPropertyName("action")] 38 | public CatalogMessageAction Action { get; set; } 39 | 40 | [JsonPropertyName("footer")] 41 | public CatalogMessageFooter Footer { get; set; } 42 | } 43 | 44 | public class CatalogMessageAction 45 | { 46 | [JsonPropertyName("name")] 47 | public string Name { get; set; } 48 | 49 | [JsonPropertyName("parameters")] 50 | public CatalogMessageParameters Parameters { get; set; } 51 | } 52 | 53 | public class CatalogMessageParameters 54 | { 55 | [JsonPropertyName("thumbnail_product_retailer_id")] 56 | public string ThumbnailProductRetailerId { get; set; } 57 | } 58 | 59 | public class CatalogMessageBody 60 | { 61 | [JsonPropertyName("text")] 62 | public string Text { get; set; } 63 | } 64 | 65 | public class CatalogMessageFooter : CatalogMessageBody 66 | { 67 | 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/Views/Home/BulkSendWhatsApps.cshtml: -------------------------------------------------------------------------------- 1 | @model BulkSendWhatsAppsViewModel 2 | @{ 3 | ViewData["Title"] = "Bulk Send WhatsApps"; 4 | ViewData["CurrentPage"] = "Bulk Send WhatsApps"; 5 | Layout = "~/Views/Shared/AdminLTE/_AdminLayout.cshtml"; 6 | ViewData["ControllerName"] = nameof(HomeController).Replace("Controller", ""); 7 | //ViewData["ActionName"] = nameof(HomeController.BulkSendWhatsApps); 8 | } 9 | 10 |
11 |
12 |
13 |
14 |
15 |

Bulk WhatsApps

16 |
17 | 18 |
19 |
20 |
21 |
22 | 23 |
24 | 25 | 26 |
27 |
28 | 29 | @if (ViewBag.SendStatus != null) 30 | { 31 |

Send Status: @ViewBag.SendStatus

32 | } 33 | 34 | @if (ViewBag.H != null) 35 | { 36 |

H from WhatsApp: @ViewBag.H

37 | } 38 | 39 | @if (ViewBag.StatusId != null) 40 | { 41 |

File Upload Status Id: @ViewBag.StatusId

42 |

File Offset: @ViewBag.FileOffset

43 | } 44 |
45 | 48 |
49 |
50 |
51 |
52 |
53 | 54 | @section Scripts { 55 | @{ 56 | await Html.RenderPartialAsync("_ValidationScriptsPartial"); 57 | } 58 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Response/SharedWABAIDResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using System.Text.Json.Serialization; 4 | 5 | namespace WhatsappBusiness.CloudApi.Response 6 | { 7 | public class SharedWABAIDResponse 8 | { 9 | [JsonPropertyName("data")] 10 | public SharedWABAIDData Data { get; set; } 11 | 12 | public string? GetSharedWABAId() 13 | { 14 | return Data 15 | ?.GranularScopes 16 | ?.FirstOrDefault(x => x.Scope == "whatsapp_business_management" || x.Scope == "whatsapp_business_messaging") 17 | ?.TargetIds 18 | ?.FirstOrDefault(); 19 | } 20 | } 21 | 22 | public class SharedWABAIDData 23 | { 24 | [JsonPropertyName("app_id")] 25 | public string AppId { get; set; } 26 | 27 | [JsonPropertyName("type")] 28 | public string Type { get; set; } 29 | 30 | [JsonPropertyName("application")] 31 | public string Application { get; set; } 32 | 33 | [JsonPropertyName("data_access_expires_at")] 34 | public long DataAccessExpiresAt { get; set; } 35 | 36 | [JsonPropertyName("expires_at")] 37 | public long ExpiresAt { get; set; } 38 | 39 | [JsonPropertyName("is_valid")] 40 | public bool IsValid { get; set; } 41 | 42 | [JsonPropertyName("scopes")] 43 | public List Scopes { get; set; } 44 | 45 | [JsonPropertyName("granular_scopes")] 46 | public List GranularScopes { get; set; } 47 | 48 | [JsonPropertyName("user_id")] 49 | public string UserId { get; set; } 50 | } 51 | 52 | public partial class GranularScope 53 | { 54 | [JsonPropertyName("scope")] 55 | public string Scope { get; set; } 56 | 57 | [JsonPropertyName("target_ids")] 58 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 59 | public List? TargetIds { get; set; } 60 | } 61 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Messages/Requests/VoiceCallMessageRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.Messages.Requests 4 | { 5 | public class VoiceCallMessageRequest 6 | { 7 | [JsonPropertyName("messaging_product")] 8 | [JsonInclude] 9 | public string MessagingProduct { get; private set; } = "whatsapp"; 10 | 11 | [JsonPropertyName("recipient_type")] 12 | [JsonInclude] 13 | public string RecipientType { get; private set; } = "individual"; 14 | 15 | [JsonPropertyName("type")] 16 | [JsonInclude] 17 | public string Type { get; private set; } = "interactive"; 18 | 19 | [JsonPropertyName("to")] 20 | public string To { get; set; } 21 | 22 | [JsonPropertyName("interactive")] 23 | public InteractiveVoiceCallRequestMessage Interactive { get; set; } 24 | } 25 | 26 | public class InteractiveVoiceCallRequestMessage 27 | { 28 | [JsonPropertyName("type")] 29 | [JsonInclude] 30 | public string Type { get; private set; } = "voice_call"; 31 | 32 | [JsonPropertyName("body")] 33 | public InteractiveVoiceCallBody Body { get; set; } 34 | 35 | [JsonPropertyName("action")] 36 | public InteractiveVoiceCallAction Action { get; set; } 37 | } 38 | 39 | public class InteractiveVoiceCallBody 40 | { 41 | [JsonPropertyName("text")] 42 | public string Text { get; set; } 43 | } 44 | 45 | public class InteractiveVoiceCallAction 46 | { 47 | [JsonPropertyName("name")] 48 | [JsonInclude] 49 | public string Name { get; private set; } = "voice_call"; 50 | 51 | [JsonPropertyName("parameters")] 52 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 53 | public VoiceCallParameters Parameters { get; set; } 54 | } 55 | 56 | public class VoiceCallParameters 57 | { 58 | [JsonPropertyName("display_text")] 59 | public string DisplayText { get; set; } 60 | 61 | [JsonPropertyName("ttl_minutes")] 62 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] 63 | public int TtlMinutes { get; set; } // Duration in minutes 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/Views/Shared/AdminLTE/_AdminLayout.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | var type = (string)TempData["_alert.type"]; 3 | } 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | WhatsApp Business Cloud API Sample - @ViewData["Title"] 12 | 13 | 14 | 15 |
16 | 17 | 18 |
19 |
20 |
21 |
22 |
23 |

@ViewData["CurrentPage"]

24 |
25 |
26 | 37 |
38 |
39 |
40 |
41 |
42 |
43 | @RenderBody() 44 |
45 |
46 |
47 | 53 | 54 |
55 | 56 | @RenderSection("Scripts", required: false); 57 | 58 | -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/Views/Home/SendWhatsAppInteractiveMessage.cshtml: -------------------------------------------------------------------------------- 1 | @model SendInteractiveMessageViewModel 2 | @{ 3 | ViewData["Title"] = "Send WhatsApp Interactive Message Page"; 4 | ViewData["CurrentPage"] = "Send WhatsApp Interactive Message"; 5 | Layout = "~/Views/Shared/AdminLTE/_AdminLayout.cshtml"; 6 | ViewData["ControllerName"] = nameof(HomeController).Replace("Controller", ""); 7 | ViewData["ActionName"] = nameof(HomeController.SendWhatsAppInteractiveMessage); 8 | } 9 | 10 |
11 |
12 |
13 |
14 |
15 |

Send WhatsApp Interactive Message

16 |
17 | 18 |
19 |
20 |
21 |
22 | 23 | 24 | 25 |
26 |
27 | 28 | 29 | 30 |
31 |
32 | 33 | 34 | 35 |
36 |
37 | 40 |
41 |
42 |
43 |
44 |
45 | 46 | @section Scripts { 47 | @{ 48 | await Html.RenderPartialAsync("_ValidationScriptsPartial"); 49 | } 50 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Response/BlockUserResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Response 5 | { 6 | public class BlockUserResponse 7 | { 8 | [JsonPropertyName("messaging_product")] 9 | public string MessagingProduct { get; set; } 10 | 11 | [JsonPropertyName("block_users")] 12 | public BlockUsers BlockUsers { get; set; } 13 | 14 | [JsonPropertyName("error")] 15 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 16 | public Error Error { get; set; } 17 | } 18 | 19 | public class Data 20 | { 21 | [JsonPropertyName("messaging_product")] 22 | public string MessagingProduct { get; set; } 23 | } 24 | 25 | public class BlockUsers 26 | { 27 | [JsonPropertyName("added_users")] 28 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 29 | public List AddedUsers { get; set; } 30 | 31 | [JsonPropertyName("failed_users")] 32 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 33 | public List FailedUsers { get; set; } 34 | 35 | [JsonPropertyName("removed_users")] 36 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 37 | public List RemovedUsers { get; set; } 38 | } 39 | 40 | public class AddedUser : BaseUser 41 | { 42 | 43 | } 44 | 45 | public class FailedUser : BaseUser 46 | { 47 | [JsonPropertyName("errors")] 48 | public List Errors { get; set; } 49 | } 50 | 51 | public class RemovedUser : BaseUser 52 | { 53 | 54 | } 55 | 56 | public partial class ErrorElement 57 | { 58 | [JsonPropertyName("message")] 59 | public string Message { get; set; } 60 | 61 | [JsonPropertyName("code")] 62 | public long Code { get; set; } 63 | 64 | [JsonPropertyName("error_data")] 65 | public BlockUserErrorData ErrorData { get; set; } 66 | } 67 | 68 | public class BlockUserErrorData 69 | { 70 | [JsonPropertyName("details")] 71 | public string Details { get; set; } 72 | } 73 | 74 | public class BaseUser 75 | { 76 | [JsonPropertyName("input")] 77 | public string Input { get; set; } 78 | 79 | [JsonPropertyName("wa_id")] 80 | public string WaId { get; set; } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Response/WhatsAppGroupResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Response 5 | { 6 | public class WhatsAppGroupResponse 7 | { 8 | [JsonPropertyName("data")] 9 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 10 | public List Data { get; set; } 11 | 12 | [JsonPropertyName("paging")] 13 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 14 | public WhatsAppGroupPaging Paging { get; set; } 15 | } 16 | 17 | public class WhatsAppGroupCursors 18 | { 19 | [JsonPropertyName("before")] 20 | public string Before { get; set; } 21 | 22 | [JsonPropertyName("after")] 23 | public string After { get; set; } 24 | } 25 | 26 | public class WhatsAppGroupData 27 | { 28 | [JsonPropertyName("join_request_id")] 29 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 30 | public string JoinRequestId { get; set; } 31 | 32 | [JsonPropertyName("wa_id")] 33 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 34 | public string WaId { get; set; } 35 | 36 | [JsonPropertyName("creation_timestamp")] 37 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 38 | public string CreationTimestamp { get; set; } 39 | 40 | [JsonPropertyName("groups")] 41 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 42 | public List Groups { get; set; } 43 | } 44 | 45 | public class WhatsAppGroup 46 | { 47 | [JsonPropertyName("id")] 48 | public string Id { get; set; } 49 | 50 | [JsonPropertyName("subject")] 51 | public string Subject { get; set; } 52 | 53 | [JsonPropertyName("created_at")] 54 | public string CreatedAt { get; set; } 55 | } 56 | 57 | public class WhatsAppGroupPaging 58 | { 59 | [JsonPropertyName("cursors")] 60 | public WhatsAppGroupCursors Cursors { get; set; } 61 | 62 | [JsonPropertyName("previous")] 63 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 64 | public string Previous { get; set; } 65 | 66 | [JsonPropertyName("next")] 67 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 68 | public string Next { get; set; } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/Views/Home/CreateQRCodeMessage.cshtml: -------------------------------------------------------------------------------- 1 | @model QRCodeMessageViewModel 2 | @{ 3 | ViewData["Title"] = "Create QR Code WhatsApp Message Page"; 4 | ViewData["CurrentPage"] = "Create QR Code Message"; 5 | Layout = "~/Views/Shared/AdminLTE/_AdminLayout.cshtml"; 6 | ViewData["ControllerName"] = nameof(HomeController).Replace("Controller", ""); 7 | ViewData["ActionName"] = nameof(HomeController.CreateQRCodeMessage); 8 | } 9 | 10 |
11 |
12 |
13 |
14 |
15 |

Create QR Code Message

16 |
17 | 18 |
19 |
20 |
21 |
22 | 23 | 24 | 25 |
26 |
27 | 28 | 29 | 30 |
31 | 32 | 33 |
34 |

QR Code Id: @ViewBag.QRCodeId

35 |
36 | 37 |
38 |

Message: @ViewBag.QRCodeMessage

39 |
40 | 41 |
42 | 43 |
44 |
45 | 48 |
49 |
50 |
51 |
52 |
53 | 54 | @section Scripts { 55 | @{ 56 | await Html.RenderPartialAsync("_ValidationScriptsPartial"); 57 | } 58 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Webhook/UserFailedMessageStatus.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Webhook 5 | { 6 | /// 7 | /// A Webhook with failed status 8 | /// 9 | public class UserFailedMessageStatus 10 | { 11 | [JsonPropertyName("object")] 12 | public string Object { get; set; } 13 | 14 | [JsonPropertyName("entry")] 15 | public List Entry { get; set; } 16 | } 17 | 18 | public class UserFailedMessageEntry 19 | { 20 | [JsonPropertyName("id")] 21 | public string Id { get; set; } 22 | 23 | [JsonPropertyName("changes")] 24 | public List Changes { get; set; } 25 | } 26 | 27 | public class UserFailedMessageChange 28 | { 29 | [JsonPropertyName("value")] 30 | public UserFailedMessageValue Value { get; set; } 31 | 32 | [JsonPropertyName("field")] 33 | public string Field { get; set; } 34 | } 35 | 36 | public class UserFailedMessageValue 37 | { 38 | [JsonPropertyName("messaging_product")] 39 | public string MessagingProduct { get; set; } 40 | 41 | [JsonPropertyName("metadata")] 42 | public MessageMetadata Metadata { get; set; } 43 | 44 | [JsonPropertyName("statuses")] 45 | public List Statuses { get; set; } 46 | } 47 | 48 | 49 | public class UserFailedStatus 50 | { 51 | [JsonPropertyName("id")] 52 | public string Id { get; set; } 53 | 54 | [JsonPropertyName("status")] 55 | public string Status { get; set; } 56 | 57 | [JsonPropertyName("timestamp")] 58 | public string Timestamp { get; set; } 59 | 60 | [JsonPropertyName("recipient_id")] 61 | public string RecipientId { get; set; } 62 | 63 | [JsonPropertyName("errors")] 64 | public List Errors { get; set; } 65 | } 66 | 67 | public class UserFailedMessageError 68 | { 69 | [JsonPropertyName("code")] 70 | public long Code { get; set; } 71 | 72 | [JsonPropertyName("title")] 73 | public string Title { get; set; } 74 | } 75 | } -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/Views/Home/SendWhatsAppLocationMessage.cshtml: -------------------------------------------------------------------------------- 1 | @model SendLocationMessageViewModel 2 | @{ 3 | ViewData["Title"] = "Send WhatsApp Location Message Page"; 4 | ViewData["CurrentPage"] = "Send WhatsApp Location Message"; 5 | Layout = "~/Views/Shared/AdminLTE/_AdminLayout.cshtml"; 6 | ViewData["ControllerName"] = nameof(HomeController).Replace("Controller", ""); 7 | ViewData["ActionName"] = nameof(HomeController.SendWhatsAppLocationMessage); 8 | } 9 | 10 |
11 |
12 |
13 |
14 |
15 |

Send WhatsApp Location Message

16 |
17 | 18 |
19 |
20 |
21 |
22 | 23 | 24 | 25 |
26 |
27 | 28 | 29 | 30 |
31 |
32 | 33 | 34 | 35 |
36 |
37 | 38 | 39 | 40 |
41 |
42 | 45 |
46 |
47 |
48 |
49 |
50 | 51 | @section Scripts { 52 | @{ 53 | await Html.RenderPartialAsync("_ValidationScriptsPartial"); 54 | } 55 | } -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/Views/Home/UploadMedia.cshtml: -------------------------------------------------------------------------------- 1 | @model UploadMediaViewModel 2 | @{ 3 | ViewData["Title"] = "Upload Media to WhatsApp"; 4 | ViewData["CurrentPage"] = "Upload Media"; 5 | Layout = "~/Views/Shared/AdminLTE/_AdminLayout.cshtml"; 6 | ViewData["ControllerName"] = nameof(HomeController).Replace("Controller", ""); 7 | ViewData["ActionName"] = nameof(HomeController.UploadMedia); 8 | } 9 | 10 |
11 |
12 |
13 |
14 |
15 |

Upload Media to WhatsApp

16 |
17 | 18 |
19 |
20 |
21 |
22 | 23 |
24 | 25 | 26 |
27 |
28 |
29 | 30 | 31 | 32 |
33 | 34 | @if (ViewBag.MediaId != null) 35 | { 36 |

Media Id from WhatsApp: @ViewBag.MediaId

37 | } 38 | 39 | @if (ViewBag.H != null) 40 | { 41 |

H from WhatsApp: @ViewBag.H

42 | } 43 | 44 | @if (ViewBag.StatusId != null) 45 | { 46 |

File Upload Status Id: @ViewBag.StatusId

47 |

File Offset: @ViewBag.FileOffset

48 | } 49 |
50 | 53 |
54 |
55 |
56 |
57 |
58 | 59 | @section Scripts { 60 | @{ 61 | await Html.RenderPartialAsync("_ValidationScriptsPartial"); 62 | } 63 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Messages/Requests/CouponCodeTemplateMessageRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Messages.Requests 5 | { 6 | public class CouponCodeTemplateMessageRequest 7 | { 8 | [JsonPropertyName("messaging_product")] 9 | [JsonInclude] 10 | public string MessagingProduct { get; private set; } = "whatsapp"; 11 | 12 | [JsonPropertyName("to")] 13 | public string To { get; set; } 14 | 15 | [JsonPropertyName("type")] 16 | [JsonInclude] 17 | public string Type { get; private set; } = "template"; 18 | 19 | [JsonPropertyName("template")] 20 | public CouponCodeMessageTemplate Template { get; set; } 21 | 22 | [JsonPropertyName("biz_opaque_callback_data")] 23 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 24 | public string BizOpaqueCallbackData { get; set; } 25 | } 26 | 27 | public class CouponCodeMessageTemplate 28 | { 29 | [JsonPropertyName("name")] 30 | public string Name { get; set; } 31 | 32 | [JsonPropertyName("language")] 33 | public CouponCodeMessageLanguage Language { get; set; } 34 | 35 | [JsonPropertyName("components")] 36 | public List Components { get; set; } 37 | } 38 | 39 | public class CouponCodeMessageComponent 40 | { 41 | [JsonPropertyName("type")] 42 | public string Type { get; set; } 43 | 44 | [JsonPropertyName("parameters")] 45 | public List Parameters { get; set; } 46 | 47 | [JsonPropertyName("sub_type")] 48 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 49 | public string SubType { get; set; } 50 | 51 | [JsonPropertyName("index")] 52 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] 53 | public int? Index { get; set; } 54 | } 55 | 56 | public class CouponCodeMessageParameter 57 | { 58 | [JsonPropertyName("type")] 59 | public string Type { get; set; } 60 | 61 | [JsonPropertyName("parameter_name")] 62 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 63 | public string ParameterName { get; set; } 64 | 65 | [JsonPropertyName("text")] 66 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 67 | public string Text { get; set; } 68 | 69 | [JsonPropertyName("coupon_code")] 70 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 71 | public string CouponCode { get; set; } 72 | } 73 | 74 | public class CouponCodeMessageLanguage 75 | { 76 | [JsonPropertyName("code")] 77 | public string Code { get; set; } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Response/ExchangeTokenResponse.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Response 5 | { 6 | public class ExchangeTokenResponse 7 | { 8 | [JsonPropertyName("access_token")] 9 | public string? AccessToken { get; set; } 10 | 11 | [JsonPropertyName("token_type")] 12 | public string? TokenType { get; set; } 13 | 14 | [JsonPropertyName("expires_in")] 15 | public int? ExpiresIn { get; set; } 16 | 17 | [JsonPropertyName("scope")] 18 | public string? Scope { get; set; } 19 | 20 | [JsonPropertyName("error")] 21 | public JsonElement? ErrorElement { get; set; } 22 | 23 | [JsonPropertyName("error_description")] 24 | public string? ErrorDescription { get; set; } 25 | 26 | /// 27 | /// Gets the error as a string representation. 28 | /// Handles both string and object error formats from the API. 29 | /// 30 | [JsonIgnore] 31 | public string? Error 32 | { 33 | get 34 | { 35 | if (!ErrorElement.HasValue) 36 | return null; 37 | 38 | var errorElement = ErrorElement.Value; 39 | 40 | if (errorElement.ValueKind == JsonValueKind.String) 41 | { 42 | return errorElement.GetString(); 43 | } 44 | else if (errorElement.ValueKind == JsonValueKind.Object) 45 | { 46 | // If it's an object, try to get a meaningful error message 47 | if (errorElement.TryGetProperty("message", out var messageElement)) 48 | { 49 | return messageElement.GetString(); 50 | } 51 | else if (errorElement.TryGetProperty("type", out var typeElement)) 52 | { 53 | return typeElement.GetString(); 54 | } 55 | else 56 | { 57 | // Return the raw JSON object as string 58 | return errorElement.GetRawText(); 59 | } 60 | } 61 | else 62 | { 63 | // For arrays or other types, return the raw JSON 64 | return errorElement.GetRawText(); 65 | } 66 | } 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/Views/Home/SendWhatsAppContactMessage.cshtml: -------------------------------------------------------------------------------- 1 | @model SendContactMessageViewModel 2 | @{ 3 | ViewData["Title"] = "Send WhatsApp Contact Message Page"; 4 | ViewData["CurrentPage"] = "Send WhatsApp Contact Message"; 5 | Layout = "~/Views/Shared/AdminLTE/_AdminLayout.cshtml"; 6 | ViewData["ControllerName"] = nameof(HomeController).Replace("Controller", ""); 7 | ViewData["ActionName"] = nameof(HomeController.SendWhatsAppContactMessage); 8 | } 9 | 10 |
11 |
12 |
13 |
14 |
15 |

Send WhatsApp Contact Message

16 |
17 | 18 |
19 |
20 |
21 |
22 | 23 | 24 | 25 |
26 |
27 | 28 | 29 | 30 |
31 |
32 | 33 | 34 | 35 |
36 |
37 | 38 | 39 | 40 |
41 |
42 | 43 | 44 | 45 |
46 |
47 | 50 |
51 |
52 |
53 |
54 |
55 | 56 | @section Scripts { 57 | @{ 58 | await Html.RenderPartialAsync("_ValidationScriptsPartial"); 59 | } 60 | } -------------------------------------------------------------------------------- /Samples/WhatsAppBusinessCloudAPI.Web/Views/Home/SendWhatsAppMediaMessage.cshtml: -------------------------------------------------------------------------------- 1 | @model SendMediaMessageViewModel 2 | @{ 3 | ViewData["Title"] = "Send WhatsApp Media Message Page"; 4 | ViewData["CurrentPage"] = "Send WhatsApp Media Message"; 5 | Layout = "~/Views/Shared/AdminLTE/_AdminLayout.cshtml"; 6 | ViewData["ControllerName"] = nameof(HomeController).Replace("Controller", ""); 7 | ViewData["ActionName"] = nameof(HomeController.SendWhatsAppMediaMessage); 8 | } 9 | 10 |
11 |
12 |
13 |
14 |
15 |

Send WhatsApp Media Message

16 |
17 | 18 |
19 |
20 |
21 |
22 | 23 | 24 | 25 |
26 |
27 | 28 | 29 | 30 |
31 |
32 | 33 | 34 | 35 |
36 |
37 | 38 | 39 | 40 |
41 |
42 | 43 | 44 | 45 |
46 |
47 | 50 |
51 |
52 |
53 |
54 |
55 | 56 | @section Scripts { 57 | @{ 58 | await Html.RenderPartialAsync("_ValidationScriptsPartial"); 59 | } 60 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Messages/Requests/InteractiveCTAButtonMessageRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.Messages.Requests 4 | { 5 | public class InteractiveCTAButtonMessageRequest 6 | { 7 | [JsonPropertyName("messaging_product")] 8 | [JsonInclude] 9 | public string MessagingProduct { get; private set; } = "whatsapp"; 10 | 11 | [JsonPropertyName("recipient_type")] 12 | [JsonInclude] 13 | public string RecipientType { get; private set; } = "individual"; 14 | 15 | [JsonPropertyName("to")] 16 | public string To { get; set; } 17 | 18 | [JsonPropertyName("type")] 19 | [JsonInclude] 20 | public string Type { get; private set; } = "interactive"; 21 | 22 | [JsonPropertyName("interactive")] 23 | public InteractiveCTAButtonMessage Interactive { get; set; } 24 | 25 | [JsonPropertyName("biz_opaque_callback_data")] 26 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 27 | public string BizOpaqueCallbackData { get; set; } 28 | } 29 | 30 | public class InteractiveCTAButtonMessage 31 | { 32 | [JsonPropertyName("type")] 33 | [JsonInclude] 34 | public string Type { get; private set; } = "cta_url"; 35 | 36 | [JsonPropertyName("header")] 37 | public CTAButtonHeader Header { get; set; } 38 | 39 | [JsonPropertyName("body")] 40 | public CTAButtonBody Body { get; set; } 41 | 42 | [JsonPropertyName("footer")] 43 | public CTAButtonFooter Footer { get; set; } 44 | 45 | [JsonPropertyName("action")] 46 | public CTAButtonAction Action { get; set; } 47 | } 48 | 49 | public class CTAButtonAction 50 | { 51 | [JsonPropertyName("name")] 52 | public string Name { get; set; } 53 | 54 | [JsonPropertyName("parameters")] 55 | public CTAButtonParameters Parameters { get; set; } 56 | } 57 | 58 | public class CTAButtonParameters 59 | { 60 | [JsonPropertyName("display_text")] 61 | public string DisplayText { get; set; } 62 | 63 | [JsonPropertyName("url")] 64 | public string Url { get; set; } 65 | } 66 | 67 | public class CTAButtonHeader 68 | { 69 | [JsonPropertyName("type")] 70 | public string Type { get; set; } 71 | 72 | [JsonPropertyName("text")] 73 | public string Text { get; set; } 74 | } 75 | 76 | public class CTAButtonBody 77 | { 78 | [JsonPropertyName("text")] 79 | public string Text { get; set; } 80 | } 81 | 82 | public class CTAButtonFooter 83 | { 84 | [JsonPropertyName("text")] 85 | public string Text { get; set; } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi.NetFramework/WhatsApp/Interfaces/IWhatsAppBusinessCloudApiClient.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using System.Threading.Tasks; 3 | using WhatsappBusiness.CloudApi.NetFramework.WhatsApp.Requests; 4 | using WhatsappBusiness.CloudApi.NetFramework.WhatsApp.Responses; 5 | 6 | namespace WhatsappBusiness.CloudApi.NetFramework.WhatsApp.Interfaces 7 | { 8 | /// 9 | /// Interface for WhatsApp Business Cloud API client 10 | /// 11 | public interface IWhatsAppBusinessCloudApiClient 12 | { 13 | /// 14 | /// Exchanges an authorization code for an access token asynchronously. 15 | /// This is used as part of the OAuth 2.0 authorization code flow for Meta Embedded Signup. 16 | /// 17 | /// Authorization code received from OAuth flow 18 | /// Redirect URI used in OAuth flow 19 | /// Cancellation token 20 | /// ExchangeTokenResponse containing the access token or error information 21 | Task ExchangeTokenAsync(string code, string redirectUri = null, CancellationToken cancellationToken = default); 22 | 23 | /// 24 | /// Get Shared WhatsApp Business Account ID from input token 25 | /// 26 | /// Input token obtained after embedded signup 27 | /// Cancellation token 28 | /// SharedWABAIDResponse 29 | Task GetSharedWABAIdAsync(string inputToken, CancellationToken cancellationToken = default); 30 | 31 | /// 32 | /// Get detailed WhatsApp Business Account information by WABA ID 33 | /// 34 | /// WhatsApp Business Account ID 35 | /// Cancellation token 36 | /// WABADetailsResponse 37 | Task GetWABADetailsAsync(string whatsAppBusinessAccountId, CancellationToken cancellationToken = default); 38 | 39 | /// 40 | /// Get all phone numbers in a WhatsApp Business Account 41 | /// 42 | /// WhatsApp Business Account ID 43 | /// Cancellation token 44 | /// PhoneNumberResponse 45 | Task GetWhatsAppBusinessAccountPhoneNumberAsync(string whatsAppBusinessAccountId, CancellationToken cancellationToken = default); 46 | } 47 | } -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Webhook/WhatsAppAdsClickReceived.cs: -------------------------------------------------------------------------------- 1 | using System.Text.Json.Serialization; 2 | 3 | namespace WhatsappBusiness.CloudApi.Webhook 4 | { 5 | 6 | public class WhatsAppAdsClickMessage : GenericMessage 7 | { 8 | [JsonPropertyName("referral")] 9 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 10 | public Referral Referral { get; set; } 11 | 12 | [JsonPropertyName("text")] 13 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 14 | public WhatsAppAdsClickText? Text { get; set; } 15 | 16 | [JsonPropertyName("audio")] 17 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 18 | public WhatsAppAdsClickAudio? Audio { get; set; } 19 | 20 | [JsonPropertyName("image")] 21 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 22 | public WhatsAppAdsClickImage? Image { get; set; } 23 | 24 | [JsonPropertyName("video")] 25 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 26 | public WhatsAppAdsClickVideo? Video { get; set; } 27 | } 28 | 29 | public class Referral 30 | { 31 | [JsonPropertyName("source_url")] 32 | public string SourceUrl { get; set; } 33 | 34 | [JsonPropertyName("source_id")] 35 | public string SourceId { get; set; } 36 | 37 | [JsonPropertyName("source_type")] 38 | public string SourceType { get; set; } 39 | 40 | [JsonPropertyName("headline")] 41 | public string Headline { get; set; } 42 | 43 | [JsonPropertyName("body")] 44 | public string Body { get; set; } 45 | 46 | [JsonPropertyName("media_type")] 47 | public string MediaType { get; set; } 48 | 49 | [JsonPropertyName("image_url")] 50 | public string ImageUrl { get; set; } 51 | 52 | [JsonPropertyName("video_url")] 53 | public string VideoUrl { get; set; } 54 | 55 | [JsonPropertyName("thumbnail_url")] 56 | public string ThumbnailUrl { get; set; } 57 | 58 | [JsonPropertyName("ctwa_clid")] 59 | public string CtwaClId { get; set; } 60 | 61 | [JsonPropertyName("welcome_message")] 62 | public ReferralWelcomeMessage WelcomeMessage { get; set; } 63 | } 64 | 65 | public class WhatsAppAdsClickText 66 | { 67 | [JsonPropertyName("body")] 68 | public string Body { get; set; } 69 | } 70 | 71 | public class ReferralWelcomeMessage 72 | { 73 | [JsonPropertyName("text")] 74 | public string Text { get; set; } 75 | } 76 | 77 | public class WhatsAppAdsClickAudio : Audio 78 | { 79 | 80 | } 81 | 82 | public class WhatsAppAdsClickImage : Image 83 | { 84 | 85 | } 86 | 87 | public class WhatsAppAdsClickVideo : Video 88 | { 89 | 90 | } 91 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Messages/Requests/FlowTemplateMessageRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Messages.Requests 5 | { 6 | public class FlowTemplateMessageRequest 7 | { 8 | [JsonPropertyName("messaging_product")] 9 | [JsonInclude] 10 | public string MessagingProduct { get; private set; } = "whatsapp"; 11 | 12 | [JsonPropertyName("recipient_type")] 13 | [JsonInclude] 14 | public string RecipientType { get; private set; } = "individual"; 15 | 16 | [JsonPropertyName("to")] 17 | public string To { get; set; } 18 | 19 | [JsonPropertyName("type")] 20 | [JsonInclude] 21 | public string Type { get; private set; } = "template"; 22 | 23 | [JsonPropertyName("template")] 24 | public FlowMessageTemplate Template { get; set; } 25 | 26 | [JsonPropertyName("biz_opaque_callback_data")] 27 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 28 | public string BizOpaqueCallbackData { get; set; } 29 | } 30 | 31 | public class FlowMessageTemplate 32 | { 33 | [JsonPropertyName("name")] 34 | public string Name { get; set; } 35 | 36 | [JsonPropertyName("language")] 37 | public FlowMessageLanguage Language { get; set; } 38 | 39 | [JsonPropertyName("components")] 40 | public List Components { get; set; } 41 | } 42 | 43 | public class FlowMessageComponent 44 | { 45 | [JsonPropertyName("type")] 46 | public string Type { get; set; } 47 | 48 | [JsonPropertyName("parameters")] 49 | public List Parameters { get; set; } 50 | 51 | [JsonPropertyName("sub_type")] 52 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 53 | public string SubType { get; set; } 54 | 55 | [JsonPropertyName("index")] 56 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] 57 | public long? Index { get; set; } 58 | } 59 | 60 | public class FlowTemplateMessageParameter 61 | { 62 | [JsonPropertyName("type")] 63 | public string Type { get; set; } 64 | 65 | [JsonPropertyName("parameter_name")] 66 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 67 | public string ParameterName { get; set; } 68 | 69 | [JsonPropertyName("action")] 70 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 71 | public FlowTemplateMessageAction Action { get; set; } 72 | } 73 | 74 | public class FlowTemplateMessageAction 75 | { 76 | [JsonPropertyName("flow_token")] 77 | public string FlowToken { get; set; } 78 | 79 | [JsonPropertyName("flow_action_data")] 80 | public object FlowActionData { get; set; } 81 | } 82 | 83 | public class FlowMessageLanguage 84 | { 85 | [JsonPropertyName("code")] 86 | public string Code { get; set; } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Messages/Requests/MultiProductMessageRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Messages.Requests 5 | { 6 | public class MultiProductMessageRequest 7 | { 8 | [JsonPropertyName("messaging_product")] 9 | [JsonInclude] 10 | public string MessagingProduct { get; private set; } = "whatsapp"; 11 | 12 | [JsonPropertyName("recipient_type")] 13 | [JsonInclude] 14 | public string RecipientType { get; private set; } = "individual"; 15 | 16 | [JsonPropertyName("to")] 17 | public string To { get; set; } 18 | 19 | [JsonPropertyName("type")] 20 | [JsonInclude] 21 | public string Type { get; private set; } = "interactive"; 22 | 23 | [JsonPropertyName("interactive")] 24 | public MultiProductInteractive Interactive { get; set; } 25 | 26 | [JsonPropertyName("biz_opaque_callback_data")] 27 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 28 | public string BizOpaqueCallbackData { get; set; } 29 | } 30 | 31 | public class MultiProductInteractive 32 | { 33 | [JsonPropertyName("type")] 34 | [JsonInclude] 35 | public string Type { get; private set; } = "product_list"; 36 | 37 | [JsonPropertyName("header")] 38 | public MultiProductHeader Header { get; set; } 39 | 40 | [JsonPropertyName("body")] 41 | public MultiProductBody Body { get; set; } 42 | 43 | [JsonPropertyName("footer")] 44 | public MultiProductBody Footer { get; set; } 45 | 46 | [JsonPropertyName("action")] 47 | public MultiProductAction Action { get; set; } 48 | } 49 | 50 | public class MultiProductAction 51 | { 52 | [JsonPropertyName("catalog_id")] 53 | public string CatalogId { get; set; } 54 | 55 | [JsonPropertyName("sections")] 56 | public List Sections { get; set; } 57 | } 58 | 59 | public class MultiProductSection 60 | { 61 | [JsonPropertyName("title")] 62 | public string Title { get; set; } 63 | 64 | [JsonPropertyName("product_items")] 65 | public List ProductItems { get; set; } 66 | } 67 | 68 | public class ProductItem 69 | { 70 | [JsonPropertyName("product_retailer_id")] 71 | public string ProductRetailerId { get; set; } 72 | } 73 | 74 | public class MultiProductBody 75 | { 76 | [JsonPropertyName("text")] 77 | public string Text { get; set; } 78 | } 79 | 80 | public class MultiProductHeader 81 | { 82 | [JsonPropertyName("type")] 83 | public string Type { get; set; } 84 | 85 | [JsonPropertyName("text")] 86 | public string Text { get; set; } 87 | } 88 | } -------------------------------------------------------------------------------- /WhatsappBusiness.CloudApi/Messages/Requests/CatalogTemplateMessageRequest.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Text.Json.Serialization; 3 | 4 | namespace WhatsappBusiness.CloudApi.Messages.Requests 5 | { 6 | public class CatalogTemplateMessageRequest 7 | { 8 | [JsonPropertyName("messaging_product")] 9 | [JsonInclude] 10 | public string MessagingProduct { get; private set; } = "whatsapp"; 11 | 12 | [JsonPropertyName("recipient_type")] 13 | [JsonInclude] 14 | public string RecipientType { get; private set; } = "individual"; 15 | 16 | [JsonPropertyName("to")] 17 | public string To { get; set; } 18 | 19 | [JsonPropertyName("type")] 20 | [JsonInclude] 21 | public string Type { get; private set; } = "template"; 22 | 23 | [JsonPropertyName("template")] 24 | public CatalogMessageTemplate Template { get; set; } 25 | 26 | [JsonPropertyName("biz_opaque_callback_data")] 27 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 28 | public string BizOpaqueCallbackData { get; set; } 29 | } 30 | 31 | public class CatalogMessageTemplate 32 | { 33 | [JsonPropertyName("name")] 34 | public string Name { get; set; } 35 | 36 | [JsonPropertyName("language")] 37 | public CatalogMessageLanguage Language { get; set; } 38 | 39 | [JsonPropertyName("components")] 40 | public List Components { get; set; } 41 | } 42 | 43 | public class CatalogMessageComponent 44 | { 45 | [JsonPropertyName("type")] 46 | public string Type { get; set; } 47 | 48 | [JsonPropertyName("parameters")] 49 | public List Parameters { get; set; } 50 | 51 | [JsonPropertyName("sub_type")] 52 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 53 | public string SubType { get; set; } 54 | 55 | [JsonPropertyName("index")] 56 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] 57 | public long? Index { get; set; } 58 | } 59 | 60 | public class CatalogTemplateMessageParameter 61 | { 62 | [JsonPropertyName("type")] 63 | public string Type { get; set; } 64 | 65 | [JsonPropertyName("parameter_name")] 66 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 67 | public string ParameterName { get; set; } 68 | 69 | [JsonPropertyName("text")] 70 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 71 | public string Text { get; set; } 72 | 73 | [JsonPropertyName("action")] 74 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] 75 | public CatalogTemplateMessageAction Action { get; set; } 76 | } 77 | 78 | public class CatalogTemplateMessageAction 79 | { 80 | [JsonPropertyName("thumbnail_product_retailer_id")] 81 | public string ThumbnailProductRetailerId { get; set; } 82 | } 83 | 84 | public class CatalogMessageLanguage 85 | { 86 | [JsonPropertyName("code")] 87 | public string Code { get; set; } 88 | } 89 | } 90 | --------------------------------------------------------------------------------