[REST Provider] WeChat Pro tutorial

7 Posts
4 Users
0 Likes
44 Views
w.qin
(@w-qinarcinfo-com)
Posts: 21
Eminent Member
Topic starter
 

WeChat is one of the world's most popular social media messaging apps, and is similar to WhatsApp. WeChat supports video, voice,and text chat and has unique features like localized translation. It is the main social app in China.

REST Provider offers us an easy way to send messages from PcVue to Wechat group chat .

-- Wechat Enterprise Edition --

In order to prevent individual users from receiving malicious harassment and advertising, WeChat currently only opens group chat messaging bots for enterprise WeChat. Enterprise WeChat is free.

1. First, you need to have one Wechat enterprise account.

2. Add the relevant persons to an internal enterprise group chat.

3. Create a bot for this group chat. WeChat will provide webhooks for bots.

Be sure to protect the webhook address of the robot to avoid leakage! Don't share it on github, blogs, or other publicly accessible places where bad guys can use your bot to spam. ( eg. https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=693a91f6-7xxx-4bc4-97a0-0ec2sifa5aaa )

-- How to install REST ADO.NET Provider

1. Download the latest provider version.

2. Unzip the file :sv-adonet-provider_REST_XXXXX.msi (XXX for the latest version).

The installation is complete !!
The provider is now visible in PcVue SQL Connection (Data source : Built-in providers).

-- Connection string --

. Connection string :

baseurl= https://qyapi.weixin.qq.com/cgi-bin/webhook/;authorizationtype=ApiKey;headers ="Content-Type:application/json";apikeylocation=QueryParams;apikeyname=key;apikeyvalue=******************************


-- Sql Write queries --

. Sent Text :

EXEC [post_send] BodyContent("application/json") Body("{"msgtype":"text","text":{"content":"Alarm on:?Param01 "}}")

. Sent Markdown :

EXEC [post_send] BodyContent("application/json") Body("{"msgtype":"markdown","markdown":{"content":"New
Alarm coming?Param01,please note!n   >Domain:?Param02   >Nature:?Param03   >Event:?Param04"}")

. Sent News :

EXEC [post_send] BodyContent("application/json") Body("{ "msgtype": "news","news": { "articles" : [ { "title" : "PcVue v16 new features", "description" : "?param01", "url"
: "www.pcvue.com.cn", "picurl" : "https://staging.pcvue.com.cn/static/upload/image/20221123/1669171069927928.png"
} ] } }")

 
Posted : 28/03/2023 9:47 am
KASI
 KASI
(@k-simanjalamarcinfo-com)
Posts: 134
Estimable Member
 

Hi,

Thank you so much for the guide. I have a question.
On the connection string, you have something like the below :

https://qyapi.weixin.qq.com/cgi-bin/webhook/

I believe this is your own custom link, and we had to do some preparation to setup up the webhook. Do we need any hosting for that? Do you have a guide for setting up the webhook?

 
Posted : 28/03/2023 10:06 am
w.qin
(@w-qinarcinfo-com)
Posts: 21
Eminent Member
Topic starter
 

Hi Kantha,
qyapi.weixin.qq.com/cgi-bin/webhook/
this is the fixed address from wechat. Its provided when we create a robot in wechat.
Like: https://qyapi.weixin.qq.com/cgi-bin/webhook/send? key=693a91f6-7xxx-4bc4-97a0-0ec2sifa5aaa
Key is spcific provided when a robot is born.

 
Posted : 28/03/2023 10:27 am
KASI
 KASI
(@k-simanjalamarcinfo-com)
Posts: 134
Estimable Member
 

Hi Wen Qin,

Thank you so much for the explanation 🙂

Have a good day.

 
Posted : 28/03/2023 11:22 am
AD
 AD
(@a-degrearcinfo-com)
Posts: 34
Trusted Member
 

Thank you very much for this excellent tutorial and for sharing your experience.

 
Posted : 28/03/2023 1:55 pm
a.mohammad
(@a-mohammadarcinfo-com)
Posts: 1
New Member Customer
 

Thanks for the tutorial and the feedback! Is it necessary to add the following header in the connection string?

headers="Content-Type:application/json"
 
Posted : 29/03/2023 4:19 pm
w.qin
(@w-qinarcinfo-com)
Posts: 21
Eminent Member
Topic starter
 

In sql command, if query contain BodyContent("application/json"). Accually Heders can be empty.
Yes, it can be removed from connection string.

 
Posted : 30/03/2023 1:05 pm