Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
erickgomez-tech
Participant
492

⚙️ How did we do it?
1. Webhook to receive messages
We created a Node.js app with Express to receive the WhatsApp Business API POST. We validated the incoming message and processed it if it was text.

2. Finding the customer in SAP B1
We use a $crossjoin query in the Service Layer to find the contact's CardCode, filtering by their phone number:

$filter=contains(BusinessPartners/ContactEmployees/MobilePhone, '${fromNumber}')
3. Saving the message in SAP B1
Once we have the CardCode, we send a POST to the endpoint of our custom table U_WHATSAPP_MESSAGES, including the text, the customer number, and the time:

{
"U_CardCode": "C1234",
"Name": "Webhook",
"U_Message": "Hello, I need help with my invoice",
"U_From": "5219981234567",
"U_Status": "Pending",
"U_MessageID": "wamid.HBgLM...",
"U_Timestamp": "03/27/2025 10:45 AM"
}
4. Security and Credential Management
All connections to the Service Layer are made through a Destination configured in SAP BTP, and we access it dynamically by reading the credentials from VCAP_SERVICES.
This allows us to scale and keep the code clean and reusable.

🔐 The best part: no hardcoded credentials
Access to the Service Layer is orchestrated by the SAP BTP Destination Service, using OAuth2 Client Credentials. This guarantees security and flexibility in production environments.

📈 Result
With this integration, now every time a customer writes to us via WhatsApp:

The message arrives at our webhook.

We identify the customer by their number.

We log the message in SAP Business One.

The support team can access it directly from SAP.

🧠 Lessons Learned
Using $crossjoin allowed us to combine contact and business partner information in a single query.

Working with VCAP_SERVICES is key to maintaining secure and portable configurations in SAP BTP.

Connecting messaging channels to SAP is no longer a futuristic dream. It's a reality within everyone's reach!

What now?
Next step: generating automatic responses or routing these messages to service flows in SAP Build Process Automation... but that's a story for another post. 😉

Are you up for implementing something similar? Do you have ideas to take it even further?
Leave me your comments or write to me and we'll talk about it.

AI-powered writing

1 Comment
Labels in this area