I’ll walk you through a complete solution covering all three critical areas: SAP event subscription, webhook configuration, and RPA event log analysis.
1. SAP Event Subscription Configuration
First, verify your SAP event subscription is configured for guaranteed delivery. In SAP, go to transaction WE20 and check your partner profile for the webhook endpoint:
Partner Type: LS (Logical System)
Message Type: INVOIC
Process Code: MM01 (for MM_INVOICE_CREATE)
Output Mode: 2 (Transfer immediately)
Queue Processing: Enabled
The key is enabling queue processing. This ensures SAP queues events if the endpoint is temporarily unavailable and retries delivery. Without this, events are fire-and-forget.
2. Webhook Endpoint Configuration
In AgilePoint RPA Designer, configure your webhook trigger with these specific settings:
Endpoint Path: /api/rpa/invoice-trigger
Method: POST
Authentication: OAuth 2.0 with refresh token
Timeout: 30 seconds (for acknowledgment)
Payload Validation: Flexible schema mode
Retry Policy: 3 attempts with exponential backoff
Critical change: Switch from static Bearer token to OAuth 2.0 with refresh token. Configure the OAuth settings to automatically refresh tokens every 50 minutes (before the typical 60-minute expiration). This prevents authentication failures.
For the payload validation, use a flexible schema that handles variations:
// Pseudocode - Webhook payload handler:
1. Receive POST request from SAP event subscription
2. Validate required fields only: eventType, invoiceNumber, timestamp
3. Extract all additional fields as optional key-value pairs
4. Log complete payload to RPA event log with correlation ID
5. Immediately return HTTP 200 acknowledgment to SAP (within 5 seconds)
6. Queue bot execution with extracted data as parameters
7. If bot queue is full, store event in fallback database table
// Reference: RPA Designer Guide Section 8.2 - Event-Driven Triggers
The immediate acknowledgment is crucial. Don’t wait for the bot to complete - just queue it and respond to SAP quickly.
3. RPA Event Log Analysis and Monitoring
Implement comprehensive logging to diagnose missing events:
- Enable verbose logging in AgilePoint Admin Portal under RPA Settings
- Create a custom monitoring dashboard that compares SAP event counts with AgilePoint bot execution counts
- Set up an hourly reconciliation job that queries both systems:
SAP Query: SELECT COUNT(*) FROM event_log WHERE event_type='MM_INVOICE_CREATE' AND timestamp > CURRENT_TIMESTAMP - 1 HOUR
AgilePoint Query: SELECT COUNT(*) FROM rpa_execution_log WHERE bot_name='InvoiceProcessor' AND start_time > CURRENT_TIMESTAMP - 1 HOUR
If counts don’t match, trigger an alert with the missing invoice numbers.
4. Handling the 30% Missing Events
For your immediate issue, implement a catch-up mechanism:
- Create a scheduled RPA bot that runs every 15 minutes
- Query SAP for invoices created in the last hour that don’t have a corresponding processing record in AgilePoint
- Manually trigger the invoice processing bot for any missing invoices
- Log these catch-up executions separately for analysis
This provides a safety net while you fix the root cause.
5. Root Cause - Authentication Token Expiration
Based on your 30% failure rate, I suspect your Bearer token expires after a certain period (likely 60 minutes) and SAP continues sending events with the expired token. The authentication fails silently, and SAP’s event log doesn’t show this as a failure because it considers delivery attempted.
To confirm this theory:
- Check if the missing events cluster around specific times of day
- Look for patterns every 60-90 minutes
- Review your webhook logs for authentication errors that might be getting suppressed
Switching to OAuth 2.0 with automatic token refresh will eliminate this issue completely. We implemented this exact solution for a client processing 500+ SAP invoices daily, and the missing event rate dropped from 28% to less than 0.1% (only during actual system outages).
6. Testing and Validation
After implementing these changes:
- Perform a load test by creating 100 invoices rapidly in SAP
- Verify all 100 trigger bot executions
- Simulate webhook endpoint downtime and confirm SAP queues events for retry
- Let the OAuth token expire and verify automatic refresh occurs
Document the success rate over a week to confirm the issue is resolved.