Architecting Email Approval without My Inbox for SAP Build Process Automation Workflows: Part 1

Estimated read time 14 min read

Business Context

While working day in and day out on SAP BTP use cases, we have noticed a growing inclination among customers towards “Automation” specially with SAP BTP SAP Build Process Automation. This trend has led to the development of various side-by-side custom extensions on SAP BTP utilizing SAP Build Process Automation.

Problem Statement

One of the most common requests we receive from multiple customers is for a mechanism that allows email-based approval without the need to manually log into the My Inbox application.

Currently, there is no out-of-the-box capability available to fulfill this requirement. Therefore, we will be developing our own reusable module to address this need.

In this three-part blog series, my colleague & BTP Architect @Adwait_Fadnavis  and I will provide insights on how to implement Email-based approval using SAP Build Process Automation capabilities.

We have prepared the content for this series in three blogs, where we will be diving deep into Design, Development, and Testing.

Blog 1 (This blog) – This blog will focus on the Business process, context, problem statement, end to end development flow, and required prerequisites.Blog 2 This blog will focus on development and will provide a detailed walkthrough of the development process.Blog 3: This blog will focus on complete end-to-end testing, helping to understand the overall objective.

Scenario Explanation

In this scenario, a workflow will be triggered using SAP Build Process Automation, which will send an email notification to the respective approver.

“The approver will receive the email notification and can reply to this email with either “Approve” or “Reject.” 

Based on the response, the corresponding workflow task will be approved or rejected.

Important Considerations

Valid Approver Verification: The approver must be a valid approver, and the email must come from the approver’s registered email address. If the email does not come from the proper approver, or if the response is not “Approved” or “Reject,” the system must send an email back indicating that the response is not valid.Unique Request Number: Each approval request must generate a unique request number. This number will be used to validate the response against the original request, ensuring that the approval or rejection is correctly matched to the corresponding workflow task.

End to End Business Process Flow: Streamlining Approval Processes with SAP BPA Email-Based Automation

End to End Process Flow : Email based Approval

Workflow Initiation

The process begins when an SAP BPA workflow is triggered. This could be due to various business events, such as a purchase order requiring approval.

Sending Approval Work Items : Once triggered, the workflow sends approval work items to the approver’s SAP BTP My Inbox. Simultaneously, an email notification is dispatched to the approver.Email Notification Details :The email notification includes essential details like the “workflow instance ID” or “Custom Request Number” in the subject line. This ensures the approver & automation (which will elaborate later) can easily identify the request.Approver’s Response Options: The approver has two options to respond:Log into SAP BTP My Inbox: Approvers can log in and approve or reject the request directly.Email-Based Response: Approvers can reply to the email with “Approve” or “Reject.”

Background Automation

An SAP BPA-based automation runs continuously in the background, monitoring the responses sent by the approver. This automation checks if the response is from a valid approver and corresponds to a valid work item.

Updating Work Items: If the response is valid, the automation updates the SAP BPA work item accordingly. This eliminates the need for the approver to log into My Inbox separately, streamlining the process.Completion Notification: Upon completion of the process, an approval email is sent to confirm the outcome. This ensures all stakeholders are informed of the decision.

Benefits of Email-Based Approval Automation

Efficiency: Reduces the time required for approvals by allowing responses directly via email.Convenience: Approvers can respond from anywhere without needing to log into the system.Accuracy: Automated monitoring ensures only valid responses are processed, reducing errors.

Initial Setup and Configuration for Inbound SMTP-Based Approval

Implementing an email-based approval system using SAP Build Process Automation (BPA) requires a few essential setup steps. Below steps will walk you through the initial configuration to ensure a smooth and efficient process.

Outbound SMTP Destination in SAP Build Process Automation

To send emails from SAP Build Process Automation to users’ email accounts, you need to configure an outbound SMTP destination. This setup is crucial for enabling the system to dispatch approval email notifications.

Inbound SMTP Email Configuration

For receiving email responses from approvers, we will use Google for both inbound and outbound SMTP. This setup can also be adapted for Microsoft email or other email services. Here are the key steps:

Enable Access for Reading Gmail: Ensure that the Gmail account used for receiving responses has the necessary permissions enabled. For detailed instructions, refer to the relevant  sap documentation.

Save Credentials JSON File: After setting up the Google Cloud Platform(GCP), securely save the credentials. These credentials are necessary for the SAP BPA to access and read incoming emails.External User Setup in SAP BPA Control Tower: Complete the configuration for the external user in the SAP BPA Control Tower. This step ensures that the system can correctly route and process incoming emails from approvers.

SAP BTP BPA Control Tower

 

Setting Up External Authentication for the Google(Gmail)

