Jump to content
thirty bees forum

[Free Module]Conseqs - execute custom action when something interesting happens


datakick

Recommended Posts

Hi everyone,

I'm presenting you my new free module named conseqs (as in consequences).

This module is based on simple idea - it allows you to execute some action when something interesting happens in your store.

It's vague on purpose -- it's because there are be many triggers (new order created, product changed, page visit, product added to cart,...) and many actions (send email, raise error, log information, update record in db, send notification to slack,...) that you can combine together.

This module allows you to create automations like this:

  • when new order is created send email to my email address
  • when product stock quantity changed, and product reference is 'mug', and new quantity is below 30, then send email
  • when user navigates to url that contains string '/blabla' then redirect to '/blabla2'
  • when employee logs in to back office then log this information to access.txt file 
  • when user ends up on 404 page, then log the url address
  • before email is send, if name contains 'www.' then raise error message
  • when customer's total amount spent is greater than 1000EUR then update customer and change his group to 'Premium customers' 

And much more.

 

>>> DOWNLOAD LINK <<<

 

Demo: you can also test this module on my demo server

Licensing: the free version is limited in number of rules you can create. If you need more automation, you can purchase license and use the module without limitations. 
 

 

  • Like 1
Link to comment
Share on other sites

Sounds like a universal hook module. All these triggers (should) have a hook already, the module apparently provides some simple way to connect some kind of code on them.

I'd expect success of such a module to raise and fall with the way this "code" gets generated. Is it selecting from a list of predefined snippets? Is it moving some control boxes? Is it an actual code editor?

Link to comment
Share on other sites

33 minutes ago, Traumflug said:

Sounds like a universal hook module. All these triggers (should) have a hook already, the module apparently provides some simple way to connect some kind of code on them.

I'd expect success of such a module to raise and fall with the way this "code" gets generated. Is it selecting from a list of predefined snippets? Is it moving some control boxes? Is it an actual code editor?

You are right, it's basically a smart bindings between existing hooks and some actions. Very similar to IFTTT concept, if you are familiar with. If not, this is how their UI looks like, I wanna make something similar

Link to comment
Share on other sites

I have a use case. I would like to help my employees to not forget to do certain actions and to remind them by email. Don't know if this is applicable here though.

One thing that I have thought of is when a choosen order status has has been active for a amount of time I would like a reminder email to be sent to my customer care and remind them to handle this order. 

For example we have order statuses for ordered goods and sometimes the supplier doesnt deliver as they should and this would be great to remind us contact the supplier and ask why.

Another one is when we have to contact a customer about something before sending the order. Sometimes they doesn't respond and we have to send a new mail. This would be great to get a notice of.

Link to comment
Share on other sites

Thanks @Briljander for your input, I really appreciate

Unfortunately these use cases will be out of the scope of my module (at least for now), because there aren't any immediate triggers that I could hook to. My module can only react when something happens (record is saved to database, visitors perform some action, email is about to be sent, etc...). Here there aren't such immediate actions, it's more about state in the database.

I do, however, plan to implement scheduled triggers in the future, if this module takes off. There would be a cron task that would periodically check if some condition is met, and if so then trigger action. This mechanism could be used to implement your use cases.

Link to comment
Share on other sites

