Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Mautic Plugin Development using Integration Framework

Mautic Plugin Development using Integration Framework

Mautic Plugin Development using Integration Framework - MautiCon 2020

E699d3eb01633cd53d59cdd28c1c252d?s=128

Mohit Aghera

November 17, 2020
Tweet

Transcript

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

    Prateek Jain
  2. 2 axelerant.com Prateek Jain Director, Consulting & Acquia Services mr_prateekjain

    prateekjain prateekjain87 Mohit Aghera Technical Architect mohit_rocks mohit-rocks mohitaghera About Us
  3. 3 axelerant.com Mautic Plugins • What are Mautic Plugins? •

    Why do we need Plugins?
  4. 4 axelerant.com Integration Framework • Why do we need Integration

    Framework? • Can’t Zapier Zap does all the things?
  5. 5 axelerant.com Integration Framework • Definition, Configuration and features •

    Webhooks • Event Listeners • Filters • Data Sync • Authentication
  6. 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
  7. 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
  8. 8 axelerant.com Bundle Definition & Configuration DemioBundle ┣ Assets ┃

    ┗ img ┃ ┗ demio.png ┃ ┣ Config ┃ ┗ config.php ┃ ┣ Integration ┃ ┣ Config.php ┃ ┗ DemioIntegration.php ┃ ┗ DemioBundle.php
  9. 9 axelerant.com Features and Sync Configuration • Provides information about

    features of the bundle • Configuration support. • Configuration for the object integration
  10. 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
  11. 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
  12. 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
  13. 13 axelerant.com Authentication Support • Options for providing Authentication keys

    and secret • Authentication approaches
  14. 14 axelerant.com Various Authentication Methods • API Keys • Basic

    Auth • OAuth
  15. 15 axelerant.com Parameter Based API Keys Authentication • Parameter based

    API Authentication • Use mautic.integrations.auth_provider. api_key service. • Implements ParameterCredentialsInterface class.
  16. 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
  17. 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
  18. 18 axelerant.com OAuth Authentication • OAuth 1 ◦ OAuth 1a

    Two Legged • OAuth 2 ◦ OAuth 2 Two Legged ◦ OAuth 2 Three Legged
  19. 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
  20. 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
  21. 21 axelerant.com Data Synchronization • Define field mapping using MappingManualFactory

    • Building sync report • Executing sync order
  22. 22 axelerant.com Field Mapping • Ensure that fields are specified

    in the configuration • Map Mautic lead fields with API response fields • Define sync direction
  23. 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
  24. 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
  25. 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
  26. 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
  27. 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
  28. 28 axelerant.com Point Actions • Use case: Once user attends

    certain events assign points. • We can implement this behaviour using event listeners.
  29. 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
  30. 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/
  31. 31 axelerant.com Questions??

  32. 32 axelerant.com Prateek Jain Director, Consulting & Acquia Services mr_prateekjain

    prateekjain prateekjain87 Mohit Aghera Technical Architect mohit_rocks mohit-rocks mohitaghera About Us