Desktop Agent Installation and External User configuration (SMTP Inbound)

The Desktop Agent must be installed in unattended mode to run background processes efficiently.

It is recommended to install the Desktop Agent on a virtual machine to ensure continuous operation. Follow these steps:

Desktop Agent Sub Account Setup: Configure the Desktop Agent within the appropriate sub-account.

Set to Unattended Mode: For real-time production scenarios, set the Desktop Agent to unattended mode. This setup is crucial for automating the approval process without manual intervention.Configure External User: Ensure that the external user configured in the previous step is correctly set up in the Desktop Agent. This configuration allows the agent to process email responses and update the SAP BPA work items accordingly.

Desktop Agent – Registering External Authentication

By following these steps, you are all set for robust email-based approval system using SAP BPA, streamlining your approval processes and enhancing efficiency.

Design and Development Walkthrough for SMTP Inbound Email-Based Approval Automation 

Once the initial setup and configuration are complete in the SAP BPA Control Tower and the unattended Desktop Agent is installed & configured, the next step is to design and develop the automation components.

Below is a summary of the key components involved in this process. My colleague @Adwait_Fadnavis  will provide a detailed walkthrough in a subsequent blog post.

The first step is to create a BPA automation. This involves several key actions:

Invoke Google Authentication and Search for New Emails:

Authenticate External Gmail: Set up Google authentication to allow the system to access your Gmail account.Search Gmail: Create a step to search for new, unread emails with the appropriate subject and request ID. Ensure that only unread emails are read to avoid processing duplicates.Validate the Approver:

Check Valid Approver Validation : Validate that the response is from an authorized approver by reading the subject line for the request number.Fetch Work Item Details: Use the SAP BPA API to retrieve work item details and match the approver. If the approver is not valid or authorized, send an error message.Read the Email Body and Response:

Process Response: If the email response contains “Approve” or “OK,” call the SAP BPA API to update the workflow task accordingly.Send Completion EmailNotify Stakeholders: After successfully processing the workflow approval or rejection, send an email notification to inform all relevant parties of the outcome.

In the upcoming blog post, @Adwait_Fadnavis  will delve into the development flow in detail and provide valuable insights on how to effectively develop inbound SMTP. Final Development flow chart will look as below:

End to End: Development FlowStay tuned for a comprehensive guide that will enhance your understanding and streamline your Development  process.

Regards,

Mohit Bansal, SAP BTP & S4HANA Architect

 

