Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
Showing results for 
Search instead for 
Did you mean: 
Product and Topic Expert
Product and Topic Expert


This is the continuation of my previous blog, where I started with the concepts of event driven architecture and integrated event mesh with CAP project. In this blog I continue the journey by creating a consumer API and integrating an end to end use case starting from CAP project (REST API) - SAP Event Mesh - SAP Integration suite (REST API) - TWILIO

Let us break down the tasks which we are going to perform.

  1. Design thinking and a quick recap of Part-1

  2. Create a consumer application using SAP Integration Suite

  3. Configure SAP Integration Suite REST API as Web hook in Event Mesh

  4. Test the complete flow: CAP (REST API) - SAP Event Mesh - SAP Integration Suite (REST API) - TWILIO

Sounds cool right? Lets start the journey.

Task-1: Design thinking and a Quick Recap of Part-1

In Part-1 of the blog, we completed below tasks -

  • Create Event Mesh message client

  • Publish message from CAP application to Event Mesh.

In this blog (Part-2), we will create a REST API using SAP Integration suite and configure it as a consumer for consuming the messages from Event Mesh. A quick recap can be elaborated with the help of below diagram -


We are going to focus on Part-B and Part-C.

Task-2: Create a Consumer API using SAP Integration Suite

The goal of this task is to

  1. Set up SAP Integration Suite

  2. Create REST API

  3. Integrate with TWILIO leveraging open connectors

All the above tasks are very well documented in my blog - here

I recommend you to go through the blog. Feel free to like, share and comment to improve it further.

Task-3: Configure SAP Integration Suite REST API as a web hook in Event Mesh

In this task, we are going to set up a consumer API as a web hook in SAP Event Mesh.

Let's get started.

  1. Open the event mesh portal and go the message client.

  2. Go to the web hook tab as shown in the below screenshot

  3. Click - Create Webhook

  4. Set up the properties as mentioned below

    1. Subscription Name - A name for your web hook

    2. Queue Name - The queue for which you are creating the web hook and configuring it as a consumer

    3. Exempt Handshake - Select as YES.

    4. Web hook URL - The REST API url for SAP Integration Suite

    5. Default Content-Type - application/json

    6. Authentication - OAuth2ClientCredentials

    7. Client ID - Client ID for SAP Integration Suite. This you will get it from the SAP Integration Suite Service Key.

    8. Client Secret -  Client secret for SAP Integration Suite. This you will get it from the SAP Integration Suite Service Key.

    9. Token URL - OAuth token url for SAP Integration Suite. This you will get it from the SAP Integration Suite Service Key.

  5. Once done, you should see the Subscription Status as ACTIVE.

All set. You have successfully completed this task.

Task-4: Test the complete flow: CAP - SAP Event Mesh - SAP Integration Suite - TWILIO

In this section,

  1. We will send a message to the CAP microservice API for new user creation.

  2. The CAP event handler will compile a welcome message and push it to event mesh topic.

  3. The event mesh topic will push the message to the queue through queue subscription.

  4. The message will be then consumed by the SAP Integration Suite REST API through the web hook.

  5. If all goes well, you should receive a text message on your phone from TWILIO.

Let us see all that in action using POSTMAN.

  1. Open the POSTMAN collection which you might have created as per the guidelines in the task-5 of my previous blog

  2. Sample request to create a new user with role Admin
    "firstName": "John",
    "lastName": "Doe",
    "email": "",
    "phone": "XXXXXXXXXX",
    "userRole_name": "Admin"

  3. I am providing the final CAP event handler in action. In this event handler, I am using

    1. @Before event to generate a random number and save it in db as OTP

    2. @after event to create message and send it to the SAP Event mesh topic

      import java.util.Objects;

      import com.nimbusds.jose.shaded.json.JSONObject;


      import org.slf4j.Logger;
      import org.slf4j.LoggerFactory;
      import org.springframework.beans.factory.annotation.Autowired;
      import org.springframework.beans.factory.annotation.Qualifier;
      import org.springframework.stereotype.Component;

      import cds.gen.adminservice.User;
      import cds.gen.adminservice.User_;

      public class AdminService implements EventHandler {

      Logger logger = LoggerFactory.getLogger(AdminService.class);

      private static final String WELCOME_STRING = "Welcome! Start to manager your tasks efficiently";

      private static final String PASSWORD_PREFIX = "capm";

      MessagingService messagingService;

      @Before(event = CqnService.EVENT_CREATE , entity = User_.CDS_NAME)
      public void beforeCreate(User userData) {

      String otp = PASSWORD_PREFIX + String.valueOf(TaskManagerUtil.generateRandomNumber()) ;

      userData.setOtp(otp);"Generated default otp for {}", userData.getFirstName());


      @After(event = CqnService.EVENT_CREATE , entity = User_.CDS_NAME)
      public void afterCreate(User userData) {

      JSONObject payload = new JSONObject();

      JSONObject jsonObject = new JSONObject();

      jsonObject.put("message", WELCOME_STRING);
      jsonObject.put("fromPhone", "+1XXXXXXXXXX");
      if(Objects.nonNull(userData.getPhone()) && userData.getPhone().startsWith("+1")){
      } else {
      jsonObject.put("toPhone","+1" + userData.getPhone());

      payload.put("data", jsonObject);"Sending message to the topic in SAP Event Mesh");

      messagingService.emit("sap/taskmanager-events/event-mesh/user-registration-topic", payload);




  4. The message is pushed to SAP Integration Suite REST API and finally you should receive a text message in your phone .


I tried to bring all the pieces of the puzzle together in this blog to complete a seamless integration using SAP Business Technology Platform .

As always, there are lot of areas to explore and learn. So, Stay curious! Keep learning!

To get more updates about this topic follow the below pages

  1. Blogs

  2. Q&A

Feel free to “like“, “Share“, “Add a Comment” and to get more updates about my next blogs follow me – avinash.vaidya