Webhook message transform service
docker run -d -p 8080:8080 elonzh/trumpet
feishu_webhook='<your-feishu-webhook-url>'
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.
DingTalk | ↔ | Feishu/Lark |
Starlark is a dialect of Python intended for use as a configuration language.
The message transformer are written by Starlark language,
and what you need to do is defining a transform
function, modifying the incoming request accordingly,
for example:
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
The configuration file deployed to the Kubernetes cluster is provided in the manifests folder, you can make adjustments according to your needs.
If you want to add or update builtin transformers, just make a pull request!