Question

sheets uses webhook to send a line of records to Enterprise WeChat.

  • 5 April 2022
  • 1 reply
  • 161 views

I need to send a row of data from Google sheets to a messaging platform. His configuration requirements:

 

How to use a group bot
After adding a bot to a group in the terminal, the creator can see the bot-specific webhook url on the bot details page, and the developer can make an HTTP POST request to this address to send messages to the group as described below. Here's a simple example.
Suppose the webhook is: https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=693a91f6-7xxx-4bc4-97a0-0ec2sifa5aaa
Special note: Be sure to protect the bot's webhook address from leaks! Don't share it on github, blogs or other publicly accessible places, or the bad guys can use your bot to spam.

Here's an example of pushing a text message to a group using the curl tool (note that the url should be replaced with your bot's webhook address and the content must be in utf8 encoding).

curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=693axxx6-7aoc-4bc4-97a0-0ec2sifa5aaa' \
   -H 'Content-Type: application/json' \
   -d '
   {
        "msgtype": "text",
        "text": {
            "content": "hello world"
        }
   }'
The current custom bot supports four message types: text (text), markdown (markdown), image (image), and graphic (news).
The bot's text/markdown type messages support the use of the <@userid> extension syntax in the content to @group members
Message types and data formats
Text type
{
    "msgtype": "text",
    "text": {
        "content": "Weather in Guangzhou today: 29 degrees, mostly cloudy, probability of rain: 60%",
        "menued_list":["wangqing","@all"],
        "menued_mobile_list":["13800001111","@all"]
    }
}
参数 是否必填 说明
msgtype 是 消息类型,此时固定为text
content 是 文本内容,最长不超过2048个字节,必须是utf8编码
mentioned_list 否 userid的列表,提醒群中的指定成员(@某个成员),@all表示提醒所有人,如果开发者获取不到userid,可以使用mentioned_mobile_list
mentioned_mobile_list 否 手机号列表,提醒手机号对应的群成员(@某个成员),@all表示提醒所有人


markdown类型
{
    "msgtype": "markdown",
    "markdown": {
        "content": "实时新增用户反馈<font color=\"warning\">132例</font>,请相关同事注意。 \n
         >类型:<font color=\"comment\">用户反馈</font>
         >普通用户反馈:<font color=\"comment\">117例</font>
         >VIP用户反馈:<font color=\"comment\">15例</font>"
    }
}
参数 是否必填 说明
msgtype 是 消息类型,此时固定为markdown
content 是 markdown内容,最长不超过4096个字节,必须是utf8编码


目前支持的markdown语法是如下的子集:

标题 (支持1至6级标题,注意#与文字中间要有空格)
# 标题一
## 标题二
### 标题三
#### 标题四
##### 标题五
###### 标题六
加粗
**bold**
链接
[这是一个链接](http://work.weixin.qq.com/api/doc)
行内代码段(暂不支持跨行)
`code`
引用
> 引用文字
字体颜色(只支持3种内置颜色)
<font color="info">绿色</font>
<font color="comment">灰色</font>
<font color="warning">橙红色</font>
图片类型
{
    "msgtype": "image",
    "image": {
        "base64": "DATA",
        "md5": "MD5"
    }
}
参数 是否必填 说明
msgtype 是 消息类型,此时固定为image
base64 是 图片内容的base64编码
md5 是 图片内容(base64编码前)的md5值
注:图片(base64编码前)最大不能超过2M,支持JPG,PNG格式

图文类型
{
    "msgtype": "news",
    "news": {
       "articles" : [
           {
               "title" : "中秋节礼品领取",
               "description" : "今年中秋节公司有豪礼相送",
               "url" : "www.qq.com",
               "picurl" : "http://res.mail.qq.com/node/ww/wwopenmng/images/independent/doc/test_pic_msg1.png"
           }
        ]
    }
}
Parameter Required or not Description
msgtype is the message type, fixed to news
articles is a graphic message, a graphic message supports 1 to 8 graphics
title is the title, not more than 128 bytes, more than that will be automatically truncated
description No Description, no more than 512 bytes, more than that will be automatically truncated
url is the link to jump to after clicking.
picurl No Picture link for graphic message, support JPG, PNG format, the better effect is big picture 1068*455, small picture 150*150.


File type
{
    "msgtype": "file",
    "file": {
         "media_id": "3a8asd892asd8asd"
    }
}
Parameter Required or not Description
msgtype is the message type, fixed to file in this case
media_id is the file id, obtained through the file upload interface below


Template card type
Text notification template card


{
    "msgtype": "template_card",
    "template_card":{
        "card_type": "text_notice",
        "source":{
            "icon_url": "https://wework.qpic.cn/wwpic/252813_jOfDHtcISzuodLa_1629280209/0",
            "desc": "enterprise_weibo",
            "desc_color":0
        },
        "main_title":{
            "title": "Welcome to Enterprise WeChat",
            "desc": "Your friends are inviting you to join WeChat"
        },
        "emphasis_content":{
            "title": "100",
            "desc": "data_meaning"
        },
        "quote_area":{
            "type":1,
            "url": "https://work.weixin.qq.com/?from=openApi",
            "appid": "APPID",
            "pagepath": "PAGEPATH",
            "title": "Quote text title",
            "quote_text": "Jack: Enterprise WeChat is really good ~ \nBalian: superb piece of software!"
        },
        "sub_title_text": "Download Enterprise WeChat can also grab red packets!" ,
        "horizontal_content_list":[
            {
                "keyname": "invitee",
                "value": "Zhang San"
            },
            {
                "keyname": "企业微官网",
                "value": "Click to visit",
                "type":1,
                "url": "https://work.weixin.qq.com/?from=openApi"
            },
            {
                "keyname": "Enterprise Micro Download",
                "value": "enterprise weibo.apk",
                "type":2,
                "media_id": "MEDIAID"
            }
        ],
        "jump_list":[
            {
                "type":1,
                "url": "https://work.weixin.qq.com/?from=openApi",
                "title": "Enterprise WeChat official website"
            },
            {
                "type":2,
                "appid": "APPID",
                "pagepath": "PAGEPATH",
                "title": "Jump to applet"
            }
        ],
        "card_action":{
            "type":1,
            "url": "https://work.weixin.qq.com/?from=openApi",
            "appid": "APPID",
            "pagepath": "PAGEPATH"
        }
    }
}
Request Parameters

Parameters Type Required Description
msgtype String is the message type, which in this case is fixed to template_card
template_card Object is the specific template card parameter
Parameter description for template_card

Parameter Type Required Description
card_type String is the template type of the template card, the text notification template card is of type text_notice
source Object No Card source style information, no source style is not required.
source.icon_url String No The url of the source image
source.desc String No Description of the source image, recommended not to exceed 13 characters
source.desc_color Int No The color of the source text, currently supports: 0 (default) gray, 1 black, 2 red, 3 green

 


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

1 reply

Userlevel 7
Badge +12

Hi @luoxin 

It sounds like you want to create a Zap that uses a webhook to sends information in a Google Sheet when there’s a new row in the sheet, is that right?

The basic set up of the Zap would be this:

  1. Trigger - New Spreadsheet Row
  2. Action: Webhooks by Zapier - Post action

The Post action can send simple parameters via webhook, but if you need to format the message so that it matches what you’ve added in your post, you’ll need to use the Custom request action. It’s difficult to say how to set it up without more context, but it looks like you’d need copy and paste the text of the hook and add the information from the Google Sheet where it says ‘content’ eg

I have to admit that that’s a rough guess, because it it depends a lot on what, exactly you need to do and on how the app on the other end handles data sent to it via webhook. I hope that helps!