Use EventBridge to push events to Lark

Updated at: 2025-01-10 02:22

After you create a custom event bus in EventBridge, you can configure a custom event rule to push events generated by a specific event source to a Lark group. This topic describes how to publish an event generated by an event source and then push the event to a Lark group.

Background information

A Lark chatbot is a dedicated tool for a Lark group. A Lark chatbot can push messages to the current Lark group by calling the webhook URL without the need for approval from the tenant administrator.

EventBridge supports event targets of the HTTP type. You can use EventBridge to push events to a Lark chatbot to implement the change-based alerting feature by using webhook URLs. Event targets of the HTTP type support HTTP and HTTPS URLs that can be accessed over the Internet and in Alibaba Cloud virtual private clouds (VPCs). You can integrate the webhook URLs into various applications to meet different business requirements. For more information, see Route events to HTTP endpoints.

Scenarios

You can connect a Lark chatbot to EventBridge in the following scenarios:

  • Scenarios in which you want to obtain event information by using a Lark chatbot. You can integrate enterprise systems into Lark by using a Lark chatbot to obtain a one-stop user experience.

  • Scenarios in which low-cost development is required. In scenarios in which low-cost development is required, you need to develop only the server-side code for excellent interactions with a chatbot. After you integrate the chatbot with Lark, other members in the enterprise can easily use the chatbot.

This topic describes how to publish events to Lark by using EventBridge.

Process

  1. Create a custom event bus to receive events generated by a custom application or to process existing messages.

  2. Create a Lark chatbot to receive events from the custom event bus and send notifications to the Lark group.

  3. Configure an event rule for the custom event bus that you created.

  4. Verify the result to check whether events can be pushed to the Lark group.

Prerequisites

Step 1: Create a custom event bus

  1. Log on to the EventBridge console.

  2. In the left-side navigation pane, click Event Buses. On the Event Buses page, select a region in the top navigation bar and click Quickly Create in the Custom Event Buses section.

    image

  3. In the Create Custom Event Bus wizard, perform the following steps:

    1. In the Event Bus step, configure the Name and Description parameters and click Next Step.

      image

    2. In the Event Source step, configure the Event Source Name parameter, set the Event Provider parameter to Custom Application, and then click Next Step.

      image

    3. In the Event Rule step, click Skip. In the Skip Subsequent Steps message, click OK.

      Note

      In this example, an event rule and an event target are not created on the custom event bus.

  4. View the custom event bus that you created.

    image

Step 2: Create a Lark chatbot

  1. Log on to Lark for PC and select the Lark group to which you want to add a chatbot.

  2. In the upper-right corner of the Lark group that you want to manage, choose image > Settings.

  3. In the Settings panel, click Bots.

  4. In the Add Bot panel, click Custom Bot.

  5. In the panel that appears, enter the name and description of the custom chatbot and click Add.

  6. In the panel that appears, copy the webhook URL and configure the Security settings parameter based on your business requirements. Then, click Finish.

Step 3: Configure an event rule

  1. Go to the Overview page of the custom event bus that you created and click Add Rule.

    image

  2. In the Create Rule wizard, perform the following steps:

    1. In the Configure Basic Info step, specify the name of the rule and click Next Step.

      image

    2. In the Configure Event Pattern step, click Next Step.

      Important

      In this example, the event pattern is not configured. In the production environment, you must configure the Event Source and Event Type parameters in the Configure Event Pattern step based on your business requirements.

    3. In the Configure Targets step, set the Service Type parameter to HTTPS and the URL parameter to the webhook URL that you copied in Step 2, set the Body parameter to Template, configure parameters in the Variables and Template code editors, and then click Create.

      Note

      For information about how to configure the template, see Template.

      image

      Variables:

      {
          "msg_source":"$.source",
          "msg_type":"$.type"
      }

      Template:

      {
          "msg_type": "text",
          "content": {
              "text": "Event source: ${msg_source}. Event Type: ${msg_type}"
          }
      }
      Note

      In this example, the configurations in the template are simple. In the production environment, you must configure the template based on your business requirements.

Step 4: Verify the result

  1. On the Overview page of the custom event bus that you created, click Publish Event.

    image

  2. In the Publish Event to Custom Event Bus panel, select the custom event source that you created from the Custom Event Source drop-down list, configure parameters in the Event Body code editor, and then click OK.

    image

  3. View the pushed event in the Lark group.

  • On this page (1, T)
  • Background information
  • Scenarios
  • Process
  • Prerequisites
  • Step 1: Create a custom event bus
  • Step 2: Create a Lark chatbot
  • Step 3: Configure an event rule
  • Step 4: Verify the result
Feedback
phone Contact Us

Chat now with Alibaba Cloud Customer Service to assist you in finding the right products and services to meet your needs.

alicare alicarealicarealicare