Type aliases
CRM_Marketing_Action
Action performed by the system after processing the notification from the email marketing service.
Action performed by the system after processing the notification from the email marketing service.
Integration with email marketing services
The Marketing workspace is a part of the CRM system solution. It is used to organize email campaigns and manage client database directly in the system interface. You can use the Marketing workspace to:
with an email marketing service. You can use a ready-made integration module from the store or configure an integration using a custom module.
This section describes the entities of the Marketing workspace and a list of function you need to implement in your custom module to set up integration. Before configuring a custom integration module, we recommend that you read more about custom modules.
Create an integration module
To set up integration with an email marketing service, you first need to create a custom module. Then open the API Methods tab, click Edit and go to Scripts. Insert the following template:
Implement the functions described above, save the module, and enable it. Now when a new campaign is created using the system interface, you will be able to choose your integration module in the Email service field.//Import email templates from the email marketing service to the system // Called by the system automatically, for example, when a user clicks the template import button in the system interface // - `offset` is the number of template to skip from the start when importing them from the service // - `limit` is the maximum amount of templates to import // By default, the function is called with `offset` equal to 0 // If more than `limit` templates need to be returned in the function, you need to return the array of `limit` templates // After that, the system will process the obtained templates and call this function again with `offset` equal to ` offset + limit` async function CRM_Marketing_ImportTemplates( offset: number, limit: number, ): Promise<CRM_Marketing_ImportTemplate[]> { throw new Error('not implemented'); } // Synchronize the list of subscribers in the system with the list in the email marketing service // The function is called by the system automatically, for example, before a newsletter is sent from the system to the external service // ` contactIds` is an array with IDs of app items from the Contacts app in the CRM workspace that need to be synced with the service async function CRM_Marketing_ExportContacts(contactIds: string[]): Promise<void> { throw new Error('not implemented'); } // Prepare data to send the newsletter, for example, add subscribers to the list of email campaigns // This function is called by the system before an email campaign is created ( before the `CRM_Marketing_CreateCampaign` function is called) // If the newsletter is going to be sent to a lot of subscribers, this function is called several times // The `contacts` argument will include a part of the full list of subscribers // - `campaignId` is the ID of an of the Email campaigns app item that will be created in the system // - `campaignType` is the type of campaign // - `contacts` is an array containing email addresses or phone numbers, depending on the campaign type async function CRM_Marketing_PrepareCampaign( campaignId: string, type: CRM_Marketing_CampaignType, contacts: string[], ): Promise<void> { throw new Error('not implemented'); } // Create a newsletter in the email marketing service // This function is called after an email campaign is created in the system // Before it is called, the campaign data is passed to the `CRM_Marketing_PrepareCampaign` function // If the function is successfully executed, a new Email campaigns app item is created // It is used to track the status of the campaign in the system // - `request` is information about the campaign async function CRM_Marketing_CreateCampaign( request: CRM_Marketing_CreateCampaignRequest, ): Promise<CRM_Marketing_CreateCampaignResponse> { throw new Error('not implemented'); } // Get statistics on an email campaign // This function is called automatically when a user views statistics of a campaign in the system // The result of calling the function can be cached by the system // - `campaignExternalId` is the ID of the campaign in the email marketing service async function CRM_Marketing_GetCampaignStats( campaignExternalId: string, ): Promise<CRM_Marketing_CampaignStats> { throw new Error('not implemented'); } // Process an event from the email marketing service // This function is called then an HTTP request is received to the webhook specified in the custom module’s settings // The body of the function needs to transform events of the email marketing service you’re using // into a list of actions that the system will perform when the function’s execution is finished // For example, this can be updating the campaign status or email delivery status // - `request` is the data of the HTTP request received to the webhook async function CRM_Marketing_ParseWebhookRequest(request: FetchRequest): Promise<CRM_Marketing_WebhookResult> { throw new Error('not implemented'); } // Get HTML code to preview a template’s content // This function is called from the system interface by the template preview widget // The result of executing the function can be cached // - `templateExternalId` is the ID of the template in the email marketing campaign service async function CRM_Marketing_GetTemplateHTML(templateExternalId: string): Promise<string> { throw new Error('not implemented'); } // Set the HTML code for the template content. Used when the template is published. // The function must return the template ID in the mailing service. // - `html` is the template content. // - `name` is the template name. // - `templateExternalId` is the template ID in the mailing service. May be empty if the template is new. async function CRM_Marketing_SetTemplateHTML(html: string, name: string, templateExternalId?: string): Promise<string> { throw new Error('not implemented'); }