Skip to content
A dingtalk callback powered by AWS lambda, Dynamodb.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

A Dingtalk(钉钉) callback on AWS

Build Status

The program provides a HTTP API endpoint to receive kinds of dingtalk callback events and persist them in AWS DynamoDB, including BPM events, Organization events and so on.

It is written by Kotlin and leverages below AWS services,

How to deploy this program


  1. Get the corpid of your dingtalk's organization in open dev platform
  2. Create secure parameters named DD_TOKEN, DD_AES_TOKEN and DD_CORPID(from step 1) in Systems Manager
  3. Create a S3 bucket(say my-deploy-bucket) for deployment
  4. [Optional] Install and configure SAM CLI for local deployment

Build, Test and package

# build the source
./gradlew build

Deploy via SAM cli

# package the lambda functions
sam package --output-template-file packaged.yaml \
    --s3-bucket my-deploy-bucket --template-file template-sam.yaml
# deploy the lambda function, api gateway, dybnamodb
sam deploy --template-file ./packaged.yaml \
    --stack-name my-dingtalk-callback --capabilities CAPABILITY_IAM

Deploy via serverless framework

sls deploy

Deploy via Code pipeline

  1. Put the github person token to codepipeline.json
  2. Set the s3 bucket name in codepipeline.json
  3. Set any parameter in codepipeline.json if necessary, such as app name, repo name and branch name
  4. Create a CI/CD pipeline in CodePipeline via below command, which can be continously triggered by new commits of this repo then deploy lambda HTTP endpoint
aws cloudformation create-stack --stack-name dingtalk-mycorp --template-body file://codepipeline.yml --parameters file://codepipeline.json --capabilities CAPABILITY_NAMED_IAM

Post deployment actions

  1. Get id of api gateway of AWS created by above deployment
  2. Use dingtalk API to register/update this serverless API gateway endpoint as callback of dingtalk events.

For example,

curl -X POST \
  '<your token>' \
  -H 'Content-Type: application/json' \
  -d '{
    "call_back_tag": [
    "token": "<token created in prerequisites step 2>",
    "aes_key": "<aes token created in prerequisites step 2>",
    "url": "https://<id of api gateway created by above deployment>.execute-api.<your region>"

Spring Cloud Function version

I also port this lambda function to use Spring Cloud Function as lambda framework, you can checkout this branch if your're interested.

You can’t perform that action at this time.