💬 Shared WhatsApp Inbox on the new PlatformMore
1msg official logo

Reply to stock availability questions (WhatsApp API)

This scenario sends a free-text WhatsApp message with sendMessage inside the 24-hour customer service window after the client asks if an item is available.

Use case overview

This scenario sends a free-text WhatsApp message with sendMessage inside the 24-hour customer service window after the client asks if an item is available.

Template example

Hello, {{1}}! «{{2}}» is currently {{3}}. Reply here if you want to reserve, get a restock alert, or see similar options.

  • {{1}}
    client name
  • {{2}}
    product or service name
  • {{3}}
    availability status or expected date
WhatsApp Business API for session reply — availability inquiry

When to use it

Reach for this when a prospect asks whether a product or service is in stock or bookable inside an open WhatsApp chat and the answer must land before they leave for a competitor. It fits sales teams pulling live inventory from OMS or CRM, developers wiring webhook-driven session replies, and agencies handling availability for client catalogs.

Fewer lost sales from slow replies
When an inbound availability question arrives via webhook, your backend resolves the SKU and sendMessage returns the product name and current status as three body variables inside the open 24-hour session, so the client gets an answer in the same thread instead of waiting on a rep.
Live stock instead of stale copy
Unlike a cold-start template, sendMessage carries inventory or slot status pulled from OMS or CRM at send time, so the availability line reflects what is on hand or when restock is expected.
Same-thread next steps without a button
The message invites the client to reply in chat to reserve, get a restock alert, or see similar options, so checkout or booking can continue without leaving WhatsApp.
Consistent availability wording
Every reply uses the same three-variable structure — client name, product or service, availability status or expected date — so reps do not retype ad hoc answers that contradict each other.

Workflow

  1. Status tracked

    An inbound client message with an availability question arrives via webhook.

    status: "read"

  2. Resolves the SKU

    Your backend resolves the SKU and current stock or slot status.

    status: "read"

  3. Build & send

    A session text message sends the product name and availability summary.

    POST /sendMessage

  4. Delivered

    The client continues the dialog to reserve or choose alternatives.

    delivered

WhatsApp Business API for session reply — availability inquiry

Technical implementation

Prerequisites

  1. 1MSG API Key · How to get API Key
  2. WhatsApp Business account · How to Connect WABA
  3. Open 24-hour session window · How the 24-hour window works
  4. Customer opt-in · How to Manage Customers Consent
  5. Webhook endpoint · How to Set Up Webhooks

Code examples

#!/usr/bin/env bash
set -euo pipefail

# === Configuration (replace "___" placeholders) ===
API_BASE_URL="https://api.1msg.io"        # production 1MSG API base URL
CHANNEL_ID="___"                           # channel ID from 1MSG dashboard
API_TOKEN="___"                            # channel JWT token (Bearer)



# === Test data ===
TEST_PHONE="___"                 # client phone in international format · requires open 24-hour session window
TEST_CUSTOMERNAME="___"         # {{1}} customer name
TEST_PRODUCTORSERVICENAME="___"         # {{2}} product or service name
TEST_STATUS="___"         # {{3}} status label

PHONE_NORM="$(printf '%s' "$TEST_PHONE" | tr -cd '0-9')"

for pair in "CHANNEL_ID=$CHANNEL_ID" "API_TOKEN=$API_TOKEN" "TEST_PHONE=$TEST_PHONE" \
            "TEST_CUSTOMERNAME=$TEST_CUSTOMERNAME" \
            "TEST_PRODUCTORSERVICENAME=$TEST_PRODUCTORSERVICENAME" \
            "TEST_STATUS=$TEST_STATUS"; do
  val="${pair#*=}"
  if [ -z "$val" ] || [ "$val" = "___" ]; then
    echo "Missing configuration value: ${pair%%=*}" >&2
    exit 1
  fi
done

if [ -z "$PHONE_NORM" ]; then
  echo "Error: phone number has no digits after normalization" >&2
  exit 1
fi

URL="${API_BASE_URL%/}/${CHANNEL_ID}/sendMessage"

read -r -d '' PAYLOAD <<JSON || true
{
  "phone": "${PHONE_NORM}",
  "body": "Hello, Alexey! «Premium Plan license» is currently in stock — ready to ship today. Reply here if you want to reserve, get a restock alert, or see similar options."
}
JSON

RESPONSE="$(curl -s -w '\n%{http_code}' -X POST "$URL" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer ${API_TOKEN}" \
  -d "$PAYLOAD")"

HTTP_CODE="$(printf '%s' "$RESPONSE" | tail -n1)"
BODY="$(printf '%s' "$RESPONSE" | sed '$d')"

case "$BODY" in
  *'"sent":true'*) ok=1 ;;
  *) ok=0 ;;
esac

if [ "$HTTP_CODE" -ge 200 ] && [ "$HTTP_CODE" -lt 300 ] && [ "$ok" -eq 1 ]; then
  echo "Message sent to client."
  echo "API response: $BODY"
else
  echo "Send failed. HTTP status: $HTTP_CODE" >&2
  echo "$BODY" >&2
  exit 1
fi

Response and delivery status

HTTP 2xx and JSON "sent": true mean 1MSG accepted the message for sending — not that it already reached the customer's phone. Save the id field (looks like wamid.…) to correlate delivery callbacks.

200 OKResponse
{
  "sent": true,
  "message": "Sent to [email protected]",
  "description": "Message has been sent to the provider",
  "id": "wamid.HBgLMzgwNjM5..."
}
  • sent

    Accepted for sending — not yet on the customer's phone

  • id

    Store it; delivery callbacks and hookInfo are keyed on this

Delivery statuses and webhooks →

Common errors

StatusAPI responseCauseFix
200Message was not sent: provide chatId, phone, bsuid, or usernameNo recipient the channel could resolve.Pass exactly one recipient: phone (country code plus number, digits only), chatId (for example [email protected]) or bsuid.
200Message was not sent: empty bodyThe body field is missing or empty.Send a non-empty body string. It is required for text, reply-button and list messages.
401token is requiredThe request has no token.Add your channel token as the token query parameter: https://api.1msg.io/{channelId}/{method}?token=…

All error codes →

Common questions

Related

Lead Engagement & Conversion
Reply to price inquiries via WhatsApp API
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.
Lead Engagement & Conversion
Auto-reply to inbound leads via WhatsApp API
This scenario sends a free-text WhatsApp message with sendMessage inside the 24-hour customer service window after the client wrote first about a product or service.
Lead Engagement & Conversion
Purchase decision nudge with WhatsApp buttons
This scenario sends a prospective customer a personalised WhatsApp template while they are still deciding.
Lead Engagement & Conversion
Proposal follow-up reminder via WhatsApp API
The scenario sends the prospect a personalised WhatsApp template message reminding them to review the commercial proposal.
Lead Engagement & Conversion
WhatsApp API list message: product catalog picker
This scenario sends an interactive list with sendList during the 24-hour session window.
Lead Engagement & Conversion
Consultation invite via WhatsApp API template
The scenario sends the customer a personalized WhatsApp template message inviting them to a pre-purchase consultation.
Lead Engagement & Conversion
New lead alert to sales manager via WhatsApp API
The scenario sends the sales manager a personalised WhatsApp template when a new lead is captured.
Lead Engagement & Conversion
Start lead qualification via WhatsApp API
This use case sends a new lead an approved WhatsApp template with a personalized greeting: the message substitutes the lead's name and product or source context, and the «Начать» (Start) quick-reply b

Build for WhatsApp in hours
without infrastructure hassle