How to send messages in WeChat Enterprise Account Development

How to send messages in WeChat Enterprise Account Development

Companies can proactively send messages to employees, with no limit on the amount of messages .

When calling the interface, use the Https protocol and JSON data packet format, and the data packet does not need to be encrypted.

Currently, it supports text, picture, voice, video, file, graphic and other message types. Except for news type, other types of messages can be added with confidentiality options when sending. Confidential messages will be watermarked and only the recipient can read them.

1. Sending interface description

  • Request Instructions

Https request method: POST

https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=ACCESS_TOKEN

  • Parameter Description
parameter must illustrate
access_token yes Call interface credentials
  • Permission requirements

The administrator needs to have permission to use the application and to view the recipients touser, toparty, and totag. Otherwise, the call will fail.

  • Return results

If you do not have permission for any of the application, recipient, department, or tag, the send will fail; if the recipient, department, or tag does not exist, the send will still be executed, but the invalid part will be returned.

  1. {
  2. "errcode" : 0 ,
  3. "errmsg" : "ok" ,
  4. "invaliduser" : "UserID1" ,
  5. "invalidparty" : "PartyID1" ,
  6. "invalidtag" : "TagID1"  
  7. }

2. Message Type and Data Format

  • text message
  1. {
  2. "touser" : "UserID1|UserID2|UserID3" ,
  3. "toparty" : " PartyID1 | PartyID2 " ,
  4. "totag" : " TagID1 | TagID2 " ,
  5. "msgtype" : "text" ,
  6. "agentid" : "1" ,
  7. "text" : {
  8. "content" : "Holiday Request For Pony(http://xxxxx)"  
  9. },
  10. "safe" : "0"  
  11. }
parameter must illustrate
touser no UserID list (message recipients, multiple recipients are separated by '|'). Special case: specify @all to send to all members who follow the enterprise application
toparty no PartyID list, multiple recipients are separated by '|'. This parameter is ignored when touser is @all
totag no TagID list, multiple recipients are separated by '|'. This parameter is ignored when touser is @all
msgtype yes Message type, fixed at this time: text
agentid yes The id of the enterprise application, integer. You can view it on the application settings page.
content yes Message content
safe no Indicates whether it is a confidential message, 0 means no, 1 means yes, the default is 0
  • image message
  1. {
  2. "touser" : "UserID1|UserID2|UserID3" ,
  3. "toparty" : " PartyID1 | PartyID2 " ,
  4. "msgtype" : "image" ,
  5. "agentid" : "1" ,
  6. "image" : {
  7. "media_id" : "MEDIA_ID"  
  8. },
  9. "safe" : "0"  
  10. }
parameter must illustrate
touser no UserID list (message recipients, multiple recipients are separated by '|'). Special case: specify @all to send to all members who follow the enterprise application
toparty no PartyID list, multiple recipients are separated by '|'. This parameter is ignored when touser is @all
totag no TagID list, multiple recipients are separated by '|'. This parameter is ignored when touser is @all
msgtype yes Message type, fixed at this time: image
agentid yes The id of the enterprise application, integer. You can view it on the application settings page.
media_id yes Media resource file ID
safe no Indicates whether it is a confidential message, 0 means no, 1 means yes, the default is 0
  • Voice message
  1. {
  2. "touser" : "UserID1|UserID2|UserID3" ,
  3. "toparty" : " PartyID1 | PartyID2 " ,
  4. "totag" : " TagID1 | TagID2 " ,
  5. "msgtype" : "voice" ,
  6. "agentid" : "1" ,
  7. "voice" : {
  8. "media_id" : "MEDIA_ID"  
  9. },
  10. "safe" : "0"  
  11. }
parameter must illustrate
touser no UserID list (message recipients, multiple recipients are separated by '|'). Special case: specify @all to send to all members who follow the enterprise application
toparty no PartyID list, multiple recipients are separated by '|'. This parameter is ignored when touser is @all
totag no TagID list, multiple recipients are separated by '|'. This parameter is ignored when touser is @all
msgtype yes Message type, fixed at this time: voice
agentid yes The id of the enterprise application, integer. You can view it on the application settings page.
media_id yes Media resource file ID
safe no Indicates whether it is a confidential message, 0 means no, 1 means yes, the default is 0
  • Video message
  1. {
  2. "touser" : "UserID1|UserID2|UserID3" ,
  3. "toparty" : " PartyID1 | PartyID2 " ,
  4. "totag" : " TagID1 | TagID2 " ,
  5. "msgtype" : "video" ,
  6. "agentid" : "1" ,
  7. " video " : {
  8. "media_id" : "MEDIA_ID" ,
  9. "title" : "Title" ,
  10. "description" : "Description"  
  11. },
  12. "safe" : "0"  
  13. }
parameter must illustrate
touser no UserID list (message recipients, multiple recipients are separated by '|'). Special case: specify @all to send to all members who follow the enterprise application
toparty no PartyID list, multiple recipients are separated by '|'. This parameter is ignored when touser is @all
totag no TagID list, multiple recipients are separated by '|'. This parameter is ignored when touser is @all
msgtype yes Message type, fixed at this time: video
agentid yes The id of the enterprise application, integer. You can view it on the application settings page.
media_id yes Media resource file ID
title no Title of the video message
description no Description of video message
safe no Indicates whether it is a confidential message, 0 means no, 1 means yes, the default is 0
  • file message
  1. {
  2. "touser" : "UserID1|UserID2|UserID3" ,
  3. "toparty" : " PartyID1 | PartyID2 " ,
  4. "totag" : " TagID1 | TagID2 " ,
  5. "msgtype" : "file" ,
  6. "agentid" : "1" ,
  7. "file" : {
  8. "media_id" : "MEDIA_ID"  
  9. },
  10. "safe" : "0"  
  11. }
