Typing Indicator - nxtele/nxcloud-doc-en GitHub Wiki

Typing Indicator API

Trigger WhatsApp “typing indicator” via API.

When you get a messages webhook indicating a received message, you can use the message.id value to mark the message as read and display a typing indicator so the WhatsApp user knows you are preparing a response. This is good practice if it will take you a few seconds to respond.

The typing indicator will be dismissed once you respond, or after 25 seconds, whichever comes first. To prevent a poor user experience, only display a typing indicator if you are going to respond.

  • URL: https://api2.nxcloud.com/api/wa/typingIndicator
  • Method: POST
  • Content-Type: application/json
  • Authentication required: Yes

Authentication

For authentication rules, refer to: API Call Convention

Request Parameters

Header Parameters

Parameter Type Required Example Description
accessKey String Yes fme2na3kdi3ki User identity key
ts String Yes 1655710885431 Request timestamp in milliseconds. Max allowed client/server time drift is 60 seconds
bizType String Yes 2 WhatsApp business type. Fixed value: 2
action String Yes read WhatsApp business action. Fixed value: read
sign String Yes 6e9506557d1f289501d333ee2c365826 API request signature. See authentication docs

Body Parameters

Parameter Type Required Example Description
appkey String Yes xxx Application appkey
messaging_product String Yes whatsapp Messaging channel. Fixed value: whatsapp
business_phone String Yes xxx Business phone number (must include country code)
status String Yes read Fixed value: read
message_id String Yes wamid.HBgNODYxMzMyMDIzNzQ0NhUCABEYEjkzRjVGODY0OTJCQzM5QzQ1MgA= Incoming message ID
typing_indicator Object Yes {"type":"text"} Typing indicator object
typing_indicator.type String Yes text Fixed value: text

Request Example

{
  "appkey": "xxx",
  "messaging_product": "whatsapp",
  "business_phone": "xxx",
  "status": "read",
  "message_id": "wamid.HBgNODYxMzMyMDIzNzQ0NhUCABEYEjkzRjVGODY0OTJCQzM5QzQ1MgA=",
  "typing_indicator": {
    "type": "text"
  }
}

Response Parameters

Parameter Type Description
code Integer Result code
data JsonObject Response payload (may include downstream error object)
message String Result message

Response Examples

Success Example

{
  "code": 0,
  "data": {
    "success": true
  },
  "message": "success"
}

Error Case 1: Invalid message_id

{
  "code": 0,
  "data": {
    "error": {
      "code": 100.0,
      "message": "(#100) Invalid parameter",
      "type": "OAuthException",
      "fbtrace_id": "APoPA639oqWRwvF3dFSQsUz",
      "error_data": {
        "messaging_product": "whatsapp",
        "details": "Please check the message ID you have provided."
      }
    }
  },
  "message": "success"
}

Error Case 2: message_id is an outgoing message (not incoming)

{
  "code": 0,
  "data": {
    "error": {
      "code": 100.0,
      "message": "(#100) Invalid parameter",
      "type": "OAuthException",
      "fbtrace_id": "A9PTrNfMQxS6EZ8uUlxAAey",
      "error_data": {
        "messaging_product": "whatsapp",
        "details": "Message supplied to mark message as read API with message ID: wamid.HBgNODYxMzMyMDIzNzQ0NhUCABEYEjkzRjVGODY0OTJCQzM5QzQ1MgA= is outgoing. Please use an incoming message ID."
      }
    }
  },
  "message": "success"
}

Failure Example: Invalid Parameters

{
  "code": 9000,
  "data": null,
  "message": "Invalid parameter (typing_indicator.type must be 'text')"
}

Failure Example: System Failure

{
  "code": -1,
  "message": "failure",
  "data": null
}

Response Code Reference

Code Message Resolution
0 success Request accepted. If data.error is not null, handle it as a downstream error
-1 failure System exception. Contact technical support
1000~100X Authentication issue See authentication docs
9000 Parameter error Check required fields and fixed-value constraints
9001 System business error Contact technical support
9002 Invalid business phone number Confirm the phone number is a valid WhatsApp business number
10003 This WhatsApp number is not bound to the app Contact business support to bind app and phone number

Integration Notes

  1. status must be read.
  2. typing_indicator is required, and typing_indicator.type must be text.
  3. message_id must be an incoming message ID. Outgoing IDs will trigger downstream Invalid parameter.
  4. Recommended success criteria:
    • code == 0
    • and data.error does not exist.