WhatsApp messaging with Business Central

WhatsApp is the one of the most used messaging systems so I thought it would be a good idea to have the chance to send messages from BC.



So, I have the idea, now, how we can do it? And why?

How to do it?
First of all, I made a little research about how to send WhatsApp messages. 

I found 2 possible ways. Using the public URL (the selected one) or using WhatsApp Business API.

So, why I choose the first one. The easy answer it's that it's 100% functional for a demo. In fact, for using WhatsApp Business API I should register as a company, wait for WhatsApp / Facebook response so maybe for another post in the future.

Why?
The night I'd decided to do it I started thinking where to use it. I was in bed and my head was thinking (when I really wanted to sleep...) so many different cases. I'll give you some ideas:

  • Send a message to a customer when shipment is done in the warehouse.
    • Also, can send tracking ID if you'll have it.
  • Reminders
    • All kind of reminders
  • CRM
    • Send messages to contacts / customers with promotions, offers, etc.
  • Employees
    • Any message you can imagine to your employees.
So, now I have the idea and where to use. Let's try it (after sleep).

Development
Next morning (currently on my Summer Holidays) I tried to move my ideas to AL code. My first idea is always try to make it simple and proof that it works. Once there, make it nice.

Of course, problems start appearing...
First problem. WhatsApp URL don't allow to send messages directly. It always opens a web browser and the Desktop app. And user must press send... So, the idea of automatizing everything it's only available if using WhatsApp Business API.

Second problem. Phone No. format. BC allows you to store numbers and symbols on Phone No. field, but WhatsApp requires specific format. WhatsApp phone number must be like + COUNTRY DIAL CODE  PHONE NO. without any symbol (see documentation).

I'll made a research and I found where to get all ISO Country Dial codes. So, I just had to add a new field on Country / Region table to store country dial codes. It will be used to format phone nos.

So now I should be able to start coding and change my initial idea. I decide to move on and create a page where I can select to who I want to send a message (Customer, Vendor, Contact or Employee). 


Once selected, I'll can navigate and find who to send the message. 

When selected, all needed data is loaded so now I only need to write the message and send it!!



So, when Send button is pressed, message appears on WhatsApp Desktop and we're able to send it. No need to be a contact on our phone.



It also works if nothing selected and just type the phone no. and the message.

And that's all. Simple and useful.

As usual, you can take a look at the code on Github or just download the app.

Comments