Deploy COW AI to public accounts

The article has been updated. Previously, Langlangyun had port forwarding public accounts that could not be deployed. This time, the direct reverse generation was successful.The same is true for Enterprise WeChat

The difference between subscription account and service account

Personal subscription account Individuals can apply When a message is received, a message will be replied to the user. After the reply is generated, the user needs to actively send a message to obtain it.
Enterprise service number Enterprises can apply and need to pass certification to open the customer service interface. After the reply is generated, it can be actively pushed to the user.

The following subscription account is an example

 Configuration file

After deploying the project according to the last blog (link below), change the parameters in the configuration file (config.json) file

COW AI access to WeChat nanny tutorial (deployed on the server, plug-in installation) - CSDN Blog

Project configuration

current chatgpt-on-wechatdownload config.jsonText matter

cd chatgpt-on-wechat/
vi config.json

Then fill in the configuration file

Click the letters on the keyboard in English input mode i to start editing

"channel_type": "wechatmp", 
"use_linkai": true,            
"linkai_api_key": "填写你自己key",
"linkai_app_code": "填写你自己code",
"linkai_api_base": "https://api.link-ai.chat",
"wechatmp_app_id": "微信公众平台的appID",
"wechatmp_app_secret": "微信公众平台的appsecret",
"wechatmp_aes_key": "微信公众平台的EncodingAESKey,加密模式需要,如果明文模式就可以空着",
"wechatmp_token": "微信公众平台的Token,你自己随便输入就好", 
"wechatmp_port": 80              # 80或者443端口

Can't copy answers

After the modification is completed, click Esc on the keyboard - and then use the English input method Shift +: —— Enter wq —— Just press Enter

run

Run the python3 app.py project in the chat-on-wechat directory

python3 app.py

 Purchase virtual host reverse generation (Langlangyun)

Note: If you are not using Langlangyun port forwarding, you can skip this step.

 Just buy a virtual host

Open Manage

Advanced - Reverse Proxy

Add proxy

 If you don’t know the NAT server IP, look here

After saving, openHomepage——OpenDomain name

 

 If it displays like this, it means success

Non-Langlangyun (port forwarding) user check

This is what it looks like when running the bottom part

 Then, add /wx to the server address after the access address in the browser and return to the terminal to see if there is a correct output of 202

This is considered a success

  

Official account configuration

Developer password

Let’s set the developer password first. OpenSettings and Development-Basic Configuration-Developer Password. After clicking it, the verification information will appear.

 Non-Langlangyun (port forwarding) user settings whitelist

This step is to obtain access_token

OpenSettings and Development - Security Center - IP Whitelist

 After clicking on it, you will see a page like this

Here we need to fill in the public IP address of our server

 Click on the cloud server we purchased before and copy the public IP

I don’t use the previous server here. I don’t know if I didn’t get it right or it was unsuccessful for other reasons, so I got one for free from Tencent Cloud. I will see if Langlang Cloud can do it later. If it is feasible, I will update the tutorial.

 Return to our official account website, fill in the IP address you just copied to confirm, and then scan the QR code for verification. After that our IP whitelist is written.

  

Configure token

Then openSettings and Development - Basic Configuration  Fill in the content according to the picture below

 Feilanglangyun (port forwarding)

 Langlangyun (port forwarding)

After submission, it will prompt that the token verification is successful and there will be an AI reply from the public account.

Service number

The access process for the service account and the above-mentioned subscription account are basically the same, with slight differences as follows:

  1. Apply for a corporate service account on the public platform and complete WeChat authentication, and confirm in the interface permissions that you have obtained the permissions of Customer Service Interface 
  2. Set in config.json "channel_type": "wechatmp_service", other configurations are the same as the above subscription number
  3. In terms of interaction effect, even long and time-consuming replies can be actively pushed to users without the need for users to obtain them manually.

Replenish

When the startup fails, please check whether port 80 is occupied by ngnix service. {ngnix} is the PHP project service of the website. This service will occupy port 80 and port 443 by default, that is, http and https. The solution is as follows:

  1. If you do not use the website service, you can simply shut down the ngnix service. Then check whether the port is occupied and end the port process to automatically shut down the port service. The command is as follows to check the port process service: netstat -anp |grep{add port number}, such as netstat -anp | grep 80 Check whether the project process starts correctly: ps -ef | grep }Note: process name-app.py} | grep -v grep, for example: ps -ef | grep app.py | grep -v grep
  2. 2. If you need to use website services, you can use a reverse proxy, or switch the website port to avoid occupying port 80 or 443.
  3. Nuo needs to use website services. Secondly, Jianyi sets the https port of the website to 443, adds an SSL certificate, forces the use of https, and sets the public account port to 80.
  4. Summary: 1. Correctly configure json to be consistent with the official account, 2. Check whether port 80 or 443 is occupied by other services, 3. It is recommended to use the website and add ssl to open https

 If a Langlangyun user clicks on the domain name and it is not displayed, you can just turn off the server.

sudo systemctl stop firewalld
sudo systemctl disable firewalld

Guess you like

Origin blog.csdn.net/m0_69655483/article/details/134321592