​ Business ContextWhile working day in and day out on SAP BTP use cases, we have noticed a growing inclination among customers towards “Automation” specially with SAP BTP SAP Build Process Automation. This trend has led to the development of various side-by-side custom extensions on SAP BTP utilizing SAP Build Process Automation.Problem StatementOne of the most common requests we receive from multiple customers is for a mechanism that allows email-based approval without the need to manually log into the My Inbox application.Currently, there is no out-of-the-box capability available to fulfill this requirement. Therefore, we will be developing our own reusable module to address this need.In this three-part blog series, my colleague & BTP Architect @Adwait_Fadnavis  and I will provide insights on how to implement Email-based approval using SAP Build Process Automation capabilities.We have prepared the content for this series in three blogs, where we will be diving deep into Design, Development, and Testing.Blog 1 (This blog) – This blog will focus on the Business process, context, problem statement, end to end development flow, and required prerequisites.Blog 2 This blog will focus on development and will provide a detailed walkthrough of the development process.Blog 3: This blog will focus on complete end-to-end testing, helping to understand the overall objective.Scenario ExplanationIn this scenario, a workflow will be triggered using SAP Build Process Automation, which will send an email notification to the respective approver.“The approver will receive the email notification and can reply to this email with either “Approve” or “Reject.” Based on the response, the corresponding workflow task will be approved or rejected.Important ConsiderationsValid Approver Verification: The approver must be a valid approver, and the email must come from the approver’s registered email address. If the email does not come from the proper approver, or if the response is not “Approved” or “Reject,” the system must send an email back indicating that the response is not valid.Unique Request Number: Each approval request must generate a unique request number. This number will be used to validate the response against the original request, ensuring that the approval or rejection is correctly matched to the corresponding workflow task.End to End Business Process Flow: Streamlining Approval Processes with SAP BPA Email-Based AutomationEnd to End Process Flow : Email based ApprovalWorkflow InitiationThe process begins when an SAP BPA workflow is triggered. This could be due to various business events, such as a purchase order requiring approval.Sending Approval Work Items : Once triggered, the workflow sends approval work items to the approver’s SAP BTP My Inbox. Simultaneously, an email notification is dispatched to the approver.Email Notification Details :The email notification includes essential details like the “workflow instance ID” or “Custom Request Number” in the subject line. This ensures the approver & automation (which will elaborate later) can easily identify the request.Approver’s Response Options: The approver has two options to respond:Log into SAP BTP My Inbox: Approvers can log in and approve or reject the request directly.Email-Based Response: Approvers can reply to the email with “Approve” or “Reject.”Background AutomationAn SAP BPA-based automation runs continuously in the background, monitoring the responses sent by the approver. This automation checks if the response is from a valid approver and corresponds to a valid work item.Updating Work Items: If the response is valid, the automation updates the SAP BPA work item accordingly. This eliminates the need for the approver to log into My Inbox separately, streamlining the process.Completion Notification: Upon completion of the process, an approval email is sent to confirm the outcome. This ensures all stakeholders are informed of the decision.Benefits of Email-Based Approval AutomationEfficiency: Reduces the time required for approvals by allowing responses directly via email.Convenience: Approvers can respond from anywhere without needing to log into the system.Accuracy: Automated monitoring ensures only valid responses are processed, reducing errors.Initial Setup and Configuration for Inbound SMTP-Based ApprovalImplementing an email-based approval system using SAP Build Process Automation (BPA) requires a few essential setup steps. Below steps will walk you through the initial configuration to ensure a smooth and efficient process.Outbound SMTP Destination in SAP Build Process AutomationTo send emails from SAP Build Process Automation to users’ email accounts, you need to configure an outbound SMTP destination. This setup is crucial for enabling the system to dispatch approval email notifications.Inbound SMTP Email ConfigurationFor receiving email responses from approvers, we will use Google for both inbound and outbound SMTP. This setup can also be adapted for Microsoft email or other email services. Here are the key steps:Enable Access for Reading Gmail: Ensure that the Gmail account used for receiving responses has the necessary permissions enabled. For detailed instructions, refer to the relevant  sap documentation.Save Credentials JSON File: After setting up the Google Cloud Platform(GCP), securely save the credentials. These credentials are necessary for the SAP BPA to access and read incoming emails.External User Setup in SAP BPA Control Tower: Complete the configuration for the external user in the SAP BPA Control Tower. This step ensures that the system can correctly route and process incoming emails from approvers.SAP BTP BPA Control Tower Setting Up External Authentication for the Google(Gmail)Desktop Agent Installation and External User configuration (SMTP Inbound)The Desktop Agent must be installed in unattended mode to run background processes efficiently.It is recommended to install the Desktop Agent on a virtual machine to ensure continuous operation. Follow these steps:Desktop Agent Sub Account Setup: Configure the Desktop Agent within the appropriate sub-account.Set to Unattended Mode: For real-time production scenarios, set the Desktop Agent to unattended mode. This setup is crucial for automating the approval process without manual intervention.Configure External User: Ensure that the external user configured in the previous step is correctly set up in the Desktop Agent. This configuration allows the agent to process email responses and update the SAP BPA work items accordingly.Desktop Agent – Registering External AuthenticationBy following these steps, you are all set for robust email-based approval system using SAP BPA, streamlining your approval processes and enhancing efficiency.Design and Development Walkthrough for SMTP Inbound Email-Based Approval Automation Once the initial setup and configuration are complete in the SAP BPA Control Tower and the unattended Desktop Agent is installed & configured, the next step is to design and develop the automation components.Below is a summary of the key components involved in this process. My colleague @Adwait_Fadnavis  will provide a detailed walkthrough in a subsequent blog post.The first step is to create a BPA automation. This involves several key actions:Invoke Google Authentication and Search for New Emails:Authenticate External Gmail: Set up Google authentication to allow the system to access your Gmail account.Search Gmail: Create a step to search for new, unread emails with the appropriate subject and request ID. Ensure that only unread emails are read to avoid processing duplicates.Validate the Approver:Check Valid Approver Validation : Validate that the response is from an authorized approver by reading the subject line for the request number.Fetch Work Item Details: Use the SAP BPA API to retrieve work item details and match the approver. If the approver is not valid or authorized, send an error message.Read the Email Body and Response:Process Response: If the email response contains “Approve” or “OK,” call the SAP BPA API to update the workflow task accordingly.Send Completion Email: Notify Stakeholders: After successfully processing the workflow approval or rejection, send an email notification to inform all relevant parties of the outcome.In the upcoming blog post, @Adwait_Fadnavis  will delve into the development flow in detail and provide valuable insights on how to effectively develop inbound SMTP. Final Development flow chart will look as below:End to End: Development FlowStay tuned for a comprehensive guide that will enhance your understanding and streamline your Development  process.Regards,Mohit Bansal, SAP BTP & S4HANA Architect   Read More Technology Blogs by Members articles 

#SAP

#SAPTechnologyblog

You May Also Like

More From Author