There are the Web Tools that can be used to create links for specific flows but this is a bit different to what you’ve described.
Since you want to create the ref link for each user dynamically within the flow you’re going to need to use a bit of a workaround since Facebook only reads the first appended parameter on the URL, e.g. a single ?ref value.
As a workaround to this limitation you could separate ref values by a character and then use the Text (String) service to split the values once you receive the Metadata. For example, you could use a URL like:
m.me/botname?ref=1-2-3-4
I’m separating 1, 2, 3 & 4 by using a hyphen.
In my flow the Metadata will come through as:
“ref”: “1-2-3-4”
This means that I can add an action to Split the Text where I grab the ref value {{new_message.metadata__ref}} and use the hyphen a the separator.
On the output from the split text action I get each value:
{{split_text.string1}}
{{split_text.string2}}
{{split_text.string3}}
{{split_text.string4}}
These could be used to save to an Attribute or placed into other actions.
You can then have a master flow that splits the values from the URL, records the User ID that did the referral and then triggers the relevant flow.