Skip to content

.NET 5 / Blazor app to demonstrate how to send/ receive WhatsApp messages via the Twilio API

Notifications You must be signed in to change notification settings

abierhaus/twilio-whatsapp-example

Repository files navigation

Twilio API WhatsApp .NET Blazor Example

This Blazor App demonstrates how to send and receive WhatsApp messages within an Blazor environment.

The goal is to provide a very easy quick-start application to send and receive WhatsApp messages via the Twilio API

We use the Twilio MessageResource API to send WhatsApp Messages. For receicing WhatsApp we use the sugessted Twilio WebHook approach

Find the complete article here: https://alexbierhaus.medium.com/twilio-api-whatsapp-net-blazor-example-f7d226da5367

chrome_2021-02-22_13-04-52

The sample should also work with Twilio SMS, however, we did not test it yet.

Getting started sending WhatsApp messages

  1. Follow the instructions on https://www.twilio.com/console/sms/whatsapp/sandbox to enable your sandbox
  2. Find your Account Sid and Token at twilio.com/console and set it in the appsettings.json
  3. Run the sample
  4. Open the send page and send yourself a WhatsApp

Configure receiving WhatsApp messages

For receicing replies we need to configure the Twilio webhook. Note: It is necessary that your application is public available via the internet

  1. Deploy application to your webhoster
  2. Open https://www.twilio.com/console/sms/whatsapp/sandbox
  3. Set "WHEN A MESSAGE COMES IN" parameter with https://YOURDOMAINAPP.net/WhatsAppReceiver

msedge_2021-02-22_13-13-01

4. Reply to the received WhatsApp 5. Open the Receive page. You should see the reply

Remarks

The demo makes use of https://www.litedb.org/ to simple store the received WhatsApp. When you are using the code in your environmennt you might replace it with your database provider.

About

.NET 5 / Blazor app to demonstrate how to send/ receive WhatsApp messages via the Twilio API

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published