WhatsApp Business API for session reply — price inquiry
This scenario sends a free-text WhatsApp message with sendMessage inside the 24-hour customer service window after the client asks how much a product or service costs.
Use case overview
This scenario sends a free-text WhatsApp message with sendMessage inside the 24-hour customer service window after the client asks how much a product or service costs.
Template example
Hello, {{1}}! The price for «{{2}}» is {{3}}. If you need a custom quote or volume discount, reply here and our manager will help.
sendMessage works only when the 24-hour session window is open.
Variables and purpose
{{1}}— client name{{2}}— product or service name{{3}}— formatted price with currency
Filled-in example
Hello, Alexey! The price for «Premium Plan (annual)» is 49 900 RUB. If you need a custom quote or volume discount, reply here and our manager will help.
When to use it
- sales pricing
Business value
- Client price question arrives via webhook inside the 24-hour session window
- CRM or pricing service resolves the SKU and current list price
- Session text message delivers the quote with product and amount placeholders
- Client can ask follow-up questions or proceed to purchase in the same thread
- Lead stage updates in CRM from the automated price response timestamp
Workflow
- An inbound client message with a price question arrives via webhook.
- Your backend resolves the product SKU and current list price.
- A session text message sends the quote with product name and formatted amount.
- The client continues the dialog for discounts or checkout in the same session.
- Delivery progress is reported asynchronously — typically
sent, thendelivered(or failed/undelivered). - Your system receives status via webhook (
hooks[]) or polls delivery status and handles failures if needed.
Technical implementation
Prerequisites
- An open WhatsApp session window (client wrote first or replied within 24 hours).
- 1MSG channel with sendMessage access and a pricing source mapped in your backend.
Code examples
Node.js
#!/usr/bin/env node
// === Configuration (replace "___" placeholders) ===
const API_BASE_URL = "https://api.1msg.io"; // production 1MSG API base URL
const CHANNEL_ID = "___"; // channel ID from 1MSG dashboard
const API_TOKEN = "___"; // channel JWT token (Bearer)
// === Test data ===
const TEST_PHONE = "___"; // client phone in international format · requires open 24-hour session window
const TEST_CUSTOMERNAME = "___"; // {{1}} customer name
const TEST_PRODUCTORSERVICENAME = "___"; // {{2}} product or service name
const TEST_PAYMENTAMOUNT = "___"; // {{3}} payment amount
function normalizePhone(phone) {
return String(phone).replace(/\D/g, "");
}
function assertConfigured(values) {
for (const [key, value] of Object.entries(values)) {
if (value === "___" || value === "" || value === undefined || value === null) {
throw new Error(`Missing configuration value: ${key}`);
}
}
}
async function sendSessionTextMessage({ phone, customerName, productOrServiceName, paymentAmount }) {
assertConfigured({
CHANNEL_ID,
API_TOKEN,
phone,
customerName,
productOrServiceName,
paymentAmount,
});
const url = `${API_BASE_URL}/${CHANNEL_ID}/sendMessage`;
const requestBody = {
phone: normalizePhone(phone),
body: `Hello, ${customerName}! The price for «${productOrServiceName}» is ${paymentAmount}. If you need a custom quote or volume discount, reply here and our manager will help.`,
};
const res = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${API_TOKEN}`,
},
body: JSON.stringify(requestBody),
});
const raw = await res.text();
let data;
try {
data = JSON.parse(raw);
} catch {
data = null;
}
if (!res.ok || !data || data.sent !== true) {
console.error("Send failed. API response:");
console.error(raw);
process.exit(1);
}
console.log("Message sent to client.");
console.log("API response:", raw);
return data;
}
if (require.main === module) {
sendSessionTextMessage({
phone: TEST_PHONE,
customerName: TEST_CUSTOMERNAME,
productOrServiceName: TEST_PRODUCTORSERVICENAME,
paymentAmount: TEST_PAYMENTAMOUNT,
}).catch((err) => {
console.error("Execution failed:", err.message);
process.exit(1);
});
}
module.exports = { sendSessionTextMessage };
Immediate API response (synchronous)
- HTTP 2xx and JSON
"sent": truemean 1MSG accepted the message for sending — not that it already reached the customer's phone. - Save the `id` field from the response (value looks like
wamid.…). Use it to correlate delivery callbacks or polling. - The response may also include
messageanddescription— informational only.
Delivery status (asynchronous)
- Register a webhook (
POST …/webhook) so 1MSG POSTs delivery updates to your HTTPS endpoint in a separate `hooks[]` payload (sent,delivered,read, or failed/undelivered when applicable). - Optionally poll:
GET {base}/{channel}/hookInfo?messageId=<id from sendTemplate>. - In practice, delivery often completes within a few seconds — but that is not guaranteed by the API contract.
Common errors
- Session window closed (no client message within 24 hours)
- Invalid or non-normalized phone number
- Missing or invalid message body / media URL
- Delivery failure — check status webhook and retry policy
FAQ
- Do I need a template? No — this scenario uses a session message inside the 24-hour customer service window.
- When does the session window close? If the client has not written or replied within 24 hours, sendMessage will fail until a template reopens the chat.
- How do I check delivery?
sent: trueonly confirms acceptance. Track delivery via webhookhooks[]or polling. - What if the message is not delivered? Log the failed/undelivered hook, verify the session window, then retry or use a template.
- Can I connect this to my CRM or backend? Yes — trigger the API call from your inbound webhook or workflow engine.
CTA
Ready to use session reply — price inquiry? Connect your 1MSG channel and run the code examples above.
Related
Build WhatsApp automation in minutes
Use 1MSG to automate this workflow and try it with our free demo.
