Forum Documentation Showcase Pricing Learn more

Pyramide scheme with bubble

Hey community,

I am recently trying to build a pyramid scheme in bubble (don’t worry, I’m not a super villain. it’s actually for a donation project lol).

I am trying to implement that if one user is receiving a dollar, the user that recruited him should also get a dollar, as well as the one that recruited his recruiter, and so on.

This means that the income of the users should regularly be updated, in case one of the people you recruit earns something (because in this case you would, as the recruiter, also get a bonus). But how do I do this?

(I can’t do anything “on page load”, because let’s say I am a user and the user directly under me in the scheme gets inactive, but the ones further down are still active, then I should get a bonus. Doesn’t work though if the user under me never loads his page)

I hope I made this more or less clear and I’d be very very thankful for help to make my pyramid scheme dreams come true

I would suggest that this sort of thing should be done in the server rather than on the page. I guess it all depends on how your database is structured but one way I can think of is that each user has a parent (user) field and an ancestors (list of users) field.

When a user signs up has a parent (recruiter), you could call a recursive api workflow and pass the user and parent as parameters. In the workflow, you update the user’s ancestors field by adding the passed parent to it then you call the same workflow again passing the user again but this time the currebt parent’s parent, but only when the current parent has aparent. This way the workflow would keep repeating until the first ‘ancestor’ has been added, since that ancestor I assume would have no parent. Be careful not to cause an infinite loop and if your list of users grows big with users having deep ancestory, this process could take a long time and use up a great amount of capacity.

Anyway, this way, you have for each, user a list of their ancestors so whenever a user makes a donation, you can run another api workflow to add $1 to each of those ancestir users.

2 Likes

Hey,

Many thanks for your reply! Unfortunately though I do not understand everything you are saying. How do I make a recursive API workflow? Maybe you could show/create an example of this? It would really help me.

Thanks,

Felix

I think you may need to be on a paid plan for it but I’m talking about this feature … [New Feature] Scheduling API workflows can now be done recursively

I’m afraid I don’t have time right at this moment to create an example but you may be able to find some examples here on the forum. Give it a try and let me know if you still need help and I will try to find some time to make a quick example for you.

1 Like

Hey,

I tried this link but they do not directly explain the pyramid scheme, so I can not really convert what they announce in the post into what I am trying to build

So an example would be really cool, maybe if you have time. That would give me the security that if I buy the plan, it really works.

Thank you

Felix

I wasn’t suggesting that it would. It was just to explain to you what a recursive workflow is. In general, you’re unlikely to find existing posts that match your use case exactly and you will tend to need to adapt them to your particular needs.

Below are some screenshots that may help. I don’t have a paid app for you to test this in, so I think you will have to subscribe to try it yourself. You’ll need to get a paid subscription anyway if you want to run any workflows on the server and what you want to do seems to me like a definite server-side function.

  1. Add the fields direct_parent (User) and ancestors (list of Users) to your User record
    db
  2. Create an API Workflow and add some parameters - I’ve named mine set_ancestry
    Set%20Ancestry%20API%20Workflow
  3. Add three actions to the workflow - one to add the value of the parent parameter to the ancestors field, a second to add that parent’s ancestors to the current users and the third to call the same workflow again but this time with the parent parameter set to the just-added parent’s parent. Remember to set a condition to only recall the workflow if the just-added parent has a parent. This is important in order to avoid an infinite loop.

  4. On your page, when a user signs up and they have a recruiter (parent), call the API Workflow you created in step 1, setting the user parameter as the user in question and the parent parameter as their recruiter (direct_parent).

Hope this helps. Good luck.

Updated: Spotted an error/omission. See bold text and added/updated screenshots.

3 Likes