This demo introduces a simple solution to integrate Dingtalk with Function Compute, using Dingtalk http callback to invoke function, and then function can read the Dingtalk Event you subscript. When the events triggered, such as department change、new member join, Dingtalk will send the notification to the function HTTP URL, and then you can process the event accordingly.
- Install Funcraft on the local machine. For more information, see installation instructions.
- Run
fun --version
to check whether the installation is successful. - You need to configure funcraft with your own aliyun access key id and access key secret. Follow the steps in Configure Funcraft .Run fun config to configure Funcraft. Then configure Account ID, Access Key ID, Access Key Secret, and Default region name as prompted.
$ fun config
Aliyun Account ID 1234xxx
Aliyun Access Key ID xxxx
Aliyun Access Key Secret xxxx
Default region name cn-xxxx
The timeout in seconds for each SDK client invoking 300
The maximum number of retries for each SDK client 5
Allow to anonynously report usage statistics to improve the tool over time? (Y/n)
- Enter Dingtalk open platform
- Enter Application-Developing -> Corporation-Inner-Develop -> MiniApp, and create a MiniApp, then record the
AppKey
. - Enter the MiniApp you just created, and go to the Event-Subscription, fill or get the
aes_key
、token
- Edit
template.yml
file to fill the environment variablesyour_app_key、your_aes_key、your_token
- For testing purpose, you can create a logsore for the function, all function logs will be collected to the logstore:
- Create a Aliyun Logstore on the region according to
fun config
config。 - Fill
your_project_name
和your_logstore_name
ontemplate.yml
file。
- Run following command on the demo root path:
fun build # build the demo
fun deploy -y # deploy function
Since the HTTP callback endpoint must be a public network access URL at Dingtalk, so you need to apply a custom domain , and bind the function to the domain path.
Eg: this demo's custom domain http://30612374-1221968287646227.test.functioncompute.com/fc-dingtalk-demo
Enter Dingtalk open platform
- Enter the MiniApp you just created, and go to the Event-Subscription, fill the
Request URL
box using the function custom domain. - Click
Save
button and Dingtalk will send acheck_url
request to your function, save success means integration is OK. - Open the switch button of the event you want to subscribe.
More information please see Event subscription
When a new member join to your corporation, function will receive a hrm_user_record_change
event, you can see the function log on the logstore: