Microsoft Dynamics 365 Integration
Connect Ledly to Microsoft Dynamics 365 to automatically sync leads. This guide walks you through registering an Azure AD application and authorizing Ledly.
Dynamics 365 uses the native Lead entity. Ledly syncs directly to the lead entity using the OData 4.0 Web API.
Prerequisites
- Microsoft Dynamics 365 Sales license
- Azure Active Directory (Azure AD) admin access
- Dynamics 365 System Administrator or Customizer role
- Ledly Education or Enterprise plan
Step 1: Register an Azure AD Application
- Go to the Azure Portal
- Navigate to Azure Active Directory -> App registrations
- Click New registration
Application Registration
| Field | Value |
|---|---|
| Name | Ledly Integration |
| Supported account types | Accounts in this organizational directory only |
| Redirect URI (Web) | https://api.ledly.io/api/dynamics/callback |
- Click Register
Step 2: Configure API Permissions
- On your app registration page, click API permissions
- Click Add a permission
- Select Dynamics CRM
- Select Delegated permissions
- Check
user_impersonation - Click Add permissions
- Click Grant admin consent for [Your Organization]
Admin consent is required. Without it, users will see an “Access Denied” error when connecting.
Step 3: Create a Client Secret
- On your app registration page, click Certificates & secrets
- Click New client secret
- Enter a description:
Ledly Integration Secret - Select an expiration period (recommended: 24 months)
- Click Add
- Immediately copy the secret value - it won’t be shown again
Security Note: Copy the secret value now. After leaving this page, you cannot retrieve it. You’ll need to create a new secret if lost.
Step 4: Get Your Application Details
Collect these values from your Azure AD app registration:
| Field | Location |
|---|---|
| Application (client) ID | Overview page |
| Directory (tenant) ID | Overview page |
| Client Secret | Certificates & secrets (copied in Step 3) |
| Dynamics URL | Your Dynamics environment URL (e.g., https://yourorg.crm.dynamics.com) |
Finding Your Dynamics URL
- Log in to Power Platform Admin Center
- Go to Environments
- Select your environment
- Copy the Environment URL
Step 5: Configure Application User in Dynamics
For server-to-server authentication, create an Application User:
- Go to your Dynamics 365 environment
- Navigate to Settings -> Security -> Users
- Switch the view to Application Users
- Click New
| Field | Value |
|---|---|
| User Name | [email protected] |
| Application ID | Your Azure AD Application (client) ID |
| Full Name | Ledly Integration |
| Primary Email | [email protected] |
- Click Save
- Click Manage Roles
- Assign the Salesperson role (or a custom role with Lead permissions)
The Application User allows Ledly to authenticate without a specific user’s credentials, providing more reliable server-to-server integration.
Step 6: Enter Credentials in Ledly
- Log in to Ledly at app.ledly.io
- Go to Settings -> CRM Integration
- Select Microsoft Dynamics 365 as your CRM
- Enter your credentials:
| Field | Value |
|---|---|
| Tenant ID | Your Azure AD Directory (tenant) ID |
| Client ID | Your Azure AD Application (client) ID |
| Client Secret | Your client secret |
| Dynamics URL | Your environment URL (e.g., https://yourorg.crm.dynamics.com) |
- Click Save Credentials
- Click Connect with Dynamics 365
- Sign in with your Microsoft account when prompted
Once connected, you’ll see the connection status and your Dynamics organization ID on the CRM settings page.
Step 7: Map Fields to Dynamics
After connecting, configure how Ledly fields map to your Dynamics Lead entity.
- Go to Settings -> CRM Integration -> Field Mapping
- For each Ledly field, select the corresponding Dynamics field
- Click Save Mapping
Standard Field Mappings
| Ledly Field | Dynamics Lead Field | Schema Name |
|---|---|---|
email | Email | emailaddress1 |
first_name | First Name | firstname |
last_name | Last Name | lastname |
phone | Business Phone | telephone1 |
company | Company Name | companyname |
job_title | Job Title | jobtitle |
address | Street 1 | address1_line1 |
city | City | address1_city |
state | State/Province | address1_stateorprovince |
zip | ZIP/Postal Code | address1_postalcode |
country | Country/Region | address1_country |
Lead Status Mapping
Ledly maps lead statuses to Dynamics Lead State and Status:
| Ledly Status | Dynamics State | Dynamics Status Reason |
|---|---|---|
new | Open | New |
contacted | Open | Contacted |
qualified | Qualified | Qualified |
disqualified | Disqualified | Lost |
Custom Field Mappings
Map Ledly custom fields to your Dynamics custom fields:
| Ledly Field | Dynamics Field | Schema Name |
|---|---|---|
program_code | Program Interest | new_programinterest |
start_date | Preferred Start Date | new_preferredstartdate |
utm_source | Lead Source Detail | new_leadsourcedetail |
Field mapping must be configured before leads will sync to Dynamics. Unmapped fields will not be sent.
For detailed mapping options, see the Field Mapping Guide.
Bidirectional Sync
Ledly supports bidirectional sync with Dynamics 365, keeping data consistent across both platforms.
Ledly to Dynamics
When a lead is created or updated in Ledly:
- Ledly checks if a Lead with matching email exists in Dynamics
- If found, the existing Lead is updated
- If not found, a new Lead is created
- A custom
ledly_leadidfield stores the Ledly ID for tracking
Dynamics to Ledly
When a Lead is updated in Dynamics:
- Dynamics sends a webhook notification via Power Automate
- Ledly matches the Lead by
ledly_leadidor email - Mapped fields are updated in Ledly
- Conflict resolution uses “last write wins” by default
Sync Frequency
| Direction | Trigger | Latency |
|---|---|---|
| Ledly -> Dynamics | Immediate on save | < 5 seconds |
| Dynamics -> Ledly | Webhook (Power Automate) | < 30 seconds |
| Full sync | Scheduled | Every 4 hours |
Status Tracking
Ledly tracks the sync status for each lead:
| Status | Description |
|---|---|
synced | Successfully synced to Dynamics |
pending | Queued for sync |
failed | Sync failed (see error details) |
not_mapped | No field mapping configured |
View sync status in Ledly:
- Go to Leads -> Select a lead
- Click the CRM Sync tab
- View sync history and any error messages
Webhook Configuration (Power Automate)
For real-time updates from Dynamics to Ledly, set up a Power Automate flow:
Step 1: Create a Power Automate Flow
- Go to Power Automate
- Click Create -> Automated cloud flow
- Name your flow:
Ledly Lead Sync - Select trigger: When a row is added, modified or deleted (Microsoft Dataverse)
Step 2: Configure the Trigger
| Field | Value |
|---|---|
| Change type | Added or Modified |
| Table name | Leads |
| Scope | Organization |
Step 3: Add HTTP Action
- Click New step
- Search for HTTP
- Configure the action:
| Field | Value |
|---|---|
| Method | POST |
| URI | https://api.ledly.io/api/dynamics/webhook |
| Headers | Content-Type: application/json |
| Body | See below |
Webhook Body:
{
"leadid": "@{triggerOutputs()?['body/leadid']}",
"emailaddress1": "@{triggerOutputs()?['body/emailaddress1']}",
"firstname": "@{triggerOutputs()?['body/firstname']}",
"lastname": "@{triggerOutputs()?['body/lastname']}",
"telephone1": "@{triggerOutputs()?['body/telephone1']}",
"modifiedon": "@{triggerOutputs()?['body/modifiedon']}"
}Step 4: Add Authentication Header
-
In the HTTP action, expand Advanced options
-
Add header:
X-Ledly-Webhook-Secret -
Value: Your Ledly webhook secret (found in Settings -> Webhooks)
-
Click Save
Power Automate flows may have execution limits based on your Microsoft 365 license. For high-volume scenarios, consider using Azure Functions.
Rate Limits
Dynamics 365 enforces API rate limits that Ledly respects:
| Limit Type | Value |
|---|---|
| Per user | 6,000 requests per 5 minutes |
| Per organization | 60,000 requests per 5 minutes |
| Concurrent requests | 52 per user |
Large bulk imports may be throttled. Use Ledly’s batch import feature which automatically handles rate limiting.
Token Expiration
- Access tokens expire after 1 hour
- Ledly automatically refreshes tokens before expiration
- Refresh tokens expire after 90 days of inactivity
Troubleshooting
”AADSTS700016: Application Not Found” Error
- Verify the Application (client) ID is correct
- Ensure the app registration is in the correct Azure AD tenant
- Check that the app hasn’t been deleted
”AADSTS65001: User Consent Required” Error
- Admin consent hasn’t been granted for the app
- Go to Azure AD -> App registrations -> API permissions
- Click Grant admin consent
”Unauthorized” or “403 Forbidden” Error
- The Application User may not have the correct security role
- Verify the user has the Salesperson role or Lead permissions
- Check that the user is enabled in Dynamics
”Resource Not Found” Error
- Verify the Dynamics URL is correct (no trailing slash)
- Ensure you’re using the correct environment URL
- Check that the Lead entity exists and is accessible
Leads Not Syncing
- Check that field mapping is configured
- Verify the Application User has Lead create/update permissions
- Check the lead’s CRM Sync tab for error details
- Ensure Dynamics API limits haven’t been exceeded
Token Refresh Failures
- Client Secret may have expired
- Create a new secret in Azure AD and update in Ledly
- Check that the app registration hasn’t been modified
Power Automate Flow Errors
- Check the flow run history for errors
- Verify the HTTP action URL is correct
- Ensure the webhook secret header is included
- Check that required fields are included in the body
Security Best Practices
- Rotate client secrets - Azure AD secrets expire. Create a new secret before expiration and update in Ledly
- Use least privilege - Grant only the permissions Ledly needs
- Monitor sign-in logs - Review Azure AD sign-in logs for unusual activity
- Enable conditional access - Consider restricting app access to specific IP ranges
- Revoke if compromised - If credentials are exposed, immediately regenerate the client secret
Revoking Access
In Ledly
- Go to Settings -> CRM Integration
- Click Disconnect
In Azure AD
- Go to the Azure Portal
- Navigate to Azure Active Directory -> App registrations
- Find
Ledly Integration - Click Delete
In Dynamics 365
- Go to Settings -> Security -> Users
- Switch view to Application Users
- Find and disable or delete the Ledly Application User
Support
If you encounter issues:
- Email: [email protected]
- Include your Dynamics organization ID (Settings -> Customizations -> Developer Resources)
- Include your Azure AD tenant ID
- Do NOT send credentials via email