Integration
Integration steps connect Logic Flows with external systems and services, enabling you to call REST APIs and send communications.
Call REST API
Invokes an external REST API endpoint through a configured Service Connection.
| Parameter | Description |
|---|---|
| Service Connection | The configured connection to use |
| Operation | The API operation to call (defined in the Service Connection) |
| Request Parameters | Input values to send with the request |
| Response Mapping | How to map the API response to flow variables |
Returns: The API response data mapped according to the configuration
Example - GET Request:
CALL REST API
Service Connection: StripePayments
Operation: GetCustomer
Request Parameters:
customerId: Customer.StripeId
Response Mapping:
→ Store response in variable: StripeCustomer
Example - POST Request:
CALL REST API
Service Connection: ShippingProvider
Operation: CreateShipment
Request Parameters:
orderId: Order.OrderNumber
address: {
street: Order.ShippingStreet,
city: Order.ShippingCity,
postalCode: Order.ShippingPostalCode,
country: Order.ShippingCountry
}
weight: Order.TotalWeight
Response Mapping:
→ TrackingNumber = response.trackingNumber
→ EstimatedDelivery = response.estimatedDeliveryDate
Handling API Responses
The Call REST API step can handle different response scenarios:
Success Response:
CALL REST API
Service Connection: PaymentGateway
Operation: ProcessPayment
...
→ Store in variable: PaymentResult
CONDITION: Payment Successful?
Condition: PaymentResult.status == "success"
TRUE BRANCH:
→ Update Order.PaymentStatus = "Paid"
FALSE BRANCH:
→ Update Order.PaymentStatus = "Failed"
→ Log PaymentResult.errorMessage
Error Handling:
CALL REST API
Service Connection: ExternalCRM
Operation: SyncContact
...
→ Store in variable: SyncResult
→ Store HTTP Status in variable: HttpStatus
CONDITION: Request Failed?
Condition: HttpStatus >= 400
TRUE BRANCH:
→ Create error log record
→ RAISE ERROR: "External sync failed: " + SyncResult.error
Service Connections are configured separately and define the base URL, authentication, and available operations for an external API. See Service Connections documentation for details on setting up connections.
Send Email
Sends an email message through Dynamics 365.
| Parameter | Description |
|---|---|
| Email ID | The ID of the email record to send |
The Send Email step sends an existing email record that has been created and populated with recipients, subject, and body.
Example - Send Existing Email:
# First, create the email record
SAVE ENTITY
Entity: Email
Data: {
Subject: "Order Confirmation - " + Order.OrderNumber,
Description: EmailBodyContent,
To: [{
EntityType: "contact",
Id: Customer.PrimaryContactId
}],
From: [{
EntityType: "systemuser",
Id: CurrentUser.Id
}],
Regarding: Order
}
→ Store in variable: ConfirmationEmail
# Then send it
SEND EMAIL
Email ID: ConfirmationEmail.Id
Building Dynamic Emails
Using Templates:
# Get email template
EXECUTE QUERY
Entity: Template
Conditions: TemplateType == "Email" AND Name == "OrderConfirmation"
→ Store in variable: EmailTemplate
# Create email from template with merged data
SAVE ENTITY
Entity: Email
Data: {
Subject: REPLACE(EmailTemplate.Subject, "{OrderNumber}", Order.OrderNumber),
Description: REPLACE(
REPLACE(EmailTemplate.Body, "{CustomerName}", Customer.Name),
"{OrderTotal}", FORMAT(Order.TotalAmount, "C")
),
To: [{ EntityType: "contact", Id: Customer.PrimaryContactId }],
Regarding: Order
}
→ Store in variable: MergedEmail
SEND EMAIL
Email ID: MergedEmail.Id
Sending to Multiple Recipients:
# Get all contacts for the account
EXECUTE QUERY
Entity: Contact
Conditions: ParentCustomerId == Account.Id AND ReceiveEmails == true
→ Store in variable: Recipients
# Build recipient list
NEW VARIABLE: ToList (List of Party)
ITERATOR: Build Recipient List
Collection: Recipients
Item Variable: Contact
Steps:
UPDATE VARIABLE
Variable: ToList
Set Variable: APPEND(ToList, { EntityType: "contact", Id: Contact.Id })
# Create and send email
SAVE ENTITY
Entity: Email
Data: {
Subject: "Important Account Update",
Description: EmailContent,
To: ToList,
Regarding: Account
}
→ Store in variable: BulkEmail
SEND EMAIL
Email ID: BulkEmail.Id
Best Practices
Handle API Failures Gracefully: External APIs can fail. Always check response status and have error handling in place.
Use Timeouts Wisely: Be aware that API calls may take time. Design flows to handle slow responses appropriately.
Secure Sensitive Data: Never log or store sensitive data like API keys, passwords, or payment details in plain text.
Respect Rate Limits: External APIs often have rate limits. If processing many records, consider adding delays or batching.
Test with Sandbox Environments: When integrating with payment or other critical systems, test thoroughly in sandbox/test environments first.
Log Integration Activity: Create audit records for important API calls to help with troubleshooting and compliance.