The EventBridge supports integrated DingTalk connectors. You can build various employee management systems based on the input parameters of business interfaces. This topic describes how to enter a DingTalk new employee entry record into a custom HTTP API operation without a code.

Flowchart

The solution used in this article involves products such as DingTalk, DingTalk connectors,EventBridge, and Function Compute. The process is shown in the following figure:Link diagram

Prerequisites

You have completed the following operations:

Step 1: Create a custom event bus

  1. Log on to the EventBridge console. In the top navigation bar, select the region where your instance is located.
  2. In the left-side navigation pane, click Event Buses. In the Custom Event Buses section, click Quickly Create.
  3. Complete the Create Custom Event Bus wizard.
    1. On the Event Bus tab, set Name and Description, and then click Next.
    2. On the Event Source tab, set Event Source Name and Description, set the following parameters, and then click Next.
      ParameterDescription
      Event ProviderHTTP/HTTPS trigger
      Request TypeHTTPS
      Request MethodPOST
      Security SettingsOptional
    3. On the Event Rule tab, click Skip. In the Skip Subsequent Steps dialog box, click OK. Event rules and event targets are not created for the custom event bus.
      After the event source is created, it is displayed on the Event Sources page. You can click Details in the Operations column to view the details of the event source. The Internet request URL can be used as the access webhook address of the DingTalk connector. pic-1

Step 2: Create a DingTalk connection flow

  1. Log on to the DingTalk Open Platform. In the top navigation bar, choose Open Capabilities > Connected Platform.
  2. In the left-side navigation pane, choose My Connection > Connection Flow.
  3. On the My Connection Flows page, select Business Flow from the Create drop-down list.
    1. In the Create Flow dialog box, set the name and description of the flow, and set Trigger to Official > Contacts > Contacts User Add.
    2. On the Connection Flow tab, click the add icon, and then click Network Request.
    3. On the right side of the Network Request section, click the > icon. In the Network Request request parameters, click Save.
      ParameterDescriptionExamples
      Request MethodThe request method configured in the Step 1: Create a custom event bus. POST
      Request URLThe URL obtained in the configuration Step 1: Create a custom event bus. https://115964845466****.eventbridge.cn-hangzhou.aliyuncs.com/webhook/putEvents?token=8a5c4e6****
      BodyThe fields that the message body contains. root

Step 3: Use the Function Compute to call the HTTP API

  1. Log on to the Function Compute console. In the left-side navigation pane, click Services & Functions.
  2. In the top navigation bar, select a region. On the Services page, click Create Service.
  3. In the Create Service panel, enter a service name and description, configure the following parameters, and then click OK.
    ParameterDescription
    LoggingSpecify whether to enable the logging feature. Valid values:
    • Enable: Function Compute sends function execution logs to Log Service for persistent storage. You can debug code, troubleshoot issues, and analyze data based on the logs.
    • Disable: You cannot use Log Service to store or query function execution logs.
    Advanced Options
    Tracing AnalysisSpecify whether to enable Tracing Analysis. Valid values:
    • Enable: enables Tracing Analysis. 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 within serverless architectures. For more information, see Overview.
    • Disable: disables Tracing Analysis.
    Server RoleSelect a role for the service. The functions that belong to the service inherit this role. For more information, see Grant Function Compute permissions to access other Alibaba Cloud services.
    Access to VPCSpecify whether to allow functions to access virtual private cloud (VPC) resources. For more information, see Configure network settings.
    VPCThis 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.
    vSwitchThis 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 GroupThis 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 InternetSpecify 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 by using the default network interface controller (NIC) in Function Compute.
    Important If 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.
  4. On the Services page, click the name of the service that you want to manage and click Create Function.
  5. On the Create Function page, select a method to create a function, configure the following parameters, and then click Create.
    1. In the Basic Settings section, set Function Name and Handler Type to HTTP Handler.
    2. In the Function Code section, set Runtime to Node.js, set Code Upload Method to Use Sample Code, and then click API Gateway-triggered Function.
      Figure - Create a function
    After the function is created, you can view the details on the Function Details page. Function details

Step 4: Create an event rule

  1. Log on to the EventBridge console and find the custom event bus created in the Step 1: Create a custom event bus.
  2. Click the name of the custom event bus. In the left-side navigation pane, click Event Rules.
  3. On the Event Rules page, click Create Rule. In the Create Rule step, configure the following parameters.
    1. In the Configure Basic Information step, set the Name and Description parameters and click Next.
    2. In the Configure Event Mode step, set Event Source Type to Custom Event Source, set Event Source to the custom event source that you created in the Step 1: Create a custom event bus, and then click Next.
    3. On the Configure Event Target tab, set the following parameters and click Create.
      ParameterDescriptionExamples
      Service TypeSelect a service type. Function Compute
      ServiceSelect the service created in the Step 3: Use the Function Compute to call the HTTP API. testserver
      FunctionConfigure the function created in Step 3: Use the Function Compute to call the HTTP API. testfunction
      EventSelect Complete Event. Complete Event
      Invocation ModeSynchronous. Synchronous

Step 5: Add an employee event to automatically trigger an HTTP API

  1. Invite members to join your DingTalk team. For more information, see Add an organization member.
  2. On the details page of the custom event bus that you created in the Step 1: Create a custom event bus, click Event Tracking, set the query time range, and then click Query.
  3. Click Event Tracking in the Actions column to check whether the new employee event is delivered.
    Log data transferred

Verify the result

Log on to the Function Compute console. On the details page of the function created in the Step 3: Use the Function Compute to call the HTTP API, click the Function Logs tab to view the logs.
Log