Slide 1

Slide 1 text

1 axelerant.com Mautic Plugin Development using Integration Framework Mohit Aghera, Prateek Jain

Slide 2

Slide 2 text

2 axelerant.com Prateek Jain Director, Consulting & Acquia Services mr_prateekjain prateekjain prateekjain87 Mohit Aghera Technical Architect mohit_rocks mohit-rocks mohitaghera About Us

Slide 3

Slide 3 text

3 axelerant.com Mautic Plugins ● What are Mautic Plugins? ● Why do we need Plugins?

Slide 4

Slide 4 text

4 axelerant.com Integration Framework ● Why do we need Integration Framework? ● Can’t Zapier Zap does all the things?

Slide 5

Slide 5 text

5 axelerant.com Integration Framework ● Definition, Configuration and features ● Webhooks ● Event Listeners ● Filters ● Data Sync ● Authentication

Slide 6

Slide 6 text

6 axelerant.com Bundle Definition & Configuration ● Overview of what we are building - Simple plugin for “Demio Webinar” ● Setup bundle class ● Setup Integration class ○ Define additional attributes like name, icon, display name etc. ● Setup config file

Slide 7

Slide 7 text

7 axelerant.com Key Points for Basic Configuration ● Have a service with proper tags in “Config.php”. ○ mautic.integration ○ mautic.basic_integration ● Other necessary class files for Integrations like ○ DemioIntegration.php ○ DemioBundle.php

Slide 8

Slide 8 text

8 axelerant.com Bundle Definition & Configuration DemioBundle ┣ Assets ┃ ┗ img ┃ ┗ demio.png ┃ ┣ Config ┃ ┗ config.php ┃ ┣ Integration ┃ ┣ Config.php ┃ ┗ DemioIntegration.php ┃ ┗ DemioBundle.php

Slide 9

Slide 9 text

9 axelerant.com Features and Sync Configuration ● Provides information about features of the bundle ● Configuration support. ● Configuration for the object integration

Slide 10

Slide 10 text

10 axelerant.com Bundle Definition & Configuration DemioBundle ┣ Assets ┃ ┗ img ┃ ┗ demio.png ┃ ┣ Config ┃ ┗ config.php ┃ ┣ Integration ┃ ┣ Support ┃ ┃ ┣ ConfigSupport.php ┃ ┃ ┗ SyncSupport.php ┃ ┃ ┃ ┣ Config.php ┃ ┗ DemioIntegration.php ┃ ┗ DemioBundle.php

Slide 11

Slide 11 text

11 axelerant.com Scaffolding for Features and Field Mapping ● Provide form for storing keys and secret key ● Store other configurations depending on requirements ● Provide field mapping for source and destination

Slide 12

Slide 12 text

12 axelerant.com Bundle Definition & Configuration DemioBundle ┣ Assets ┃ ┗ img ┃ ┗ demio.png ┃ ┣ Config ┃ ┗ config.php ┃ ┣ Form ┃ ┗ Type ┃ ┣ ConfigAuthType.php ┃ ┣ ConfigFeaturesType.php ┃ ┣ Integration ┃ ┣ Support ┃ ┃ ┣ ConfigSupport.php ┃ ┃ ┗ SyncSupport.php ┃ ┃ ┃ ┣ Config.php ┃ ┗ DemioIntegration.php ┃ ┗ DemioBundle.php

Slide 13

Slide 13 text

13 axelerant.com Authentication Support ● Options for providing Authentication keys and secret ● Authentication approaches

Slide 14

Slide 14 text

14 axelerant.com Various Authentication Methods ● API Keys ● Basic Auth ● OAuth

Slide 15

Slide 15 text

15 axelerant.com Parameter Based API Keys Authentication ● Parameter based API Authentication ● Use mautic.integrations.auth_provider. api_key service. ● Implements ParameterCredentialsInterface class.

Slide 16

Slide 16 text

16 axelerant.com Header Based API Key Authentication ● Header based API Authentication uses header keys for API ● Use mautic.integrations.auth_provider.api _key service. ● Implements HeaderCredentialsInterface

Slide 17

Slide 17 text

17 axelerant.com Basic Authentication ● Basic Auth uses combination of username and password for authentication ● Use mautic.integrations.auth_provid er.basic_auth service. ● Implements CredentialsInterface

Slide 18

Slide 18 text

18 axelerant.com OAuth Authentication ● OAuth 1 ○ OAuth 1a Two Legged ● OAuth 2 ○ OAuth 2 Two Legged ○ OAuth 2 Three Legged

Slide 19

Slide 19 text

19 axelerant.com OAuth2 Two Legged Authentication ● Also known as “Application-Only Authentication” ● Two step process: ○ Request the access token ○ Use token in next requests

Slide 20

Slide 20 text

20 axelerant.com Authentication DemioBundle ┃ ┣ Config ┃ ┗ config.php ┃ ┣ Connection ┃ ┣ ApiConsumer.php ┃ ┣ Client.php ┃ ┗ Credentials.php ┃ ┣ Form ┃ ┗ Type ┃ ┣ ConfigAuthType.php ┃ ┣ ConfigFeaturesType.php ┃ ┗ DemioEventActivities.php ┃ ┣ Integration ┃ ┣ Support ┃ ┃ ┣ ConfigSupport.php ┃ ┃ ┗ SyncSupport.php ┃ ┃ ┃ ┣ Config.php ┃ ┗ DemioIntegration.php ┃ ┗ DemioBundle.php

Slide 21

Slide 21 text

21 axelerant.com Data Synchronization ● Define field mapping using MappingManualFactory ● Building sync report ● Executing sync order

Slide 22

Slide 22 text

22 axelerant.com Field Mapping ● Ensure that fields are specified in the configuration ● Map Mautic lead fields with API response fields ● Define sync direction

