Query Business Partner records from your SAP B1 installation in a WhatsApp chatbot. When a customer messages you, look up their account by phone number using the SAP B1 Service Layer and reply with their account name, balance, or order history.
Before following this guide, read the External API Request step foundation guide. It covers every field in the step interface so this guide can focus on SAP B1-specific values.
SAP Business One is almost always installed on-premise or in a private cloud. For WA.Expert to call the Service Layer, your SAP B1 server must be reachable from the internet. Confirm this with your IT team before attempting any integration steps. The default Service Layer port is 50000.
| Requirement | Where to find it | Notes |
|---|---|---|
| SAP B1 server URL | Your IT team | The server must be accessible from the internet. e.g. https://erp.yourcompany.com:50000 |
| Company database name | SAP B1 Administration > Company Details > Database Name | The exact database name as configured in SAP B1 (case-sensitive) |
| SAP B1 username and password | Your SAP B1 admin | Use a dedicated service account with read-only access to Business Partners |
| Network access confirmed | IT/network team | Port 50000 must be open to WA.Expert's servers, or a reverse proxy must forward HTTPS requests to it |
Create a dedicated SAP B1 user for the WhatsApp integration with read-only access to Business Partners. Do not use an admin account. If the credentials are ever exposed, a limited account reduces risk. Set the account's permissions to read Business Partners only.
SAP B1 Service Layer uses session-based authentication, unlike every other CRM in this series which uses Bearer tokens or API keys. You POST credentials to a Login endpoint and receive a B1SESSION cookie that authenticates all subsequent requests.
In your WA.Expert chatbot flow, add a first External API Request step to log in:
{
"SessionId": "PTRzIjYK-weN6-1Lx1-ZG0J-3ARxfjcU0Shy",
"Version": "10.0.2310.0",
"SessionTimeout": 30
}
The B1SESSION cookie is set in the response headers:
Set-Cookie: B1SESSION=PTRzIjYK-weN6-1Lx1-ZG0J-3ARxfjcU0Shy; Path=/b1s
Map the SessionId value as {{b1_session}} for use in Step 2.
Sessions time out after 30 minutes of inactivity by default.Unlike every other ERP and CRM in this series, SAP B1 authenticates via a session cookie. The B1SESSION cookie value must be sent with every subsequent request in a Cookie header: Cookie: B1SESSION=YOUR_SESSION_ID. This two-step pattern (login then query) is unique to SAP B1.
With the B1SESSION stored as {{b1_session}} and the customer's phone as {{customer_phone}}, add a second External API Request step:
| What you want | OData $filter value |
|---|---|
| Customer by primary phone | Phone1 eq '9820000001' and CardType eq 'cCustomer' |
| Customer by mobile | Cellular eq '9820000001' and CardType eq 'cCustomer' |
| Phone or mobile | (Phone1 eq '9820000001' or Cellular eq '9820000001') and CardType eq 'cCustomer' |
| Customer by card code | CardCode eq 'C001' and CardType eq 'cCustomer' |
| Customer by name | startswith(CardName,'Sharma') and CardType eq 'cCustomer' |
CardType values: cCustomer (customers), cSupplier (suppliers), cLead (leads). Always include CardType eq 'cCustomer' to avoid returning suppliers in the results.
A successful SAP B1 Business Partner response looks like this:
{
"@odata.context": "...",
"value": [
{
"CardCode": "C001",
"CardName": "Sharma Textiles Pvt Ltd",
"Phone1": "9820000001",
"Cellular": "+919820000001",
"EmailAddress": "priya@sharma.com",
"Balance": 125000.0
}
]
}
Map:
value[0].CardCode → account code
value[0].CardName → company name
value[0].Balance → outstanding balanceSAP B1 OData responses use a value array, same as Microsoft Dynamics 365. Map as value[0].CardName, value[0].Balance. If the value array is empty, no Business Partner was found with that phone number.
Map these response paths to variables in the External API Request step:
| Variable name | Response path | Example value |
|---|---|---|
| card_code | value[0].CardCode | C001 |
| company_name | value[0].CardName | Sharma Textiles Pvt Ltd |
| phone1 | value[0].Phone1 | 9820000001 |
| value[0].EmailAddress | priya@sharma.com | |
| balance | value[0].Balance | 125000.0 |
Balance is the current outstanding balance in the company's base currency. A positive value means the customer owes money; negative means a credit. Use it carefully in WhatsApp replies: some customers may find balance mentions intrusive.
If the customer messaged you first within the last 24 hours, your reply is a free service conversation. For proactive outbound messages from SAP B1 data, use an approved Utility or Marketing template.
Customer messages your WhatsApp number.
WA.Expert captures their phone as {{customer_phone}} = "9820000001".
Step 1 — Login:
POST https://erp.yourcompany.com:50000/b1s/v2/Login
Body: {{"CompanyDB":"SBODEMOIN","UserName":"waexpert","Password":"service_pass"}}
Response: {{"SessionId":"PTRzIjYK-weN6-1Lx1-ZG0J-3ARxfjcU0Shy",...}}
Store: b1_session = "PTRzIjYK-weN6-1Lx1-ZG0J-3ARxfjcU0Shy"
Step 2 — Query:
GET https://erp.yourcompany.com:50000/b1s/v2/BusinessPartners
?$select=CardCode,CardName,Balance
&$filter=Phone1 eq '9820000001' and CardType eq 'cCustomer'
&$top=1
Cookie: B1SESSION={{b1_session}}
Response mapped:
card_code = "C001"
company_name = "Sharma Textiles Pvt Ltd"
balance = "125000.0"
Bot replies (if found):
"Hello, Sharma Textiles.
Your account code: C001
For invoice queries or payments, please reply
INVOICE or SUPPORT and our team will assist you."| Symptom | Likely cause | Fix |
|---|---|---|
| Connection refused / timeout | SAP B1 server not reachable from internet | Confirm with IT that port 50000 is open externally or a reverse proxy forwards requests. Test by accessing the URL from a browser outside the office network. |
| SSL certificate error | SAP B1 uses a self-signed certificate by default | Install a valid SSL certificate on the Service Layer, or configure WA.Expert to accept self-signed certs. Most production deployments should use a valid certificate. |
| 401 on Login | Wrong CompanyDB, UserName, or Password | Case-sensitive check: CompanyDB is the exact database name as configured. Try logging in via the SAP B1 client to verify credentials. |
| 401 on Business Partner query | B1SESSION cookie expired (30-minute timeout) | Add a fresh login step before each lookup. Sessions expire after 30 minutes of inactivity. |
| Empty value array | Phone number format mismatch or no match | Check if SAP B1 stores numbers with country code, spaces, or dashes. Try Cellular field as well as Phone1. |
| Permission denied on query | Service account lacks Business Partner read permission | In SAP B1 Administration > Users, ensure the integration user has View permission for Business Partners. |
NetSuite: two integration paths, SuiteQL queries, RESTlet middleware.
Read guide →Microsoft Dynamics 365: Azure AD OAuth, OData filters.
Read guide →Odoo ERP: Bearer API key, res.partner model, domain filters.
Read guide →Free trial, no credit card required. And if you ever get stuck, we are the only platform in India that answers you live on WhatsApp.