Skip to content
Dingtalk(钉钉) callback powered by Aliyun Function Compute
Kotlin
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
gradle/wrapper
lib
src
.funignore
.gitignore
.gitlab-ci.yml
README.md
build.gradle.kts
gradle.properties
gradlew
gradlew.bat
settings.gradle
template.tmpl

README.md

部署于阿里云函数计算的钉钉回调接口

该程序实现了一个HTTP接口用于接受钉钉的各类事件回调,包括且不限于审批事件、组织事件等。同时事件消息被保存在表格存储中。

该程序使用JVM语言Kotlin开发,使用了如下阿里云产品,

  • 函数计算
  • 表格存储
  • API网关
  • 监控服务
  • 日志服务
  • 访问控制

部署步骤

准备步骤

  1. 从钉钉的开发者平台获取你组织的 corpid
  2. 为回调函数创建密钥DD_TOKEN, DD_AES_KEY
  3. 安装配置 Fun CLI用于部署

编译、测试、打包

# build the source
./gradlew build

通过Fun工具部署

# 基于环境变量渲染函数部署配置, template.yml基于Go template, 支持任意Go Template工具处理
sigil -f template.tmpl \
      USING_VPC=true VPC_ID=$VPC_ID VPC_SWITCH_IDS=$VPC_SWITCHER_IDS SECURITY_GROUP_ID=$SECURITY_GROUP_ID \
      USING_LOG=true LOG_PROJECT=$LOG_PROJECT LOG_STORE=$LOG_STORE \
      DD_TOKEN=$DD_TOKEN DD_AES_KEY=$DD_AES_KEY DD_CORPID=$DD_CORPID \
      DTS_ENDPOINT=$DTS_ENDPOINT DTS_INSTANCE_NAME=$DTS_INSTANCE_NAME \
      > template.yml
    
# deploy the fc function, api gateway, table store
fun deploy

钉钉回调设置步骤

  1. 获取到部署后应用的API网关地址
  2. 使用钉钉 API注册或者更新回调地址

For example,

curl -X POST \
  'https://oapi.dingtalk.com/call_back/update_call_back?access_token=<your token>' \
  -H 'Content-Type: application/json' \
  -d '{
    "call_back_tag": [
        "bpms_task_change",
        "bpms_instance_change"
    ],
    "token": "<token created in prerequisites step 2>",
    "aes_key": "<aes token created in prerequisites step 2>",
    "url": "<部署后获得API网关地址>"
}' 
You can’t perform that action at this time.