# customerServiceMessage.setTyping

Call this API at the server side. For more information, see Server API.

This API supports Cloud Calls. The WeChat DevTools version must be 1.02.1904090 or later (download the latest stable version here), and the wx-server-sdk version must be 0.4.0 or later.

Delivers the current input status of customer service to the user. For details, see Input Status of Customer Service Messages.

Calling methods:

# HTTPS Call

# Request Address

POST https://api.weixin.qq.com/cgi-bin/message/custom/typing?access_token=ACCESS_TOKEN

# Request Parameters

Attribute Type Default Required Description
access_token string Yes Credentials to call API
touser string Yes The user's OpenID.
command Strign Yes Command

Valid values of command

Value Description Minimum Version
Typing Delivers the Typing status to the user
CancelTyping Cancels the Typing status displayed to the user

# Return Value

# Object

JSON data package that is returned

Attribute Type Description
errcode number Error code
errmsg string Error message

Valid values of errcode

Value Description Minimum Version
45072 Incorrect value in the command field
45080 To send typing status, there should be message interactions with the user within the last 30 seconds.
45081 Already in the Typing status. The Typing status cannot be delivered repeatedly.

# Request Example

{
  "touser": "OPENID",
  "command": "Typing"
   }

# Cloud Call

Cloud call is a capability provided by Mini Program·Cloud Base that allows you to call WeChat APIs in a cloud function. It must be used via wx-server-sdk in the cloud function.

# API Calling Method

openapi.customerServiceMessage.setTyping

You need to configure the permissions for the customerServiceMessage.setTyping API via config.json. Details

# Request Parameters

Attribute Type Default Required Description
touser string Yes The user's OpenID.
command Strign Yes Command

Valid values of command

Value Description Minimum Version
Typing Delivers the Typing status to the user
CancelTyping Cancels the Typing status displayed to the user

# Return Value

# Object

JSON data package that is returned

Attribute Type Description
errCode number Error code
errMsg string Error message

Valid values of errCode

Value Description Minimum Version
0 Succeeded

# Exceptions

# Object

Thrown Exceptions

Property Type Description
errCode number Error code
errMsg string Error message

Valid values of errCode

Value Description Minimum Version
45072 Incorrect value in the command field
45080 To send typing status, there should be message interactions with the user within the last 30 seconds.
45081 Already in the Typing status. The Typing status cannot be delivered repeatedly.

# Request Example

const cloud = require('wx-server-sdk')
  cloud.init()
  exports.main = async (event, context) => {
    try {
      const result = await cloud.openapi.customerServiceMessage.setTyping({
        touser: 'OPENID',
        command: 'Typing'
      })
      console.log(result)
      return result
    } catch (err) {
      console.log(err)
      return err
    }
  }