💬 Командный WhatsApp-Инбокс на новой ПлатформеЕщё
1msg official logo

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.

Use case overview

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.

Template example

Hello, {{1}}! We received your request about «{{2}}». {{3}} is reviewing it and will reply shortly.

  • {{1}}
    client name
  • {{2}}
    request topic or product area
  • {{3}}
    assigned sales manager name
WhatsApp Business API for session reply — incoming client request

When to use it

Use this scenario when a prospect writes first on WhatsApp asking about a product or service and you need to acknowledge the request before a sales manager replies with details. It fits sales inbound flows where the client already opened the 24-hour session window and leaving them without a reply risks losing the lead.

Fewer leads left waiting
An inbound webhook triggers sendMessage as soon as the client message arrives, so the prospect gets acknowledgment in the same session before a manager opens the thread.
No template cold-start friction
sendMessage works inside the open 24-hour customer service window, so you skip template approval and the extra cost of reopening a dialog the client already started.
Request topic stays in the chat
Three body variables carry the client name, the request topic your backend extracted from CRM, and the assigned manager, so the acknowledgment is searchable in WhatsApp instead of a generic receipt.
Clear handoff to sales
The message names the assigned manager and sets expectation for a detailed reply in the same session, so the client knows who is handling the request while the manager prepares the answer.

Workflow

  1. Status tracked

    An inbound client message arrives via webhook.

    status: "read"

  2. Capture event

    Your backend maps the chat to a lead and extracts the request topic.

    POST /sendMessage

  3. Build & send

    A session text message acknowledges the request and names the manager.

    POST /sendMessage

  4. Delivered

    The manager continues the dialog with a detailed answer in the same session.

    delivered

WhatsApp Business API for session reply — incoming client request

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_TOPIC="___"         # {{2}} topic or subject
TEST_MANAGERNAME="___"         # {{3}} manager name

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_TOPIC=$TEST_TOPIC" \
            "TEST_MANAGERNAME=$TEST_MANAGERNAME"; 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! We received your request about «CRM for a sales team». Manager Anna is reviewing it and will reply shortly."
}
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

Связанные

Вовлечение и конверсия лидов
WhatsApp Business API для напоминания о сопровождении предложений
Сценарий отправляет потенциальному клиенту шаблонное персонализированное сообщение WhatsApp с напоминанием ознакомиться с коммерческим предложением.
Вовлечение и конверсия лидов
WhatsApp Business API для каталога товаров — интерактивный список
Этот сценарий отправляет интерактивный список с помощью sendList в течение 24-часового окна сеанса.
Вовлечение и конверсия лидов
WhatsApp Business API для консультаций перед покупкой
Сценарий отправляет клиенту персонализированный шаблон сообщения WhatsApp с приглашением на консультацию перед покупкой.
Вовлечение и конверсия лидов
WhatsApp Business API для уведомления нового менеджера по лидам
Сценарий отправляет менеджеру по продажам персонализированный шаблон WhatsApp, когда поступает новый лид.
Вовлечение и конверсия лидов
WhatsApp Business API для квалификации лидов с ключевыми вопросами
Этот кейс отправляет новому лиду одобренный шаблон WhatsApp с персонализированным приветствием: подставляются имя лида и продукт, а также быстрый ответ «Начать»
Вовлечение и конверсия лидов
WhatsApp Business API для повторного обращения к лиду без ответа
Сценарий отправляет лиду персонализированный шаблон WhatsApp, если он не ответил на предыдущее продажное сообщение в ожидаемое время.
Вовлечение и конверсия лидов
WhatsApp Business API для передачи лида в отдел продаж
Сценарий отправляет клиенту персонализированный шаблон WhatsApp, когда квалифицированный лид передаётся в отдел продаж.
Вовлечение и конверсия лидов
WhatsApp Business API для первого контакта с новым лидом
Сценарий отправляет лиду персонализированный шаблон WhatsApp как первое касание в продажах.

Интегрируйте WhatsApp за часы
без проблем с инфраструктурой