Automation
Guide to automate processes in Sarah using webhooks and integrations
Last updated: 2025-01-26
Sarah allows you to automate processes through webhooks and integrations with platforms like Make and Zapier. This guide will help you create automated workflows to optimize your business.
Basic Concepts
What is Automation?
Automation allows different systems to work together without manual intervention:
- Trigger: Event that starts the workflow
- Action: Action that executes automatically
- Workflow: Sequence of automated steps
Benefits
- ⚡ Time savings: Eliminates repetitive tasks
- 🎯 Accuracy: Reduces human errors
- 📊 Visibility: Improves process tracking
- 🔄 Scalability: Handles more volume without more staff
Automation Platforms
Make (Integromat)
Advantages:
- Intuitive visual interface
- Multiple operations per scenario
- Advanced data transformations
- Free plan available
Ideal for:
- Complex workflows
- Data transformations
- Advanced integrations
Zapier
Advantages:
- Easy to use
- Thousands of connected applications
- Pre-configured templates
- Free plan available
Ideal for:
- Simple integrations
- Quick connections
- Non-technical users
Sarah Webhooks
Inbound (Receive Events)
Sarah can receive events from external systems:
Endpoint:
POST /api/integration/in
Use:
- Update products from external systems
- Create sales from external orders
- Sync inventory
Outbound (Send Events)
Sarah can send events to external systems:
Endpoint:
POST /api/integration/out
Use:
- Notify new sales
- Update external systems
- Send alerts
Common Use Cases
1. Sync Products from Shopify
Goal: Keep products synchronized between Shopify and Sarah
Workflow:
- Trigger: New product in Shopify
- Action: Send webhook to Sarah (
product.upserted) - Result: Product created/updated in Sarah
Configuration in Make:
Shopify (Trigger) → HTTP Request (Action)
- URL: https://sarah.ar/api/integration/in
- Method: POST
- Headers: Authorization: Bearer <integration-key>
- Body: {
"event": "product.upserted",
"data": { "product": {...} }
}
2. Notify Sales in Slack
Goal: Receive notifications in Slack when a sale is created
Workflow:
- Trigger: Sarah sends
sales.createdevent - Action: Make/Zapier receives webhook
- Action: Send message to Slack
- Result: Notification in Slack channel
Configuration in Zapier:
Webhook (Trigger) → Slack (Action)
- Webhook URL: https://your-zapier-webhook.com
- Filter: event = "sales.created"
- Slack: Send Channel Message
3. Update Inventory in Google Sheets
Goal: Maintain an inventory record in Google Sheets
Workflow:
- Trigger: Sarah sends
product.stock_updatedevent - Action: Make/Zapier receives webhook
- Action: Update row in Google Sheets
- Result: Spreadsheet updated
4. Send Email when Invoice is Issued
Goal: Send invoice by email automatically
Workflow:
- Trigger: Sarah sends
invoice.issuedevent - Action: Make/Zapier receives webhook
- Action: Send email with attached invoice
- Result: Customer receives invoice by email
5. Create Order in Sarah from WooCommerce
Goal: Create sales in Sarah when there are orders in WooCommerce
Workflow:
- Trigger: New order in WooCommerce
- Action: Send webhook to Sarah (
sales.created) - Result: Sale created in Sarah
6. Alert Low Stock in Discord
Goal: Receive alerts when stock is low
Workflow:
- Trigger: Sarah sends
product.stock_updatedevent - Filter: If
current_stock < 10 - Action: Send message to Discord
- Result: Alert in Discord channel
Step-by-Step Configuration
Step 1: Get Integration Key
- Log in to Sarah
- Go to Settings > Integrations
- Copy your Integration Key
- Save it securely
Step 2: Configure Webhook in Make/Zapier
In Make
- Create a new scenario
- Add Webhooks > Custom webhook module
- Copy the Webhook URL
- Configure this URL in Sarah (environment variable
MAKER_WH_URL)
In Zapier
- Create a new Zap
- Choose Webhooks by Zapier > Catch Hook
- Copy the Webhook URL
- Configure this URL in Sarah
Step 3: Configure Security (Optional but Recommended)
HMAC Signature
- In Sarah: Configure
MAKER_WH_HMAC_SECRET - In Make/Zapier: Validate
x-signatureheader
Validation example:
javascriptconst signature = request.headers['x-signature'];
const expected = hmacSha256(secret, rawBody);
if (signature !== expected) {
// Reject request
}
Step 4: Test Workflow
- Trigger an event: Create a sale or update a product
- Verify webhook: Check that Make/Zapier receives the event
- Verify action: Confirm action executes correctly
- Adjust if necessary: Refine workflow as needed
Best Practices
1. Idempotency
Always use x-idempotency-key to avoid duplicate processing:
javascriptconst idempotencyKey = request.headers['x-idempotency-key'];
if (await isProcessed(idempotencyKey)) {
return; // Already processed
}
await processEvent(event, data);
await markProcessed(idempotencyKey);
2. Error Handling
Implement robust error handling:
- Retries: Retry failed requests
- Logging: Log all errors
- Alerts: Notify critical errors
- Fallbacks: Have alternative plans
3. Validation
Validate all data before processing:
- Structure: Verify data has correct structure
- Types: Validate data types
- Ranges: Verify values within valid ranges
4. Performance
Optimize your workflows:
- Early filters: Filter unnecessary events as early as possible
- Async processing: Don't block the webhook
- Rate limiting: Respect rate limits
- Caching: Cache data that doesn't change frequently
5. Security
Protect your integrations:
- HTTPS always: Never use HTTP
- HMAC signatures: Validate data integrity
- Secure tokens: Never expose tokens publicly
- Replay protection: Validate timestamps
Troubleshooting
Webhook doesn't arrive
- Verify URL: Ensure it's correct and accessible
- Review logs: Look for errors in Sarah
- Test manually: Send a test event
- Verify configuration: Review environment variables
Duplicate events
- Implement idempotency: Use
x-idempotency-key - Verify retries: Ensure there are no unnecessary retries
- Review logs: Identify source of duplicates
Processing errors
- Review structure: Verify data is correct
- Validate permissions: Ensure you have necessary permissions
- Review logs: Look for specific errors
- Test incrementally: Test each step of the workflow
Additional Resources
- Webhooks Inbound - Receive events
- Webhooks Outbound - Send events
- Make and Zapier - Detailed configuration
- Event Reference - All available events
Support
If you need help with automation:
- Review this guide and webhook documentation
- Verify configuration in Sarah and Make/Zapier
- Review logs to identify errors
- Contact Sarah support with problem details