{"id":25409464,"url":"https://github.com/gabrieldwight/whatsapp-business-cloud-api-net","last_synced_at":"2026-01-07T00:09:52.132Z","repository":{"id":37817060,"uuid":"496419483","full_name":"gabrieldwight/Whatsapp-Business-Cloud-Api-Net","owner":"gabrieldwight","description":"This is C# wrapper of whatsapp business cloud api for .NET","archived":false,"fork":false,"pushed_at":"2025-05-13T23:05:39.000Z","size":3525,"stargazers_count":369,"open_issues_count":1,"forks_count":137,"subscribers_count":30,"default_branch":"master","last_synced_at":"2025-05-14T00:35:37.670Z","etag":null,"topics":["csharp","dotnet","whatsapp","whatsapp-api","whatsapp-business","whatsapp-business-api","whatsapp-cloud-api-client"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gabrieldwight.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"License","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-05-25T23:28:32.000Z","updated_at":"2025-05-13T22:54:46.000Z","dependencies_parsed_at":"2024-04-21T20:23:17.864Z","dependency_job_id":"d20e33d1-d74a-4497-a9f5-ea2e9c5a56f4","html_url":"https://github.com/gabrieldwight/Whatsapp-Business-Cloud-Api-Net","commit_stats":{"total_commits":99,"total_committers":4,"mean_commits":24.75,"dds":0.06060606060606055,"last_synced_commit":"d9e62c81210ec711da2606b65e7d7c2006892a2d"},"previous_names":[],"tags_count":66,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabrieldwight%2FWhatsapp-Business-Cloud-Api-Net","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabrieldwight%2FWhatsapp-Business-Cloud-Api-Net/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabrieldwight%2FWhatsapp-Business-Cloud-Api-Net/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gabrieldwight%2FWhatsapp-Business-Cloud-Api-Net/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gabrieldwight","download_url":"https://codeload.github.com/gabrieldwight/Whatsapp-Business-Cloud-Api-Net/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254464895,"owners_count":22075570,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csharp","dotnet","whatsapp","whatsapp-api","whatsapp-business","whatsapp-business-api","whatsapp-cloud-api-client"],"created_at":"2025-02-16T08:28:04.005Z","updated_at":"2026-01-07T00:09:52.125Z","avatar_url":"https://github.com/gabrieldwight.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WhatsApp Business Cloud API C# Wrapper Library for .NET Developers\n\nA Wrapper for the WhatsApp Business Cloud API hosted by Meta.\n\n[![Build status](https://dev.azure.com/gabrieldwight/WhatsappCloudApi/_apis/build/status/WhatsappCloudApi-CI)](https://dev.azure.com/gabrieldwight/WhatsappCloudApi/_build/latest?definitionId=9)\n[![NuGet version (WhatsappBusiness.CloudApi)](https://img.shields.io/nuget/v/WhatsappBusiness.CloudApi.svg?style=flat-square)](https://www.nuget.org/packages/WhatsappBusiness.CloudApi/)\n\nOfficial API Documentation: [Meta for Developers](https://developers.facebook.com/docs/whatsapp/cloud-api/overview)\n\nSell Product and Services: [Product Message Configuration](https://developers.facebook.com/docs/whatsapp/cloud-api/guides/sell-products-and-services)\n\nAccount Metrics: [Account Metrics Configuration for analytics and conversation analytics](https://developers.facebook.com/docs/whatsapp/business-management-api/analytics)\n\nQR Code Message Management: [QR Code Messages for WhatsApp Business](https://developers.facebook.com/docs/whatsapp/business-management-api/qr-codes)\n\nWhatsApp Flows: [Setting up WhatsApp Flows](https://developers.facebook.com/docs/whatsapp/flows/gettingstarted/)\n\nWhatsApp Welcome Message: [Setting up Conversational Components](https://developers.facebook.com/docs/whatsapp/cloud-api/phone-numbers/conversational-components)\n\nWhatsApp Block User API: [How to block a user](https://developers.facebook.com/docs/whatsapp/cloud-api/block-users?locale=en_US)\n\nWhatsApp Cloud API Calling: [How to set up cloud API VoIP calls](https://developers.facebook.com/docs/whatsapp/cloud-api/calling)\n\nWhatsApp Group API: [How to send messages to a group chat](https://developers.facebook.com/docs/whatsapp/cloud-api/groups/getting-started)\n\nWebhook Configuration Documentation: [WhatsApp Cloud API Webhook](https://developers.facebook.com/docs/graph-api/webhooks/getting-started#verification-requests)\n\nAuthentication Message Documentation: [Create and Send Authentication Message](https://developers.facebook.com/docs/whatsapp/business-management-api/authentication-templates)\n\nWhatsApp Cloud API Error Codes: [Error Codes](https://developers.facebook.com/docs/whatsapp/cloud-api/support/error-codes)\n\n- [End User License](https://github.com/gabrieldwight/Whatsapp-Business-Cloud-Api-Net/blob/master/LICENSE)\n- [NuGet Package](https://www.nuget.org/packages/WhatsappBusiness.CloudApi/)\n\nTake note: Sending a message to a phone number format `00[Country Code] xx xx xx` using the prefix `00` before the country code will make the cloud API return an invalid parameter error (#100) (Credits @Tekkharibo)\n\nNote: Downloading media from the generated WhatsApp media URL requires specifying the app name and version value as the user agent for the download media function to work. It is included as a property for the config class. (Credits @atmtrujillo)\n\n## Capabilities\n\n\u003e Note: **This package is WIP**. The capabilities of the Cloud API will be reflected soon. Feel free to contribute!\n\n- [x] Sending Messages\n  - [x] Text\n  - [x] Media (image, video, audio, document, sticker)\n  - [x] Contact\n  - [x] Location\n  - [x] Interactive (List, Reply)\n  - [x] Template (text, image, video, document, authentication, flow message, carousel, catalog message, limited-time offer message, product message)\n  - [x] Template Messages with parameters (text, image, video, document, authentication, product message)\n  - [x] Single Product Message\n  - [x] Multiple Product Message\n  - [x] Authentication Message\n  - [x] Flow Message\n  - [x] Conversational Components\n  - [x] Block User\n  - [X] VoIP Calls support\n  - [X] Sending Messages to Group\n- [x] Receiving Message (via Webhook)\n  - [x] Text\n  - [x] Media (image, video, audio, document, sticker)\n  - [x] Contact\n  - [x] Location\n  - [x] Interactive (List, Reply)\n  - [x] Button\n\n- [x] WhatsApp Business Management API\n  - [x] QR Code Message Management\n  - [x] Account Metrics\n  - [X] Template Management\n\n- [x] Sample project\n  - [x] Read csv, and send over WhatsApp per record\n  - [x] Implements many of the samples below\n  - [x] Upload files to local server, before uploading to WhatsApp\n     \n\n## Installation\n- PackageManager: ```PM\u003e Install-Package WhatsappBusiness.CloudApi```\n- DotNetCLI: ```\u003e dotnet add package WhatsappBusiness.CloudApi```\n\n## Setting yourself up for successful WhatsApp Business Cloud Api integration\nBefore you proceed kindly acquaint yourself with WhatsApp Business Cloud Apis by going through the Docs in Meta's developer portal if you like.\n\n1.  Obtain a Temporary access token for the meta developers portal.\n\n2.  Ensure your project is running on the minimum supported versions of .Net \n\n3.  WhatsAppBusinessCloudAPi is dependency injection (DI) friendly and can be readily injected into your classes. You can read more on DI in Asp.Net core [**here**](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/dependency-injection?view=aspnetcore-5.0). If you can't use DI you can always manually create a new instance of WhatsAppBusinessClient and pass in an httpClient instance in its constructor. eg.\n\n```c#\n// When Dependency Injection is not possible...\n\n//create httpclient instance\nvar httpClient = new HttpClient();\n\nhttpClient.BaseAddress = WhatsAppBusinessRequestEndpoint.BaseAddress;\n\t\n//create WhatsAppBusiness API client instance\nvar whatsAppBusinessClient = new WhatsAppBusinessClient(httpClient, whatsAppConfig); //make sure to pass httpclient and whatsAppConfig instance as an argument\n\t\n```\nI recommend creating WhatsAppBusinessClient using Dependency Injection. [Optional] You can use any IOC container or Microsoft DI container in your legacy projects.\n```c#\n// Adding Dependency Injection into legacy projects\n\npublic static IServiceProvider ServiceProvider;\n\n\n// To be used in the main application startup method\nvoid Application_Start(object sender, EventArgs e)\n{\n  var hostBuilder = new HostBuilder();\n  hostBuilder.ConfigureServices(ConfigureServices);\n  var host = hostBuilder.Build();\n\n  ServiceProvider = host.Services;\n}\n\nvoid ConfigureServices(IServiceCollection services)\n{\n   services.AddHttpClient\u003cIWhatsAppBusinessClient, WhatsAppBusinessClient\u003e(options =\u003e options.BaseAddress = WhatsAppBusinessRequestEndpoint.BaseAddress);\n   //inject services here\n}\n\t\n```\n\n## Registering WhatsAppBusinessClient \u0026 Set the BaseAddress -Dependency Injection Method in ASPNETCORE\n* Install WhatsappBusiness.CloudApi Project via Nuget Package Manager Console or Nuget Package Manager GUI.\n\n## For ASPNETCORE projects\n* In **Program.cs** add the namespace...\n\n```c#    \nusing WhatsappBusiness.CloudApi.Configurations;\nusing WhatsappBusiness.CloudApi.Extensions;\n```\n\n* Inside ConfigureServices method add the following\n\n```c#\nWhatsAppBusinessCloudApiConfig whatsAppConfig = new WhatsAppBusinessCloudApiConfig();\nwhatsAppConfig.WhatsAppBusinessPhoneNumberId = builder.Configuration.GetSection(\"WhatsAppBusinessCloudApiConfiguration\")[\"WhatsAppBusinessPhoneNumberId\"];\nwhatsAppConfig.WhatsAppBusinessAccountId = builder.Configuration.GetSection(\"WhatsAppBusinessCloudApiConfiguration\")[\"WhatsAppBusinessAccountId\"];\nwhatsAppConfig.WhatsAppBusinessId = builder.Configuration.GetSection(\"WhatsAppBusinessCloudApiConfiguration\")[\"WhatsAppBusinessId\"];\nwhatsAppConfig.AccessToken = builder.Configuration.GetSection(\"WhatsAppBusinessCloudApiConfiguration\")[\"AccessToken\"];\nbuilder.Services.AddWhatsAppBusinessCloudApiService(whatsAppConfig);\n```\n\n* Once the WhatsAppBusinessClient is registered, you can pass it and use it in your classes to make API calls to WhatsApp Business Cloud API Server as follows;\n```c#\npublic class SendMessageController\n{\n\tprivate readonly IWhatsAppBusinessClient _whatsAppBusinessClient;\n\tpublic SendMessageController(IWhatsAppBusinessClient whatsAppBusinessClient)\n\t{\n\t\t_whatsAppBusinessClient = whatsAppBusinessClient;\n\t}\n\t....\n\t//code omitted for brevity\n}\n```\n\n## Send Text Message Request\n```c#\nTextMessageRequest textMessageRequest = new TextMessageRequest();\ntextMessageRequest.To = \"Recipient Phone Number\";\ntextMessageRequest.Text = new WhatsAppText();\ntextMessageRequest.Text.Body = \"Message Body\";\ntextMessageRequest.Text.PreviewUrl = false;\n\nvar results = await _whatsAppBusinessClient.SendTextMessageAsync(textMessageRequest);\n```\n## Send Audio Message Request\n```c#\nAudioMessageByUrlRequest audioMessage = new AudioMessageByUrlRequest();\naudioMessage.To = \"Recipient Phone Number\";\naudioMessage.Audio = new MediaAudioUrl();\naudioMessage.Audio.Link = \"Audio Url\";\n\nvar results = await _whatsAppBusinessClient.SendAudioAttachmentMessageByUrlAsync(audioMessage);\n```\n## Send Document Message Request\n```c#\nDocumentMessageByUrlRequest documentMessage = new DocumentMessageByUrlRequest();\ndocumentMessage.To = \"Recipient Phone Number\";\ndocumentMessage.Document = new MediaDocumentUrl();\ndocumentMessage.Document.Link = \"Document Url\";\n\nvar results = await _whatsAppBusinessClient.SendDocumentAttachmentMessageByUrlAsync(documentMessage);\n```\n\n## Send Image Message Request\n```c#\nImageMessageByUrlRequest imageMessage = new ImageMessageByUrlRequest();\nimageMessage.To = \"Recipient Phone Number\";\nimageMessage.Image = new MediaImageUrl();\nimageMessage.Image.Link = \"Image Url\";\n\nvar results = await _whatsAppBusinessClient.SendImageAttachmentMessageByUrlAsync(imageMessage);\n```\n## Send Sticker Message Request\n```c#\nStickerMessageByUrlRequest stickerMessage = new StickerMessageByUrlRequest();\nstickerMessage.To = \"Recipient Phone Number\";\nstickerMessage.Sticker = new MediaStickerUrl();\nstickerMessage.Sticker.Link = \"Sticker Url\";\n\nvar results = await _whatsAppBusinessClient.SendStickerMessageByUrlAsync(stickerMessage);\n```\n\n## Send Video Message Request\n```c#\nVideoMessageByUrlRequest videoMessage = new VideoMessageByUrlRequest();\nvideoMessage.To = \"Recipient Phone Number\";\nvideoMessage.Video = new MediaVideoUrl();\nvideoMessage.Video.Link = \"Video url\";\n\nvar results = await _whatsAppBusinessClient.SendVideoAttachmentMessageByUrlAsync(videoMessage);\n```\n\n## Send Contact Message Request\n```c#\nContactMessageRequest contactMessageRequest = new ContactMessageRequest();\ncontactMessageRequest.To = \"Recipient Phone Number\";\ncontactMessageRequest.Contacts = new List\u003cContactData\u003e()\n{\n    new ContactData()\n    {\n        Addresses = new List\u003cAddress\u003e()\n        {\n            new Address()\n            {\n                State = \"State Test\",\n                City = \"City Test\",\n                Zip = \"Zip Test\",\n                Country = \"Country Test\",\n                CountryCode = \"Country Code Test\",\n                Type = \"Home\"\n            }\n        },\n        Name = new Name()\n        {\n            FormattedName = \"Testing name\",\n            FirstName = \"FName\",\n            LastName = \"LName\",\n            MiddleName = \"MName\"\n        }\n    }\n};\n\nvar results = await _whatsAppBusinessClient.SendContactAttachmentMessageAsync(contactMessageRequest);\n```\n\n## Send Location Message Request\n```c#\nLocationMessageRequest locationMessageRequest = new LocationMessageRequest();\nlocationMessageRequest.To = \"Recipient Phone Number\";\nlocationMessageRequest.Location = new Location();\nlocationMessageRequest.Location.Name = \"Location Test\";\nlocationMessageRequest.Location.Address = \"Address Test\";\nlocationMessageRequest.Location.Longitude = \"location longitude\";\nlocationMessageRequest.Location.Latitude = \"location latitude\";\n\nvar results = await _whatsAppBusinessClient.SendLocationMessageAsync(locationMessageRequest);\n```\n\n## Send Interactive List Message Request\n```c#\nInteractiveListMessageRequest interactiveListMessage = new InteractiveListMessageRequest();\ninteractiveListMessage.To = \"Recipient Phone Number\";\ninteractiveListMessage.Interactive = new InteractiveListMessage();\n\ninteractiveListMessage.Interactive.Header = new Header();\ninteractiveListMessage.Interactive.Header.Type = \"text\";\ninteractiveListMessage.Interactive.Header.Text = \"List Header Sample Test\";\n\ninteractiveListMessage.Interactive.Body = new ListBody();\ninteractiveListMessage.Interactive.Body.Text = \"List Message Body\";\n\ninteractiveListMessage.Interactive.Footer = new Footer();\ninteractiveListMessage.Interactive.Footer.Text = \"List Footer Sample Test\";\n\ninteractiveListMessage.Interactive.Action = new ListAction();\ninteractiveListMessage.Interactive.Action.Button = \"Send\";\ninteractiveListMessage.Interactive.Action.Sections = new List\u003cSection\u003e()\n{\n    new Section()\n    {\n        Title = \"Category A\",\n        Rows = new List\u003cRow\u003e()\n        {\n            new Row()\n            {\n                Id = \"Item_A1\",\n                Title = \"Apples\",\n                Description = \"Enjoy fruits for free\"\n            },\n            new Row()\n            {\n                Id = \"Item_A2\",\n                Title = \"Tangerines\",\n                Description = \"Enjoy fruits for free\"\n            },\n        },\n    },\n    new Section()\n    {\n        Title = \"Category B\",\n        Rows = new List\u003cRow\u003e()\n        {\n            new Row()\n            {\n                Id = \"Item_B1\",\n                Title = \"2JZ\",\n                Description = \"Engine discounts\"\n            },\n            new Row()\n            {\n                Id = \"Item_2\",\n                Title = \"1JZ\",\n                Description = \"Engine discounts\"\n            },\n        }\n    }\n};\n\nvar results = await _whatsAppBusinessClient.SendInteractiveListMessageAsync(interactiveListMessage);\n```\n## Send Interactive Reply Button Request\n```c#\nInteractiveReplyButtonMessageRequest interactiveReplyButtonMessage = new InteractiveReplyButtonMessageRequest();\ninteractiveReplyButtonMessage.To = \"Recipient Phone Number\";\ninteractiveReplyButtonMessage.Interactive = new InteractiveReplyButtonMessage();\n\ninteractiveReplyButtonMessage.Interactive.Body = new ReplyButtonBody();\ninteractiveReplyButtonMessage.Interactive.Body.Text = \"Reply Button Body\";\n\ninteractiveReplyButtonMessage.Interactive.Action = new ReplyButtonAction();\ninteractiveReplyButtonMessage.Interactive.Action.Buttons = new List\u003cReplyButton\u003e()\n{\n    new ReplyButton() \n    {\n        Type = \"reply\",\n        Reply = new Reply()\n        {\n            Id = \"SAMPLE_1_CLICK\",\n            Title = \"CLICK ME!!!\"\n        }\n    },\n\n    new ReplyButton()\n    {\n        Type = \"reply\",\n        Reply = new Reply()\n        {\n            Id = \"SAMPLE_2_CLICK\",\n            Title = \"LATER\"\n        }\n    }\n};\n\nvar results = await _whatsAppBusinessClient.SendInteractiveReplyButtonMessageAsync(interactiveReplyButtonMessage);\n```\n\n## Send Template Message Request\n```c#\nTextTemplateMessageRequest textTemplateMessage = new TextTemplateMessageRequest();\ntextTemplateMessage.To = \"Recipient Phone Number\";\ntextTemplateMessage.Template = new TextMessageTemplate();\ntextTemplateMessage.Template.Name = \"Template Name\";\ntextTemplateMessage.Template.Language = new TextMessageLanguage();\ntextTemplateMessage.Template.Language.Code = \"en_US\";\n\nvar results = await _whatsAppBusinessClient.SendTextMessageTemplateAsync(textTemplateMessage);\n```\n\n## Send Text Template Message with parameters request\n```c#\n// For Text Template message with parameters supported component type is body only\nTextTemplateMessageRequest textTemplateMessage = new TextTemplateMessageRequest();\ntextTemplateMessage.To = sendTemplateMessageViewModel.RecipientPhoneNumber;\ntextTemplateMessage.Template = new TextMessageTemplate();\ntextTemplateMessage.Template.Name = sendTemplateMessageViewModel.TemplateName;\ntextTemplateMessage.Template.Language = new TextMessageLanguage();\ntextTemplateMessage.Template.Language.Code = LanguageCode.English_US;\ntextTemplateMessage.Template.Components = new List\u003cTextMessageComponent\u003e();\ntextTemplateMessage.Template.Components.Add(new TextMessageComponent()\n{\n    Type = \"body\",\n    Parameters = new List\u003cTextMessageParameter\u003e()\n    {\n\tnew TextMessageParameter()\n\t{\n\t    Type = \"text\",\n\t    Text = \"Testing Parameter Placeholder Position 1\"\n\t},\n\tnew TextMessageParameter()\n\t{\n\t    Type = \"text\",\n\t    Text = \"Testing Parameter Placeholder Position 2\"\n\t}\n    }\n});\n\nvar results = await _whatsAppBusinessClient.SendTextMessageTemplateAsync(textTemplateMessage);\n```\n\n## Send Media Template Message with parameters\n```c#\n// Tested with facebook predefined template name: sample_movie_ticket_confirmation\nImageTemplateMessageRequest imageTemplateMessage = new ImageTemplateMessageRequest();\nimageTemplateMessage.To = sendTemplateMessageViewModel.RecipientPhoneNumber;\nimageTemplateMessage.Template = new ImageMessageTemplate();\nimageTemplateMessage.Template.Name = sendTemplateMessageViewModel.TemplateName;\nimageTemplateMessage.Template.Language = new ImageMessageLanguage();\nimageTemplateMessage.Template.Language.Code = LanguageCode.English_US;\nimageTemplateMessage.Template.Components = new List\u003cImageMessageComponent\u003e()\n{\n    new ImageMessageComponent()\n    {\n\tType = \"header\",\n\tParameters = new List\u003cImageMessageParameter\u003e()\n\t{\n\t    new ImageMessageParameter()\n\t    {\n\t\tType = \"image\",\n\t\tImage = new Image()\n\t\t{\n\t\t    Link = \"https://otakukart.com/wp-content/uploads/2022/03/Upcoming-Marvel-Movies-In-2022-23.jpg\"\n\t\t}\n\t    }\n\t},\n    },\n    new ImageMessageComponent()\n    {\n\tType = \"body\",\n\tParameters = new List\u003cImageMessageParameter\u003e()\n\t{\n\t    new ImageMessageParameter()\n\t    {\n\t\tType = \"text\",\n\t\tText = \"Movie Testing\"\n\t    },\n\n\t    new ImageMessageParameter()\n\t    {\n\t\tType = \"date_time\",\n\t\tDateTime = new ImageTemplateDateTime()\n\t\t{\n\t\t    FallbackValue = DateTime.Now.ToString(\"dddd d, yyyy\"),\n\t\t    DayOfWeek = (int)DateTime.Now.DayOfWeek,\n\t\t    Year = DateTime.Now.Year,\n\t\t    Month = DateTime.Now.Month,\n\t\t    DayOfMonth = DateTime.Now.Day,\n\t\t    Hour = DateTime.Now.Hour,\n\t\t    Minute = DateTime.Now.Minute,\n\t\t    Calendar = \"GREGORIAN\"\n\t\t}\n\t    },\n\n\t    new ImageMessageParameter()\n\t    {\n\t\tType = \"text\",\n\t\tText = \"Venue Test\"\n\t    },\n\n\t    new ImageMessageParameter()\n\t    {\n\t\tType = \"text\",\n\t\tText = \"Seat 1A, 2A, 3A and 4A\"\n\t    }\n\t}\n    }\n};\n\nvar results = await _whatsAppBusinessClient.SendImageAttachmentTemplateMessageAsync(imageTemplateMessage);\n```\n\n## Send Interactive Template Message with parameters\n```c#\n// Tested with facebook predefined template name: sample_issue_resolution\nInteractiveTemplateMessageRequest interactiveTemplateMessage = new InteractiveTemplateMessageRequest();\ninteractiveTemplateMessage.To = sendTemplateMessageViewModel.RecipientPhoneNumber;\ninteractiveTemplateMessage.Template = new InteractiveMessageTemplate();\ninteractiveTemplateMessage.Template.Name = sendTemplateMessageViewModel.TemplateName;\ninteractiveTemplateMessage.Template.Language = new InteractiveMessageLanguage();\ninteractiveTemplateMessage.Template.Language.Code = LanguageCode.English_US;\ninteractiveTemplateMessage.Template.Components = new List\u003cInteractiveMessageComponent\u003e();\ninteractiveTemplateMessage.Template.Components.Add(new InteractiveMessageComponent()\n{\n    Type = \"body\",\n    Parameters = new List\u003cInteractiveMessageParameter\u003e()\n    {\n\tnew InteractiveMessageParameter()\n\t{\n\t    Type = \"text\",\n\t    Text = \"Interactive Parameter Placeholder Position 1\"\n\t}\n    }\n});\n\nvar results = await _whatsAppBusinessClient.SendInteractiveTemplateMessageAsync(interactiveTemplateMessage);\n```\n\n## Sending Authentication Message\n```c#\n// You need to create your authentication template message\nAuthenticationTemplateMessageRequest authenticationTemplateMessageRequest = new();\nauthenticationTemplateMessageRequest.To = sendTemplateMessageViewModel.RecipientPhoneNumber;\nauthenticationTemplateMessageRequest.Template = new();\nauthenticationTemplateMessageRequest.Template.Name = sendTemplateMessageViewModel.TemplateName;\nauthenticationTemplateMessageRequest.Template.Language = new();\nauthenticationTemplateMessageRequest.Template.Language.Code = LanguageCode.English_US;\nauthenticationTemplateMessageRequest.Template.Components = new List\u003cAuthenticationMessageComponent\u003e()\n{\n    new AuthenticationMessageComponent()\n    {\n\tType = \"body\",\n\tParameters = new List\u003cAuthenticationMessageParameter\u003e()\n\t{\n\t    new AuthenticationMessageParameter()\n\t    {\n\t\tType = \"text\",\n\t\tText = \"J$FpnYnP\" // One time password value\n\t    }\n\t}\n    },\n    new AuthenticationMessageComponent()\n    {\n\tType = \"button\",\n\tSubType = \"url\",\n\tIndex = 0,\n\tParameters = new List\u003cAuthenticationMessageParameter\u003e()\n\t{\n\t    new AuthenticationMessageParameter()\n\t    {\n\t\tType = \"text\",\n\t\tText = \"J$FpnYnP\" // One time password value\n\t    }\n\t}\n    }\n};\n\nvar results = await _whatsAppBusinessClient.SendAuthenticationMessageTemplateAsync(authenticationTemplateMessageRequest);\n```\n\n## Sending Flow Message\n```c#\nFlowMessageRequest flowMessageRequest = new FlowMessageRequest();\nflowMessageRequest.To = sendFlowMessageViewModel.RecipientPhoneNumber;\nflowMessageRequest.Interactive = new FlowMessageInteractive();\n\nflowMessageRequest.Interactive.Header = new FlowMessageHeader();\nflowMessageRequest.Interactive.Header.Type = \"text\";\nflowMessageRequest.Interactive.Header.Text = \"Header flow\";\n\nflowMessageRequest.Interactive.Body = new FlowMessageBody();\nflowMessageRequest.Interactive.Body.Text = \"Body flow\";\n\nflowMessageRequest.Interactive.Footer = new FlowMessageFooter();\nflowMessageRequest.Interactive.Footer.Text = \"Footer flow\";\n\nflowMessageRequest.Interactive.Action = new FlowMessageAction();\nflowMessageRequest.Interactive.Action.Parameters = new FlowMessageParameters();\nflowMessageRequest.Interactive.Action.Parameters.FlowToken = sendFlowMessageViewModel.FlowToken;\nflowMessageRequest.Interactive.Action.Parameters.FlowId = sendFlowMessageViewModel.FlowId;\nflowMessageRequest.Interactive.Action.Parameters.FlowCta = sendFlowMessageViewModel.FlowButtonText;\nflowMessageRequest.Interactive.Action.Parameters.FlowAction = sendFlowMessageViewModel.SelectedFlowAction;\nflowMessageRequest.Interactive.Action.Parameters.IsInDraftMode = (sendFlowMessageViewModel.SelectedMode.Equals(\"Draft\", StringComparison.OrdinalIgnoreCase));\n\nflowMessageRequest.Interactive.Action.Parameters.FlowActionPayload = new FlowActionPayload();\nflowMessageRequest.Interactive.Action.Parameters.FlowActionPayload.Screen = sendFlowMessageViewModel.ScreenId;\n\nvar results = await _whatsAppBusinessClient.SendFlowMessageAsync(flowMessageRequest);\n```\n\n## Sending Flow Template Message\n```c#\nFlowTemplateMessageRequest flowTemplateMessageRequest = new FlowTemplateMessageRequest();\nflowTemplateMessageRequest.To = sendTemplateMessageViewModel.RecipientPhoneNumber;\nflowTemplateMessageRequest.Template = new();\nflowTemplateMessageRequest.Template.Name = sendTemplateMessageViewModel.TemplateName;\nflowTemplateMessageRequest.Template.Language = new();\nflowTemplateMessageRequest.Template.Language.Code = LanguageCode.English_US;\nflowTemplateMessageRequest.Template.Components = new List\u003cFlowMessageComponent\u003e()\n{\n    new FlowMessageComponent()\n    {\n        Type = \"button\",\n        SubType = \"flow\",\n        Index = 0,\n        Parameters = new List\u003cFlowTemplateMessageParameter\u003e()\n        {\n            new FlowTemplateMessageParameter()\n            {\n                Type = \"action\",\n                Action = new FlowTemplateMessageAction()\n                {\n                    FlowToken = \"\",\n                }\n            }\n        }\n    }\n};\n\nvar results = await _whatsAppBusinessClient.SendFlowMessageTemplateAsync(flowTemplateMessageRequest);\n```\n\n## Sending template messages with different parameters\n```C#\n// Text Header, Body with Parameters, Footer, and Quick Reply Button\nvar components = new[]\n{\n    new TemplateComponent { Type = \"header\", Text = \"Order Update\" },\n    new TemplateComponent \n    { \n        Type = \"body\", \n        Parameters = new object[] { new { type = \"text\", text = \"Your order is ready!\" } }\n    },\n    new TemplateComponent { Type = \"footer\", Text = \"Need help? Reply below\" },\n    new TemplateComponent \n    { \n        Type = \"button\", \n        Parameters = new object[] { new { type = \"text\", text = \"Track Order\" } }\n    }\n};\n\nawait _whatsAppBusinessClient.SendTemplateMessageAsync(\"+1234567890\", \"template_name\", \"en_US\", components);\n\n//  Image Header, Body, and Call-to-Action Button (URL)\nvar components = new[]\n{\n    new TemplateComponent \n    { \n        Type = \"header\", \n        Parameters = new object[] { new { type = \"image\", image = new { link = \"https://example.com/image.jpg\" } } }\n    },\n    new TemplateComponent \n    { \n        Type = \"body\", \n        Parameters = new object[] { new { type = \"text\", text = \"Check out our latest offers!\" } }\n    },\n    new TemplateComponent \n    { \n        Type = \"button\", \n        Parameters = new object[] \n        { \n            new { type = \"text\", text = \"Visit Website\", sub_type = \"url\", url = \"https://example.com\" } \n        }\n    }\n};\n\nawait _whatsAppBusinessClient.SendTemplateMessageAsync(\"+1234567890\", \"template_name\", \"en_US\", components);\n```\n\n## Webhook Subscription\nFirst, you need to setup the callback url and verify the token string for WhatsApp Cloud API to verify your callback url.\nVerification part\n```c#\n[HttpGet(\"\u003cYOUR ENDPOINT ROUTE\u003e\")]\npublic ActionResult\u003cstring\u003e ConfigureWhatsAppMessageWebhook([FromQuery(Name = \"hub.mode\")] string hubMode,\n                                                                    [FromQuery(Name = \"hub.challenge\")] int hubChallenge,\n                                                                    [FromQuery(Name = \"hub.verify_token\")] string hubVerifyToken)\n{\nreturn Ok(hubChallenge);\n}\n```\n\n## Receiving Messages\n```c#\n[HttpPost(\"\u003cYOUR ENDPOINT ROUTE\u003e\")]\npublic IActionResult ReceiveWhatsAppTextMessage([FromBody] dynamic messageReceived)\n{\n// Logic to handle different type of messages received\nreturn Ok();\n}\n```\n\n## Reply to Message\n```c#\nTextMessageReplyRequest textMessageReplyRequest = new TextMessageReplyRequest();\ntextMessageReplyRequest.Context = new TextMessageContext();\ntextMessageReplyRequest.Context.MessageId = textMessage.SingleOrDefault().Id;\ntextMessageReplyRequest.To = textMessage.SingleOrDefault().From;\ntextMessageReplyRequest.Text = new WhatsAppText();\ntextMessageReplyRequest.Text.Body = \"Your Message was received. Processing the request shortly\";\ntextMessageReplyRequest.Text.PreviewUrl = false;\n\nawait _whatsAppBusinessClient.SendTextMessageAsync(textMessageReplyRequest);\n```\n\n## Verify Webhook X-Hub-Signature-256 (Credits @Tekkharibo)\n```c#\n[HttpPost]\npublic async Task\u003cIActionResult\u003e GetMessage()\n{\n    string stringifiedBody;\n\n    string xHubSignature256 = this.HttpContext.Request.Headers[\"X-Hub-Signature-256\"].ToString();\n\n    using (var sr = new StreamReader(this.HttpContext.Request.Body))\n    {\n        stringifiedBody = await sr.ReadToEndAsync().ConfigureAwait(false);\n    }\n\n    string xHubSignature256Result = FacebookWebhookHelper.CalculateSignature(this._configuration.GetSection(\"WhatsAppBusinessCloudApiConfiguration\")[\"AppSecret\"], stringifiedBody);\n\n    if (!String.Equals(xHubSignature256, xHubSignature256Result, StringComparison.InvariantCultureIgnoreCase))\n        return this.Unauthorized(\"Invalid Signature\");\n\n    return this.Ok();\n}\n```\n\n## Verify Webhook X-Hub-Signature-256 (.NET 7 Minimal API) (Credits @sapharos)\n```c#\napp.Use((context, next) =\u003e\n{\n\tcontext.Request.EnableBuffering();\n\treturn next();\n});\n\n// Validation implementation\n\nstring stringifiedBody;\nstring xHubSignature256 = context.Request.Headers[\"X-Hub-Signature-256\"].ToString();\ncontext.Request.Body.Seek(0, SeekOrigin.Begin);\nusing (var sr = new StreamReader(context.Request.Body))\n{\n\tstringifiedBody = await sr.ReadToEndAsync().ConfigureAwait(false);\n}\nstring xHubSignature256Result = FacebookWebhookHelper.CalculateSignature(_config.GetValue\u003cstring(\"Facebook:AppSecret\"), stringifiedBody);\nif (!String.Equals(xHubSignature256, xHubSignature256Result,StringComparison.InvariantCultureIgnoreCase))\n{\n\treturn Results.Unauthorized();\n}\n```\n\n## Error handling\nWhatsAppBusinessClient Throws ```WhatsappBusinessCloudAPIException``` It is your role as the developer to catch\nthe exception and continue processing in your application. The snippet below shows how you can catch the WhatsappBusinessCloudAPIException.\n\n```c#\nusing WhatsappBusiness.CloudApi.Exceptions; // add this to your class or namespace\n\ntry\n{\t\n\treturn await _whatsAppBusinessClient.SendTextMessageAsync(textMessageRequest);\n}\ncatch (WhatsappBusinessCloudAPIException ex)\n{\n\t_logger.LogError(ex, ex.Message);\n}\t\t\n```\n## Issues\n\nIf you will face any issues with the usage of this package please raise one so that we can quickly fix it as soon as possible.\n\n## Contributing\n\nThis is an open-source project under ```MIT License``` so anyone is welcome to contribute from typos, to source code to documentation.\n\n## Credits\n1. [Gabriel](https://github.com/gabrieldwight)\n2. All other contributors\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgabrieldwight%2Fwhatsapp-business-cloud-api-net","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgabrieldwight%2Fwhatsapp-business-cloud-api-net","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgabrieldwight%2Fwhatsapp-business-cloud-api-net/lists"}