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:

  • Send newsletters to groups of clients, for example, inform them about new prices of products or services, sales, webinars, etc.
  • Organize long-term customer support: send news, updates, etc.
  • Determine how active and engaged your customers are in relation with your product or service. To send emails from the Marketing workspace, you need to set up integration
    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 functions 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:
    //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'); 
    } 
    // Get HTML code to preview a  template’s content. It 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'); 
    } 
    // Get HTML code of the template  content. It is called during template publication 
    // The function returns  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. It can be null if the template is  new 
    async function CRM_Marketing_SetTemplateHTML(html: string, name:  string, templateExternalId?: string): Promise<string> { 
    throw new Error( 'not implemented'); 
    } 
    
    Implement the functions described above, save the module, and enable it When creating a new email campaign via the system interface, you can choose your integration in the Email service field.

    Create a messenger integration module

    To set up integration with a messenger, you first need to [create a custom module]( https://brix365.com/en/help/ platform/create-extention.html). Then open the API Methods > Scripts page and insert
    the following template:
    // Prepare data for sending  newsletter, e. g., add subscribers to the campaign list. The function is  called before creating a campaign 
    // (before calling  `CRM_Marketing_CreateMessengerCampaign` function) 
    // 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 the Email campaigns app item  created in the system; 
    // - `campaignType` is the type of campaign; 
    // -  `contacts` is an array containing IDs of the contacts 
    async function  CRM_Marketing_PrepareCampaign( 
    campaignId: string, 
    type:  CRM_Marketing_CampaignType, 
    contacts: string[], 
    ): Promise<void> { 
    throw new Error('not implemented'); 
    } 
    // Create a message in the  messenger. This function is called after a 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 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_CreateMessengerCampaign( 
    request: CRM_Marketing_CreateMessengerCampaignRequest, 
    ):  Promise<CRM_Marketing_CreateCampaignResponse> { 
    throw new Error('not  implemented'); 
    } 
    // Get statistics on a 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 
    async function  CRM_Marketing_GetCampaignStats( 
    campaignExternalId: string, 
    ):  Promise<CRM_Marketing_CampaignStats> { 
    throw new Error('not implemented');  
    } 
    // Process an event from the messenger. This function is called when 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  messenger 
    // 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 message 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');  
    } 
    // Returns messenger types where the campaign is performed 
    // The type  of the created campaign is specified in the  `CRM_Marketing_CreateMessengerCampaign` function 
    // in the `request. campaignType` 
    function CRM_Marketing_GetMessengerTypes(): AccountType[] { 
    throw new Error('not implemented'); 
    } 
    // Get data about available bots and  groups of the messenger for campaign 
    // - `request` is campaign data 
    async  function CRM_Marketing_GetMessengerBots():  Promise<CRM_Marketing_MessengerBot[]> { 
    throw new Error('not implemented');  
    } 
    
    Implement the function body using the template above, save the module, and enable it. Now in the Messenger activity of the customer journey maps, you can select you integration in the Campaign module field. Ψ The Marketing workspace is a part of the CRM system solution. It is used to send campaigns and manage your customer base from the system interface. With the Marketing workspace, you can:
  • Send bulk campaigns to specific customer groups, such as notifications about product
    or service price changes, promotions, webinars, etc.
  • Implement long-term customer support: send news, notify about updates, etc.
  • Determine customer activity and their interest in a product or service. To send emails through the Marketing workspace, you must connect the integration module with the mailing service. Integrations can be imported or you can create your own integration using a custom module. This workspace describes the entities in the Marketing workspace and functions that need to be implemented in the custom module to create your own integration. Before creating your own integration, we recommend to read the articles about the Marketing workspace and custom modules.

    Creating an Integration Module

    To create your own integration with the mailing service, you first need to [create a custom module]( https://brix365 .com/en/help/platform/create-extention.html). Next, go to API Methods > Scripts and paste
    the following code into the code editor:
    // Import email  templates from the mailing list service into the system. Called  automatically, e. g., 
    // by the template import button in the system  interface. 
    // - `offset` is the offset starting from which templates should  be taken from the mailing service. 
    // - `limit` is the maximum number of  templates to get. 
    // The function is initially called with `offset = 0`. If  you need to get more templates using the function, 
    // than specified in  `limit`, you must return an array of `limit` items. After that, the system  processes 
    // the received templates, and this function is called again with  the `offset` value equal to `offset + limit`. 
    async function  CRM_Marketing_ImportTemplates( 
    offset: number, 
    limit: number, 
    ):  Promise<CRM_Marketing_ImportTemplate[]> { 
    throw new Error('not  implemented'); 
    } 
    // Synchronize subscribers from the system with the  mailing service. Called automatically, e. g., 
    // before sending a mailing  list from the system interface to the mailing service. 
    // - `contactIds` is  an array of identifiers of the Contacts app items from the CRM workspace  that need to be 
    // synchronized with the mailing service. 
    async function  CRM_Marketing_ExportContacts(contactIds: string[]): Promise<void> { 
    throw  new Error('not implemented'); 
    } 
    // Prepare data for sending the mailing  list, for example, add subscribers to the mailing list. Called before  creating the mailing list 
    // (before calling the  `CRM_Marketing_CreateCampaign` function). 
    // If the newsletter is sent to a  large number of subscribers, this function is called multiple times, and the  `contacts` argument 
    // contains a part of the entire subscriber list. 
    // -  `campaignId` is the identifier of the Campaigns app items that will be  created in the system; 
    // - `campaignType` is the campaign type; 
    // -  `contacts` is an array of email addresses. 
    async function  CRM_Marketing_PrepareCampaign( 
    campaignId: string, 
    type:  CRM_Marketing_CampaignType, 
    contacts: string[], 
    ): Promise<void> { 
    throw new Error('not implemented'); 
    } 
    // Create an email newsletter on the  mailing service side. This function is called after the newsletter is  created from the 
    // system interface. Before calling this function, the  data for the mailing list is passed to the `CRM_Marketing_PrepareCampaign`  function. 
    // If the function is successfully executed, the Campaigns app  item will be created, which is used 
    // to track the mailing list status on  the system side. 
    // - `request` is information about the campaign being  sent. 
    async function CRM_Marketing_CreateCampaign( 
    request:  CRM_Marketing_CreateCampaignRequest, 
    ):  Promise<CRM_Marketing_CreateCampaignResponse> { 
    throw new Error('not  implemented'); 
    } 
    // Get mailing list statistics. The function is called  automatically when viewing mailing list statistics from the 
    // system  interface. The function result can be temporarily cached by the system. 
    // -  `campaignExternalId` is mailing list identifier on the mailing service  side. 
    async function CRM_Marketing_GetCampaignStats( 
    campaignExternalId:  string, 
    ): Promise<CRM_Marketing_CampaignStats> { 
    throw new Error('not  implemented'); 
    } 
    // Process the event from the mailing service. This  function is called upon receiving an HTTP request for the webhook, 
    // which  is specified in the custom module settings. In the body of this function, it  is necessary to convert the events 
    // of a specific mailing service into a  list of actions that the system performs upon completion of the function 
    //  (for example, updating statuses of the mailing or the status of sending an  email to a subscriber). 
    // `request` is data of the HTTP request received  by the webhook. 
    async function CRM_Marketing_ParseWebhookRequest(request:  FetchRequest): Promise<CRM_Marketing_WebhookResult> { 
    throw new Error('not  implemented'); 
    } 
    // Get the HTML code for previewing the template  contents. Called from the system interface by the 
    // template preview  widget. The function result can be temporarily cached by the system. 
    // -  `templateExternalId` is a template identifier in the mailing service. 
    async  function CRM_Marketing_GetTemplateHTML(templateExternalId: string):  Promise<string> { 
    throw new Error('not implemented'); 
    } 
    // Set the HTML  code of the template contents. Called when publishing a template. 
    // The  function must return the template ID in the mailing service. 
    // - `html`is  template contents. 
    // - `name` is a template name. 
    // -  `templateExternalId` is a 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'); 
    } 
    
    Implement the function body from the code template above, save the module and enable it. Now, when you [create a new campaign through the system interface]( https://brix365.com/en/ help/crm/campaigns.html), you can select your integration in the Mailing service field.

    Creating a messenger integration module

    To set up your own integration with a messenger, first create a custom module. Next, go to the [API Methods > Scripts page](https://brix365.com/en/help/platform/ extention-api.html) and paste the following code into the code editor:
    // Prepare data for sending a campaign, for example, add  subscribers to a mailing list. Called before creating a mailing list 
    // ( before calling the `CRM_Marketing_CreateMessengerCampaign` function) 
    // If  the campaign is sent to a large number of subscribers, this function is  called several times, and a part of the entire subscriber list is passed in  the `contacts` argument 
    // - `campaignId` is the identifier of the  Campaigns app item that is created in the system.; 
    // - `campaignType` is  the mailing type. 
    // - `contacts` is an array of contact identifiers 
    async  function CRM_Marketing_PrepareCampaign( 
    campaignId: string, 
    type:  CRM_Marketing_CampaignType, 
    contacts: string[], 
    ): Promise<void> { 
    throw new Error('not implemented'); 
    } 
    // Create a message campaign via  messenger. This function is called after the campaign is created from the 
    //  system interface. Before calling this function, the data for the campaign  is passed to the `CRM_Marketing_PrepareCampaign` function 
    // As a result of  successful execution of the function, the Campaigns app item is created,  which is used 
    // to track the status of the campaign on the system side 
    //  - `request` is information about the sent campaign 
    async function  CRM_Marketing_CreateMessengerCampaign( 
    request:  CRM_Marketing_CreateMessengerCampaignRequest, 
    ):  Promise<CRM_Marketing_CreateCampaignResponse> { 
    throw new Error('not  implemented'); 
    } 
    // Get statistics on the campaign. The function is called  automatically when viewing the statistics on the campaign from the 
    //  system interface. The function result may be temporarily cached by the  system. 
    // - `campaignExternalId` is the campaign ID. 
    async function  CRM_Marketing_GetCampaignStats( 
    campaignExternalId: string, 
    ):  Promise<CRM_Marketing_CampaignStats> { 
    throw new Error('not implemented');  
    } 
    // Process the event from the messenger. This function is called upon  receiving an HTTP request for the webhook, 
    // which is specified in the  custom module settings. In the body of this function, transform events 
    //  from a specific messenger into a list of actions that the system will  perform upon completion of the function 
    // For example, updating the status  of a mailing list or the status of sending a message to a subscriber 
    //  `request` is data from the HTTP request received by the webhook 
    async  function CRM_Marketing_ParseWebhookRequest(request: FetchRequest):  Promise<CRM_Marketing_WebhookResult> { 
    throw new Error('not implemented');  
    } 
    // Returns the messenger types for which campaign is implemented 
    // The  type of campaign being created is specified in the  CRM_Marketing_CreateMessengerCampaign function in the information 
    // about  the mailing list being sent `request.campaignType` 
    function  CRM_Marketing_GetMessengerTypes(): AccountType[] { 
    throw new Error('not  implemented'); 
    } 
    // Get data on messenger bots or communities available  for mailing 
    // - `request` is information about the mailing list 
    async  function CRM_Marketing_GetMessengerBots():  Promise<CRM_Marketing_MessengerBot[]> { 
    throw new Error('not implemented');  
    } 
    
    Implement the function body from the code template above, save the module, and enable it. Now, in the Messenger activity settings of the customer journey maps, you can select your integration in the Mailing module field.

Type aliases

CRM_Marketing_Action

Update data action

Action performed by the system after processing the notification from the email marketing service.