PHPackages                             remp/crm-scenarios-module - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. remp/crm-scenarios-module

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

remp/crm-scenarios-module
=========================

CRM Scenarios Module

4.4.0(5mo ago)246.7k—7.1%1[4 PRs](https://github.com/remp2020/crm-scenarios-module/pulls)1MITPHPPHP ^8.1

Since Nov 29Pushed 5mo ago7 watchersCompare

[ Source](https://github.com/remp2020/crm-scenarios-module)[ Packagist](https://packagist.org/packages/remp/crm-scenarios-module)[ Docs](https://remp2030.com)[ RSS](/packages/remp-crm-scenarios-module/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)DependenciesVersions (72)Used By (1)

CRM Scenarios Module
====================

[](#crm-scenarios-module)

[![Translation status @ Weblate](https://camo.githubusercontent.com/136d185204b340284b821827e67913720e38b52efc509c28b5478f67567bd6df/68747470733a2f2f686f737465642e7765626c6174652e6f72672f776964676574732f72656d702d63726d2f2d2f7363656e6172696f732d6d6f64756c652f7376672d62616467652e737667)](https://hosted.weblate.org/projects/remp-crm/scenarios-module/)

Scenarios module main feature is a scenario builder, a tool for modeling scenarios within CRM system using drag-and-drop UI toolkit. Each scenario is visually represented by a graph, connecting various events (e.g. user registration, subscription) with conditions (e.g. user segment check) and actions (e.g. send email, show banner).

Scenario example[![Scenario goals overview](docs/scenario_example.png)](docs/scenario_example.png)

Scenario builder elements
-------------------------

[](#scenario-builder-elements)

Scenario builder provides several node types to build a graph with. User can link nodes in arbitrary ways, connecting output of one node into an input of another node. After saving (and enabling) the scenario, it will be executed every time the scenario trigger is hit.

### Triggers

[](#triggers)

Each scenario has to start with a trigger node. Currently, there is two trigger types - "Event" node and "Before Event".

#### Event

[](#event)

Event provides several hooks on changes related to user. Currently it supports event types:

- User created
- New subscription
- Subscription ends
- Recurrent payment renewal
- Test event (triggered by console command `scenarios:test_user`)

Every time user triggers specified event, all scenarios having this event will be executed, passing a user (triggering the scenario) down the graph.

#### Before Event

[](#before-event)

Before Event requires two parameters - an event and a time interval. Time interval specifies how long before the actual event the trigger fires, starting the scenario. Currently it supports event types:

- Subscription ends
- Recurrent payment charge
- Recurrent payment expires

### Conditions

[](#conditions)

The condition block allows to edit the flow of graph based on the result of specified criteria. One condition block is able to combine more criteria of a single type. All defined criteria are evaluated together and based on the result, graph flow follows either positive or negative direction. Currently supported criteria types:

- **User** - User criteria are evaluated based on parameters of a user who triggered the scenario. Criteria class has to implement `ScenariosCriteriaInterface`.
- **Payment** - Payments criteria are evaluated based on payment parameters of a scenario trigger. Such criteria can only be used in scenarios starting with triggers related to payments. Some triggers may or may not have payment parameters attached, e.g. 'New subscription' trigger. In such case, use 'Trigger' criteria (such as 'Has payment') check first to make sure payment parameters are present before using payments criteria. Criteria class has to implement `ScenariosCriteriaInterface`.
- **Subscription** - Subscription criteria are evaluated based on subscription parameters of a scenario trigger. Such criteria can only be used in scenarios starting with triggers related to subscriptions. Criteria class has to implement `ScenariosCriteriaInterface`.
- **Trigger** - Trigger criteria are evaluated based on parameters provided during the event triggering. Criteria class has to implement both interfaces `ScenariosTriggerCriteriaInterface` and `ScenariosCriteriaInterface`.

### Actions

[](#actions)

#### Send email

[](#send-email)

This node sends an email to an user who triggered the scenario and reached this node. Email list is loaded from CRM.

#### Show banner

[](#show-banner)

**Warning:** enabled only when REMP-Campaign module is installed and integrated with Campaign tool.

This node shows a one-time banner to user triggering the node. Available banners are loaded from Campaign tool.

#### Run generic action

[](#run-generic-action)

This node emits League event specified in `createEvent` method in generic action definition. You can specify custom params which will render in ui and will be passed as options to `createEvent` method.

You can try how this feature works by registering `TestGenericEvent` in your configuration:

```
services:
	scenariosGenericEventsManager:
		setup:
			- register('test_gen_event', Crm\ScenariosModule\Scenarios\TestGenericEvent())
```

You can unregister event registered by another module by calling `unregister` method:

```
services:
	scenariosGenericEventsManager:
		setup:
			- unregister('test_gen_event')
```

### Operations

[](#operations)

Typically, scenario actions should be reached only by a subset of users triggering the initial scenario trigger. Therefore, the builder provides several elements to filter users or delay execution of later actions in the graph.

#### Segment

[](#segment)

Segment node checks whether user reaching the node is present in specified segment. Based on the result, the node redirects execution flow to either positive (user in segment) or negative (user not in segment) path.

Segment node details[![Scenario goals overview](docs/segment_node_detail.png)](docs/segment_node_detail.png)

#### Wait

[](#wait)

This node simply delays execution of next element in a graph by specified time interval.

### Goal

[](#goal)

Goal element checks if user triggering the node have completed selected onboarding goals. For more details, see "Onboarding module" documentation.

### AB Test

[](#ab-test)

AB Test element chooses one flow from two or more variants based on the percentual distribution.

Installing module
-----------------

[](#installing-module)

We recommend using Composer for installation and update management.

```
composer require remp/crm-scenarios-module
```

### Enabling module

[](#enabling-module)

Add installed extension to your `app/config/config.neon` file.

```
extensions:
    - Crm\ScenariosModule\DI\ScenariosModuleExtension
```

When it's added, generate ACL for newly created module.

```
php bin/command.php user:generate_access
php bin/command.php api:generate_access
php bin/command.php application:seed
```

### Building assets

[](#building-assets)

Install dependencies inside module folder `yarn install`Be sure to have scenario config filled in a global scope. It should look like this:

```
window.Scenario = {
  config: {
    AUTH_TOKEN: '',
    CRM_HOST: '',
    CANCEL_PATH: '',
    SEGMENT_ID: null
  }
};
```

Run `yarn build-prod` if you want to build whole application for the deployment. Then, at the root of the project, copy assets using:

```
php bin/command.php application:install_assets
```

### Engine

[](#engine)

Scenarios module requires Scenario engine worker to run separately in a background to process graph execution flows. In addition, it also requires Hermes worker to process asynchronous tasks. Execute:

```
php bin/command.php application:hermes_worker
php bin/command.php scenarios:worker
```

Make sure both workers are started again if killed, e.g. by running a service or a watchog.

Speed of engine processing is configurable. One can specify lower and upper limit on sleep delay between processing rounds (in each round, all jobs in queue are processed) in your configuration:

```
scenariosEngine:
    setup:
        # time in microseconds
        - setMinSleepTime(10000) #0.01s
        - setMaxSleepTime(10000000) # 10s
```

The actual sleep time is computed using exponential backoff algorithm. Default values are 0.05 and 1 second for min/max delay.

### Schedule commands

[](#schedule-commands)

Aggregate statistic data older than 5 days or data from the specific date with using option `from`. Setup cron to run command every hour.

```
# Aggregate scenarios statistics
php bin/command.php scenarios:aggregate_stats
```

Remove statistic data older than 31 days. To specify exact date use option `date-to`. Setup cron to run command daily.

```
# Remove old statistic data
php bin/command.php scenarios:remove_stats
```

### Before events

[](#before-events)

For generating "Before Event" triggers, add the following command to your crontab. Optionally set it up to run every 10 minutes.

```
php bin/command.php scenarios:event_generator
```

### Graceful shutdown of workers

[](#graceful-shutdown-of-workers)

To gracefully shutdown both workers (`application:hermes_worker` and `scenarios:worker`) use command from [ApplicationModule](https://github.com/remp2020/crm-application-module):

```
php bin/command.php application:hermes_shutdown
```

Use this to in case CRM modules were updated and you need to reload workers. More details in README of [ApplicationModule](https://github.com/remp2020/crm-application-module).

###  Health Score

56

—

FairBetter than 98% of packages

Maintenance72

Regular maintenance activity

Popularity32

Limited adoption so far

Community26

Small or concentrated contributor base

Maturity81

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~32 days

Recently: every ~62 days

Total

68

Last Release

162d ago

Major Versions

0.37.0 → 1.0.0-beta12022-01-03

0.38.0 → 1.0.0-beta22022-02-03

0.39.0 → 2.0.02022-08-25

2.11.0 → 3.0.02024-01-22

3.7.0 → 4.0.02025-04-02

PHP version history (5 changes)0.7.0PHP ^7.1

0.29.0PHP ^7.3

0.35.0PHP ^7.4

2.0.0PHP ^8.0

3.0.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/7c733f9bd683c3814197d8a532b7da1ba1f631bb1efe1cde5f064feab1e24877?d=identicon)[rootpd](/maintainers/rootpd)

![](https://www.gravatar.com/avatar/a05541c0b35f43d95db5342210e1d9e64242888812d13f5b096df48b6aabd863?d=identicon)[msvitok](/maintainers/msvitok)

![](https://www.gravatar.com/avatar/2c30fdbc85cda35b94f7f59399918193a0289152281abcef344ec9ee82864177?d=identicon)[markoph](/maintainers/markoph)

---

Top Contributors

[![miroc](https://avatars.githubusercontent.com/u/1230714?v=4)](https://github.com/miroc "miroc (154 commits)")[![markoph](https://avatars.githubusercontent.com/u/6843562?v=4)](https://github.com/markoph "markoph (103 commits)")[![rootpd](https://avatars.githubusercontent.com/u/812909?v=4)](https://github.com/rootpd "rootpd (53 commits)")[![lubos-michalik](https://avatars.githubusercontent.com/u/63700066?v=4)](https://github.com/lubos-michalik "lubos-michalik (21 commits)")[![zoldia](https://avatars.githubusercontent.com/u/1526070?v=4)](https://github.com/zoldia "zoldia (10 commits)")[![burithetech](https://avatars.githubusercontent.com/u/3502143?v=4)](https://github.com/burithetech "burithetech (7 commits)")[![Matefko](https://avatars.githubusercontent.com/u/22897457?v=4)](https://github.com/Matefko "Matefko (4 commits)")[![tomaj](https://avatars.githubusercontent.com/u/446736?v=4)](https://github.com/tomaj "tomaj (2 commits)")[![weblate](https://avatars.githubusercontent.com/u/1607653?v=4)](https://github.com/weblate "weblate (1 commits)")[![davidkvasnovsky](https://avatars.githubusercontent.com/u/12381721?v=4)](https://github.com/davidkvasnovsky "davidkvasnovsky (1 commits)")[![mmacsodi-fcm](https://avatars.githubusercontent.com/u/169140294?v=4)](https://github.com/mmacsodi-fcm "mmacsodi-fcm (1 commits)")[![mikoczy](https://avatars.githubusercontent.com/u/14105084?v=4)](https://github.com/mikoczy "mikoczy (1 commits)")

### Embed Badge

![Health badge](/badges/remp-crm-scenarios-module/health.svg)

```
[![Health](https://phpackages.com/badges/remp-crm-scenarios-module/health.svg)](https://phpackages.com/packages/remp-crm-scenarios-module)
```

###  Alternatives

[getsolaris/laravel-make-service

A MVCS pattern create a service command for Laravel 5+

81161.3k](/packages/getsolaris-laravel-make-service)[ikkez/f3-flash

Add simple Flash Messages and Flash Keys to PHP Fat-Free Framework

1926.0k5](/packages/ikkez-f3-flash)[mfd/ai-filemetadata

Automatically generates FAL metadata for files by means of public LLMs

1142.1k](/packages/mfd-ai-filemetadata)[latfur/laravel-event-crud

Laravel Event CRUD With Full Calendar

125.6k](/packages/latfur-laravel-event-crud)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
