May 19, 2021 WeChat Mini Program Development Document
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:
POST https://api.weixin.qq.com/cgi-bin/message/custom/typing?access_token=ACCESS_TOKEN
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 |
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 |
{
"touser": "OPENID",
"command": "Typing"
}
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.
openapi.customerServiceMessage.setTyping
Permissions for the customerServiceMessage.setTyping API need to be configured in config.json, details
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 |
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 |
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 |
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
}
}