parameter must illustrate
touser no UserID list (message recipients, multiple recipients are separated by '|'). Special case: specify @all to send to all members who follow the enterprise application
toparty no PartyID list, multiple recipients are separated by '|'. This parameter is ignored when touser is @all
totag no TagID list, multiple recipients are separated by '|'. This parameter is ignored when touser is @all
msgtype yes Message type, fixed at this time: file
agentid yes The id of the enterprise application, integer. You can view it on the application settings page.
media_id yes Document ID
safe no Indicates whether it is a confidential message, 0 means no, 1 means yes, the default is 0
  • news
  1. {
  2. "touser" : "UserID1|UserID2|UserID3" ,
  3. "toparty" : " PartyID1 | PartyID2 " ,
  4. "totag" : " TagID1 | TagID2 " ,
  5. "msgtype" : "news" ,
  6. "agentid" : "1" ,
  7. "news" : {
  8. "articles" :[
  9. {
  10. "title" : "Title" ,
  11. "description" : "Description" ,
  12. "url" : "URL" ,
  13. "picurl" : "PIC_URL" ,
  14. },
  15. {
  16. "title" : "Title" ,
  17. "description" : "Description" ,
  18. "url" : "URL" ,
  19. "picurl" : "PIC_URL" ,
  20. }
  21. ]
  22. }
  23. }
parameter must illustrate
touser no UserID list (message recipients, multiple recipients are separated by '|'). Special case: specify @all to send to all members who follow the enterprise application
toparty no PartyID list, multiple recipients are separated by '|'. This parameter is ignored when touser is @all
totag no TagID list, multiple recipients are separated by '|'. This parameter is ignored when touser is @all
msgtype yes Message type, fixed at this time: news
agentid yes The id of the enterprise application, integer. You can view it on the application settings page.
title no title
description no describe
url no Click the link to jump to. The company can verify the employee's true identity based on the code parameter in the URL. For details, please refer to "9 WeChat page jump employee identity query"
picurl no The image link of the picture message supports JPG and PNG formats. The best effect is 640*320 for large pictures and 80*80 for small pictures. If it is not filled, the picture will not be displayed on the client
  • mpnews news

Note: mpnews messages are similar to news messages, except that the text and picture message content is stored in the WeChat backend and supports confidentiality options.

  1. {
  2. "touser" : "UserID1|UserID2|UserID3" ,
  3. "toparty" : " PartyID1 | PartyID2 " ,
  4. "totag" : " TagID1 | TagID2 " ,
  5. "msgtype" : "mpnews" ,
  6. "agentid" : "1" ,
  7. "mpnews" : {
  8. "articles" :[
  9. {
  10. "thumb_media_id" : "id" ,
  11. "author" : "Author" ,
  12. "content_source_url" : "URL" ,
  13. "content" : "Content"  
  14. "digest" : "Digest description" ,
  15. "show_cover_pic" : "0"  
  16. },
  17. {
  18. "thumb_media_id" : "id" ,
  19. "author" : "Author" ,
  20. "content_source_url" : "URL" ,
  21. "content" : "Content"  
  22. "digest" : "Digest description" ,
  23. "show_cover_pic" : "0"  
  24. }
  25. ]
  26. "media_id" : "id"  
  27. }
  28. "safe" : "0"  
  29. }
parameter must illustrate
touser no UserID list (message recipients, multiple recipients are separated by '|'). Special case: specify @all to send to all members who follow the enterprise application
toparty no PartyID list, multiple recipients are separated by '|'. This parameter is ignored when touser is @all
totag no TagID list, multiple recipients are separated by '|'. This parameter is ignored when touser is @all
msgtype yes Message type, fixed at this time: mpnews
agentid yes The id of the enterprise application, integer. You can view it on the application settings page.
articles yes Graphics and text messages. One graphic and text message supports 1 to 10 graphics and texts.
thumb_media_id yes The media_id of the picture and text message thumbnail can be obtained in the multimedia file upload interface. Here, thumb_media_id is the media_id returned by the upload interface.
title yes Title of the picture and text message
author no Author of the picture and text message
content_source_url no The page link after clicking "Read original text" in the picture and text message
content yes Content of graphic message, supports HTML tags
digest no Description of picture and text message
show_cover_pic no Whether to display the cover, 1 for display, 0 for not display
safe no Indicates whether it is a confidential message, 0 means no, 1 means yes, the default is 0

<<:  Should I learn Swift or Objective-C directly?

>>:  Android Getting Started - Button Control + Custom Button Control

Recommend

2019 Complete Plan for Online Event Promotion!

How to plan an online event? Even those who are j...

Traffic acquisition operator, building a traffic matrix

Course Catalog: ├──【1】Main course for traffic acq...

Flying needles and threads! Fibers that “weave” smart fashion

The 1990s was a boom period for Hong Kong's g...

How to write a countdown short copy?

During the Double Eleven period, when others were...

Recommend some keys to improve iOS development efficiency

First of all, the title is a bit broad. This arti...

Seeing the "bones" of the cosmic ghost hand

Seeing the "bones" of the cosmic ghost ...

Analyze these 4 factors of the viral growth model

What is Growth Hacking ? This concept originated ...

Xiaomi is going to acquire BlackBerry?

[[134475]] Rumors about Microsoft acquiring Black...