I like the idea! Some use cases I see in addition to the ones you mentioned (and I'm sure there are lots more) are:

- If products in shopping cart are under free shipping amount, show text: Only X Euro to get free shipping! Here are some products to help you get free shipping: (Display products close to the missing amount)

- I use the loyalty points module. I'd love to have an email sent to customers ca. 10 days before the loyalty points expire. (Could one use as a general trigger to get around the required cron something like every new customer registration?)

- If product X with attribute Z is sold, deduct stock from product Y with attribute Q.

- If visitor visits a sold out product X, recommend product Y instead.

Edited by 30knees
Link to comment
Share on other sites

2 hours ago, datakick said:

Unfortunately these use cases will be out of the scope of my module (at least for now), because there aren't any immediate triggers that I could hook to. My module can only react when something happens (record is saved to database, visitors perform some action, email is about to be sent, etc...). Here there aren't such immediate actions, it's more about state in the database.

In an old module someone implemented as a trigger each time the store was visited (I guess visit saved to database?) to get around having a cron task. Would this be an easy workaround, i.e. having a "universal" trigger?

Link to comment
Share on other sites

1 hour ago, 30knees said:

I like the idea! Some use cases I see in addition to the ones you mentioned (and I'm sure there are lots more😞

- If products in shopping cart are under free shipping amount, show text: Only X Euro to get free shipping! Here are some products to help you get free shipping: (Display products close to the missing amount)

- I use the loyalty points module. I'd love to have an email sent to customers ca. 10 days before the loyalty points expire. (Could one use as a general trigger to get around the required cron something like every new customer registration?)

- If product X with attribute Z is sold, deduct stock from product Y with attribute Q.

- If visitor visits a sold out product X, recommend product Y instead.

Thanks for the ideas.

The first one is probably not possible -- it would be hard/possibly impossible to change page content. Actions that can be triggered are somewhat independent, not related to the source / trigger. 

The rest of your ideas could be theoretically done

Link to comment
Share on other sites

Sounds like a great module, but with such big scope is it feasable? I just mean that every person will think something different, with a new trigger o a new consequence and most of them should be included to not give the user frustration. But if it is technically possible, it is a good idea. Seems to me like an "internal PrestaShop Zapier"

I write you a PM

Link to comment
Share on other sites

1 hour ago, rubben1985 said:

I just mean that every person will think something different, with a new trigger o a new consequence and most of them should be included to not give the user frustration

That's true. But fortunately, creating new trigger or action is very easy (at least it has been easy so far). One needs to declare input/output parameters, and then implement the actual action execution. If there will be a demand for this module, I'll be happy to invest some time on this task. And maybe some tech savvy users will be able to implement (and share) their own actions/triggers. 

Link to comment
Share on other sites

On 5/17/2019 at 11:20 AM, datakick said:

Thanks for the ideas.

The first one is probably not possible -- it would be hard/possibly impossible to change page content. Actions that can be triggered are somewhat independent, not related to the source / trigger. 

The rest of your ideas could be theoretically done

About the first one: I was thinking of adding a line in the shopping cart summary, in case that makes it easier.

Link to comment
Share on other sites

If the module is capable to blacklist customers I will buy it 🙂

For example: If customer is added to a blacklist and some of customer’s details like phone number, name, address etc. match in new order, the module sends warning email to the merchant.

Link to comment
Share on other sites

17 hours ago, MockoB said:

If the module is capable to blacklist customers I will buy it 🙂

For example: If customer is added to a blacklist and some of customer’s details like phone number, name, address etc. match in new order, the module sends warning email to the merchant.

This is, in general, the intended use case. 

The module will work like this:

1) something happens in your thirtybees that will trigger the consequence rule

2) every trigger type will collect and provide details about the event. For example, *product added to cart* event would fetch information about added product, information about cart, information about customer, current cart total, etc... and pass these information forward to conditions/action layer

3) conditions can be build using only those information passed by trigger. So, there can be condition like 'added product id equals 100' or 'added product description contains word T-shirt'. 

4)  if all conditions are met, then the action is trigger

5) most actions needs some parameters for execution. For example, action 'Redirect' needs redirect url. These action parameters can be provided as constant during rule definition, or can be derived from trigger output. For example, we could say the redirect url is 'https://www.google.com/{product_name}' where {product_name} will be substituted on the fly

 

Your use case would require to define condition (step 3) like this:

- there exists some customer record in database that is marked as blacklisted and has same email as currently pending email

While this condition can be implemented, it will not be in the first few versions, as I will first try to tackle primitive conditions 

  • Like 1
Link to comment
Share on other sites

I've just released first beta version of this module, you can download it here. There are still a lot of work to do, but I wanted to release it as soon as possible in order to collect your opinions and ideas. I hope there will be some 🙂

You can also test this module on my demo server - go to Advanced parameters > Conseqences. Please be careful and don't ruin my test account too much 🙂

Some information about the module:

- this module allows you to create Rules

- every Rule consists of three parts: trigger, conditions, and action

- trigger is some event that can fire the action, for example

  • new order created
  • email is about to be sent
  • page view
  • order status change
  • ... etc

- conditions - optional settings that you can use to react only on some events. For example, you can use conditions to execute action only when new order is created for customer with id 123

action - this is where you set what you want to do in reaction to trigger event. For example:

  • send email
  • redirect 
  • raise error
  • change product quantity
  • execute custom sql

Some screenshots:

1) Rule builder:

rule-overview.jpg.3f2e186bfcbb6ec2d0d986ab24f809a7.jpg

 

2) Choose trigger

select-trigger.jpg.33ca820b0c7139511f8f1772e6ad502e.jpg

trigger-settings.jpg.f3b94efc6b1da1c684e313a2d67df0d7.jpg

 

3) enter conditions:

