Files
gitlab-instance-0a899031_ma…/微信AI/charles.md
hackrobot 5bcc3a51fd 'mmm'
2024-08-03 14:18:12 +08:00

50 lines
1.4 KiB
Markdown

例如:
- APPID: xxxxxxxxxxxxxxx
- TOKEN: xxxxxxxxxxxxxxx
- EncodingAESKey: xxxxxxxxxxxxxxx
### 1. 获取`signature`接口:
`https://chatbot.weixin.qq.com/openapi/sign/{TOKEN}`
```
{
signature: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImp0aSI6IjI2NTQ0NzYzLTk1NzctNDZlNS1iOTFlLTA3NjAyMzhiMjUwNSIsImlhdCI6MTU4NjA5Nzc4MSwiZXhwIjoxNTg2MTAxMzgxfQ.qugHipCyBnONQRGY2fadm1LH-bLi0TrVqam3vZTpRcI
expiresIn: 7200
}
```
> signature 也可以在本地通过jwt签名得到
```
const signature = jwt.encode(
EncodingAESKey,
{
username: "some persone",
userid: "alsjdasf12",
avatar:
"https://res.wx.qq.com/a/wx_fed/weixin_portal/res/static/img/1L3ryyg.png",
},
"HS256",
);
```
### 2. 智能对话接口:
`https://chatbot.weixin.qq.com/openapi/aibot/{TOKEN}`
| 字段 | 类型 | 是否必填 | 描述 |
| --------- | ------ | ---- | --------------------- |
| signature | string | 是 | 上一步获取到的 signature 返回值 |
| query | string | 是 | 用户发送的消息 |
返回值说明:
| 字段 | 类型 | 描述 |
| ------------- | ------ | --------- |
| ans_node_id | int32 | 技能id |
| ans_node_name | string | 分类/技能名称 |
| title | string | 标准问题/意图名称 |
| answer | string | 命中的回答 |