https://github.com/elonzh/trumpet
a webhook message transform service
https://github.com/elonzh/trumpet
dingtalk dingtalk-robot feishu transformer webhook webhook-server
Last synced: 7 months ago
JSON representation
a webhook message transform service
- Host: GitHub
- URL: https://github.com/elonzh/trumpet
- Owner: elonzh
- License: mit
- Created: 2020-10-28T07:49:35.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2020-11-07T13:24:39.000Z (almost 5 years ago)
- Last Synced: 2025-03-19T01:38:40.655Z (8 months ago)
- Topics: dingtalk, dingtalk-robot, feishu, transformer, webhook, webhook-server
- Language: Go
- Homepage:
- Size: 59.6 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 🎺trumpet   [](https://golangci.com)  [](https://github.com/elonzh/trumpet/blob/main/LICENSE)
Webhook message transform service
---
[English](./README.md) | [ç®€ä½“ä¸æ–‡](./README.zh.md)
## Usage
### Quick start
```shell
docker run -d -p 8080:8080 elonzh/trumpet
feishu_webhook=''
curl "http://127.0.0.1:8080/transformers/dingtalk-to-feishu?trumpet_to=${feishu_webhook}" \
-v -X "POST" -H "Content-Type: application/json" \
-d '{"msgtype": "text", "text": {"content": "message from trumpet!"}}'
```
You can mount the configuration in the default configuration path `/app/config.yaml`, or provide the `-c/--config` parameter to provide the configuration file path.
### Builtin transformers
| | | |
|------------------------------------------------------------------|---|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [DingTalk](https://ding-doc.dingtalk.com/doc#/serverapi2/qf2nxq) | ↔ | [Feishu](https://www.feishu.cn/hc/zh-cn/articles/360024984973-%E5%9C%A8%E7%BE%A4%E8%81%8A%E4%B8%AD%E4%BD%BF%E7%94%A8%E6%9C%BA%E5%99%A8%E4%BA%BA)/[Lark](https://www.larksuite.com/hc/en-US/articles/360048487736-Bot-Use-bots-in-groups#source=section) |
### Customize transformers
> Starlark is a dialect of Python intended for use as a configuration language.
The message transformer are written by [Starlark language](https://github.com/google/starlark-go),
and what you need to do is defining a `transform` function, modifying the incoming request accordingly,
for example:
```python
def transform(request):
# print(requst["headers"])
# print(requst["body"])
msg_type = request["body"]["msg_type"]
body = {}
if msg_type == "text":
body = {
"msgtype": "text",
"text": {"content": request["body"]["content"]["text"]},
}
request["body"] = body
return request
```
### Deploy to Kubernetes
The configuration file deployed to the Kubernetes cluster is provided in the [manifests](./manifests) folder, you can make adjustments according to your needs.
## Contribute
If you want to add or update builtin transformers, just make a pull request!