WhatsApp Integration by using Azure Functions and Business Central API.


  • A sales man send a request with a Whatsapp message, eg: “What is XYZ order status?“.
  • The request is processed by an Azure function that queries Business Central API and gets the response.
  • The answer from Business Central is dispatched by the Azure function to the sales man via whatsapp chat, eg:


The recipe to integrate Whatsapp and Business Central is pretty easy and consists in two ingredients:

  • Configure a Twilio account to work with Whatsapp.
  • Create a simple Azure function.
  • In this sample I am not using Azure Vault to store passwords and I just use settings.json, you should when in production environment πŸ™‚


Configuring Twilio is the hardest part. I don’t give here detailed instructions about registration. After you get your account confirmed and sandbox enabled just double check your Azure Function endpoint in correctly configured in “When a message comes in”. https://www.twilio.com/console/sms/whatsapp/sandbox .


A simple Azure Function works as “middle layer” between Twilio API and Business Central API.

Here are sources in GitHub: https://github.com/avalonit/AzBcTwilioConnector

The azure function consists basically in five .cs files.

TwilioTrigger.cs contains the azure function invoked by Twilio every time it gets an incoming whatsapp message. The function parses the incoming whatsapp message, query Business Central API for the requested order number and returns the message to be replied to the sales agent.

The function should be in charge to manage security related stuffs too. In my example, of course, no security is managed at all πŸ™‚

BusinessCentralConnector.cs contains class that manages calls to API. It connects to API and get the requested order by applying filtering to API request.

MessageComposer.cs is the class that create the response string used to reply to the request.

SalesOrders.cs is the class that represents Business Central SalesOrders table for deserialising API data. I find quiet useful https://app.quicktype.io/ to automatically convert Json returned from BC API to C# class. Just pay attention to DateTimeOffset field type that are not supported by JSON.

To have your solution working just download sources, configure your Business Central endpoint and deploy it to your azure subscription.


When I write a whatsapp message with the specified template “What is XXX order status” I get the reply from BC.


In the future I plan to add some kind of artificial intelligence by using Azure Cognitive API to process requests.

And absolutely I am going to add a little bit of security by allowing the sales agent to have information just about his own orders.


10th of April 2020

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s