conditions.jpg.a7307fc290f052bebb450b82c5ead0f5.jpg

 

4) define action

select-action.png.331253bd61541ab62dff075126002570.png

bindings.thumb.jpg.f60bfddab0eeb28089eaeb711ece4cd6.jpg

 

  • Like 3
Link to comment
Share on other sites

The demo in your account looks great. This is an amazing module, truly fantastic! It opens up so many possibilities. I don't think I saw customer groups or country zones as conditions. Would these be possible, too?

Link to comment
Share on other sites

10 hours ago, 30knees said:

The demo in your account looks great. This is an amazing module, truly fantastic! It opens up so many possibilities. I don't think I saw customer groups or country zones as conditions. Would these be possible, too?

Good idea, I'll add these to my backlog

Link to comment
Share on other sites

I've just released new version 0.0.2 -- I've added another level of records data that you can use for conditions and/or bind to action.

For example, when you choose trigger

Before record is created and select record = Product

then in Conditions you can use all product fields -- you can write condition like this:

Product:Name contains 'Cup' 

This was already available in previous version. This new version will allow you to access sub-records field values as well. For example, every product has default category, so we can now write condition using this default category values:

Product:Category:Name = 'Shoes'

This mechanism is implemented using lazy loading technique, so it shouldn't impact performance. Data for sub-records are loaded only when needed

 

  • Like 1
Link to comment
Share on other sites

1 hour ago, MockoB said:

Looks great @datakick !

Just few misalignments on my phone

Thanks for the heads up. I didn't really test the module for mobile use, because not many merchants are managing their back office using their phones. But it should definitely be fixed

Link to comment
Share on other sites

I've just released new version 0.0.3, with following changes:

Features:

  • Ability to register third-party triggers and actions -- Other modules can now register their own triggers and actions. I will soon release new version of my other modules (datakick, revws, pricealert) that will add integrations with conseqs. That will allow to trigger action when new review is created, generate xml/csv file when something happens, etc. 
  • Import and export rules -- you can now export your rules and import them back, or to another server. If you have some interesting rules, you can now share them with the community!
  • New action - log into text file,... you can log anything that happens in your store. For example, you can keep track of order state changes. Or you can generate list of orders with VAT number in separate file, etc.
  • New action: Assign customer to group - you can, for example, automatically assign your customers to B2B group if they enter VAT number  
  • New binding mode - Interpolation -- in previous version, you could bind action parameters to either constant, or value provided by trigger. Newly, you can combine multiple values using interpolation binding. During runtime, placeholders will be replaced by actual values.  You can use this, for example, to personalize subject email:

image.png.5d493a7c3f2da7308ae61dd41ba93982.png

Improvements:

  • Added more common context variables that you can use for binding (date, time, current url, shop url, shop email,...)
  • Caching object models detection to improve performance

Bugfixes

  • fix mobile issues

I'm open for any ideas for future enhancements!






 

  • Like 1
  • Thanks 2
Link to comment
Share on other sites

On 5/30/2019 at 6:05 PM, datakick said:

Features:

  • Ability to register third-party triggers and actions -- Other modules can now register their own triggers and actions. I will soon release new version of my other modules (datakick, revws, pricealert) that will add integrations with conseqs. That will allow to trigger action when new review is created, generate xml/csv file when something happens, etc.

Depending on how much work it is, it would be great if you could hook it into https://github.com/thirtybees/loyalty so customers will be contacted before their points expire. Note: If possible, customers should be able to unsubscribe from any such emails after the first one is set. Perhaps also an opt-in/out feature like for Revws during the order process?

Link to comment
Share on other sites

On 5/31/2019 at 8:17 PM, 30knees said:

Depending on how much work it is, it would be great if you could hook it into https://github.com/thirtybees/loyalty so customers will be contacted before their points expire. Note: If possible, customers should be able to unsubscribe from any such emails after the first one is set. Perhaps also an opt-in/out feature like for Revws during the order process?

These kind of triggers are in the backlog, but it's not immediate task.

The problem here is that there is no real-time event conseqs could subscribe and react to. In this case, this trigger action is defined by state that changes over time. That means that some cron needs to run, and periodically check if the conditions are met. What's even more complicated is the fact that conditions can hold for a long time. We definitely don't want to send email reminder to use loyalty points every time cron task executes. That means some database storage in which we will hold previous value of this measurement, and use it to react on changes only.

Altogether, it's very complicated. But I agree that this extends the use cases significantly, so I'll definitely implement this in near future. 

 

  • Thanks 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...