EventBridge can integrate with a DingTalk connector, which allows you to build various employee management systems based on input parameters of your business operations. This topic describes how to use a third-party service to call HTTP API operations. In this topic, the process of adding an employee to a DingTalk team is used as an example.
Workflow
In this topic, the following services are used: DingTalk, DingTalk connector, EventBridge, and Function Compute. The following figure shows the workflow for triggering HTTP APIs by using DingTalk.
Prerequisites
Before you start, make sure that the following operations are performed:
Sign up for a DingTalk account and create a DingTalk team and specify yourself as the administrator. For more information, see How to create an organization?
Activate EventBridge and grant a Resource Access Management (RAM) user permissions. For more information, see Activate EventBridge and grant permissions to a RAM user.
Step 1: Create a custom event bus
Log on to the EventBridge console. In the top navigation bar, select a region.
In the left-side navigation pane, click Event Buses. In the Custom Event Buses section, click Quickly Create.
In the Create Custom Event Bus panel, perform the following operations in each step:
In the Event Bus step, configure the Name and Description parameters and click Next Step.
In the Event Source step, configure the Event Source Name and Description parameters, proceed with the parameters in the following table, and then click Next Step.
Parameter
Value
Event Provider
HTTP/HTTPS Events
Request Type
HTTPS
Request Method
POST
Security Settings
Optional
In the Event Rule step, click Skip. The Skip Subsequent Steps message appears. Click OK. This ensures that no event rules and event targets are created on the event bus.
After you create an event source, it is displayed on the Event Sources page. You can click Details in the Operations column to view the details of the event source. You can use the value of the Internet Request URL parameter as the webhook URL of the DingTalk connector.
Step 2: Create a DingTalk connection flow
Log on to the DingTalk Open Platform console. In the top navigation bar, choose .
In the left-side navigation pane, choose .
On the My Connection Flows page, select Business Flow from the Create drop-down list.
In the Create Flow dialog box, specify the name and description of the flow, and set Trigger to .
On the Connection Flow tab, click the icon and then Network Request.
On the right side of the Network Request section, click the icon. In the Network Request panel, configure request parameters and click Save. The following table describes the parameters.
Step 3: Use Function Compute to call HTTP API operations
Log on to the Function Compute console. In the left-side navigation pane, click Services & Functions.
In the top navigation bar, select a region. On the Services page, click Create Service.
In the Create Service panel, enter the service name and description, configure other parameters, and then click OK. The following table describes the parameters.
Parameter
Description
Logging
Specify whether to enable the logging feature. Valid values:
Enable: Function Compute sends function execution logs to Simple Log Service for persistent storage. You can debug code, troubleshoot issues, and analyze data based on the logs.
Disable: You cannot use Simple Log Service to store or query function execution logs.
Advanced options
Managed Service for OpenTelemetry
Specifies whether to enable Managed Service for OpenTelemetry. Valid values:
Enable: enables Managed Service for OpenTelemetry. You can use Jaeger to upload trace information. This allows you to view the traces of functions. You can also analyze and diagnose performance bottlenecks in serverless architectures. For more information, see Overview of Managed Service for OpenTelemetry.
Disable: disables Managed Service for OpenTelemetry.
Service Role
Configure the role for functions in the service. This way, the functions can obtain the permissions of the role. For more information, see Grant Function Compute permissions to access other Alibaba Cloud services.
Access to VPC
Specifies whether to allow functions to access virtual private cloud (VPC) resources. For more information, see Configure network settings.
VPC
This parameter is required if you set Access to VPC to Yes. Create a VPC or select the ID of an existing VPC that you want to access from the drop-down list.
vSwitch
This parameter is required if you set Access to VPC to Yes. Create a vSwitch or select the ID of an existing vSwitch from the drop-down list.
Security Group
This parameter is required if you set Access to VPC to Yes. Create a security group or select an existing security group from the drop-down list.
Access to Internet
Specifies whether to allow functions in the service to access the Internet. If you set this parameter to No, functions in the service cannot access the Internet over the default network interface controller (NIC) in Function Compute.
ImportantIf you want to use a static public IP address to access the Internet, you must set Access to Internet to No. Otherwise, the configured static public IP address does not take effect. For more information, see Configure static public IP addresses.
On the Services page, click the name of the service that you want to view and click Create Function.
On the Create Function page, select Use Built-in Runtime to create a function, configure the following parameters, and then click Create.
In the Basic Settings section, configure the Function Name parameter and set Handler Type to Event Handler.
In the Code section, set Runtime to Node.js, set Code Upload Method to Use Sample Code, and then click API Gateway-triggered Function.
After you create the function, you can view the details on the function details page.
Step 4: Create an event rule
Log on to the EventBridge console and find the custom event bus that you created in Step 1.
Click the name of the custom event bus. In the left-side navigation pane, click Event Rules.
On the Event Rules page, click Create Rule. In the Create Rule panel, perform the operations in the following steps.
In the Configure Basic Info step, configure the Name and Description parameters and click Next Step.
In the Configure Event Pattern step, set Event Source Type to Custom Event Source and Event Source to the custom event source that you created in Step 1. Then, click Next Step.
In the Configure Targets tab, configure parameters and click Create. The following table describes the parameters.
Parameter
Description
Example
Service Type
Select the service type of the event target.
Function Compute
Service
Select the service that is created in Step 3.
testserver
Function
Configure the function that is created in Step 3.
testfunction
Event
Select Complete Event.
Complete Event
Invocation Mode
Select Synchronous.
Synchronous
Step 5: Add an employee to automatically trigger an HTTP API operation
Invite members to join your DingTalk team. For more information, see How do I add members?
On the details page of the custom event bus that you created in Step 1, click Event Tracking, specify a time range, and then click Query.
Find the event that you want to manage and click Event Track in the Operations column to check whether the new employee event is delivered.
Verify the result
Log on to the Function Compute console and view the function that you created in Step 3. In the Requests List section of the Function Logs tab, you can find that the function is executed once.