Slide 23

Slide 23 text

23 axelerant.com Sync Field Mapping ● Field Repository ● Fields Sync Direction ● Field Mapping Factory DemioBundle ┣ Assets ┃ ┗ img ┃ ┗ demio.png ┃ ┣ ….Other Files….. ┃ ┣ Sync ┃ ┗ Mapping ┃ ┣ Field ┃ ┃ ┣ Field.php ┃ ┃ ┣ FieldRepository.php ┃ ┃ ┗ MappedFieldInfo.php ┃ ┣ Manual ┃ ┃ ┗ MappingManualFactory.php ┃ ┗ FieldMapping.json ┃ ┣ Integration ┃ ┣ Support ┃ ┃ ┣ ConfigSupport.php ┃ ┃ ┗ SyncSupport.php ┃ ┃ ┃ ┣ Config.php ┃ ┗ DemioIntegration.php ┃ ┗ DemioBundle.php

Slide 24

Slide 24 text

24 axelerant.com Building Sync Report and Running Sync ● Define and implement report builder class ● Identifies objects created and updated between two sync ● Typically we use API to fetch data between two duration ● To Run: php bin/console mautic:integrations:sync demio

Slide 25

Slide 25 text

25 axelerant.com Sync Field and Data Exchange DemioBundle ┣ Assets ┃ ┗ img ┃ ┗ demio.png ┣ ….Other Files….. ┃ ┣ Sync ┃ ┣ DataExchange ┃ ┃ ┣ ReportBuilder.php ┃ ┃ ┣ SyncDataExchange.php ┃ ┃ ┗ ValueNormalizer.php ┃ ┃ ┃ ┗ Mapping ┃ ┃ ┣ Field ┃ ┃ ┃ ┣ Field.php ┃ ┃ ┃ ┣ FieldRepository.php ┃ ┃ ┃ ┗ MappedFieldInfo.php ┃ ┃ ┃ ┃ ┃ ┣ Manual ┃ ┃ ┃ ┗ MappingManualFactory.php ┃ ┃ ┗ FieldMapping.json ┃ ┣ Integration ┃ ┣ Support ┃ ┃ ┣ ….Other Files…. ┃ ┃ ┃ ┣ ….Other Files... ┃ ┗ DemioBundle.php ● ReportBuilder service ● SyncDataExchange services

Slide 26

Slide 26 text

26 axelerant.com Creating and Using Filters for Segments ● We need to segment the users based on various criteria ● Add new filters while creating the segments

Slide 27

Slide 27 text

27 axelerant.com Creating Filters ● Create EventListeners that listens LIST_FILTERS_CHOICES_ON_GE NERATE event. ● Create another service to map filter and related query builder. It listens SEGMENT_DICTIONARY_ON_GE NERATE event. ● Create Query Builder to build and run query. DemioBundle ┣ EventListener ┃ ┣ DemioSegmentFiltersDictionarySubscriber.php ┃ ┗ SegmentFiltersChoiceSubscriber.php ┃ ┣ Form ┃ ┗ Type ┃ ┃ ┣ ….Other Files….. ┣ Integration ┃ ┣ Support ┃ ┃ ┣ ….Other Files…. ┃ ┣ Config.php ┃ ┗ DemioIntegration.php ┃ ┣ Segment ┃ ┗ Query ┃ ┃ ┗ Filter ┃ ┃ ┃ ┗ DemioContactFilterQueryBuilder.php ┃ ┣ Services ┃ ┣ ….Other Files….. ┣ Sync ┃ ┣ ….Other Directories Files….. ┗ DemioBundle.php 3 2 1

Slide 28

Slide 28 text

28 axelerant.com Point Actions ● Use case: Once user attends certain events assign points. ● We can implement this behaviour using event listeners.

Slide 29

Slide 29 text

29 axelerant.com Create Point Actions ● Subscribe PointEvents::POINT_ON_BUILD ● Provide form type class to generate options ● Trigger event from relevant methods DemioBundle ┣ EventListener ┃ ┣ DemioObjectCreator.php ┃ ┣ DemioSegmentFiltersDictionarySubscriber.php ┃ ┣ EventPointsSubscriber.php ┃ ┗ SegmentFiltersChoiceSubscriber.php ┃ ┣ Form ┃ ┗ Type ┃ ┃ ┣ ConfigAuthType.php ┃ ┃ ┣ ConfigFeaturesType.php ┃ ┃ ┗ DemioEventActivities.php ┃ ┣ Segment ┃ ┗ Query ┃ ┃ ┗ Filter ┃ ┃ ┃ ┗ DemioContactFilterQueryBuilder.php ┃ ┣ Services ┃ ┣ DemioContactStore.php ┃ ┣ SyncObjectMapping.php ┃ ┗ SyncObjectProcessor.php ┃ ┗ DemioBundle.php 1 2 3

Slide 30

Slide 30 text

30 axelerant.com Code Repositories and Further Reading Code Repositories: ● Authorization Code Grant Example: https://github.com/mautic/plugin-helloworld /tree/mautic-3-authorization-code-grant-exa mple ● Hello World Plugin: https://github.com/mautic/plugin-helloworld /tree/mautic-3 ● Demio Plugin Discussed in Session: https://github.com/mohit-rocks/DemioBund le Further Reading: ● https://github.com/mautic-inc/plugin-integr ations/wiki/

Slide 31

Slide 31 text

31 axelerant.com Questions??

Slide 32

Slide 32 text

32 axelerant.com Prateek Jain Director, Consulting & Acquia Services mr_prateekjain prateekjain prateekjain87 Mohit Aghera Technical Architect mohit_rocks mohit-rocks mohitaghera About Us