Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

WeChat program setTyping


May 19, 2021 WeChat Mini Program Development Document


Table of contents


customerServiceMessage.setTyping

This interface should be called on the server side, as detailed in the Service Side API.
This interface supports cloud calls. Developer tool version required . . . 1.02.1904090 (latest stable download)
wx-server-sdk >= 0.4.0

The current input status of the customer service is sent to the user. See customer service message entry status for details

How to call:

  • HTTPS call
  • Cloud call

HTTPS call

Request address

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

Request parameters

Attributes type Defaults Required illustrate
access_token string Yes Interface call credential
touser string Yes User's OpenID
command Strign Yes Order

Legal value of Command

value illustrate Minimum version
Typing "Input" status is issued to the user
CancelTyping Cancel the "Input" status of the user

return value

Object

Returned JSON packet

Attributes type illustrate
errcode number error code
errmsg string Error message

Errcode's legitimate value

value illustrate Minimum version
45072 Command field is not right
45080 When you send an input state, you need to have a message interact with the user within 30 seconds.
45081 Already in the input state, you can not repeat

Request example

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

Cloud call

The cloud call is the ability to call the WeChat open interface in the cloud function, which needs to be used in the cloud function in the cloud function. Use by WX-Server-SDK.

Interface method

openapi.customerServiceMessage.setTyping
Permissions for the customerServiceMessage.setTyping API need to be configured in config.json, details

Request parameters

Property Type The default Required Description
touser string Is The user's OpenID
command Strign Is Command

The legal value of the command

Value Description The lowest version
Typing The Entering status is issued to the user
CancelTyping Cancel the Entering status for the user

Returns a value

Object

The returned JSON packet

Property Type Description
errCode number Error code
errMsg string The error message

The legal value of errCode

Value Description The lowest version
0 Success

Abnormal

Object

The exception thrown

Property Type Description
errCode number Error code
errMsg string The error message

The legal value of errCode

Value Description The lowest version
45072 The command field has the wrong value
45080 Under the input status, you need to have a message interaction with the user within the first 30 seconds
45081 Already in the input state, it cannot be issued repeatedly

An example of a request

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'
      })
    return result
  } catch (err) {
    return err
  }
}