Image 1 hosted in ImgBB
ibb.co
While the first 2 examples I gave are obviously similar, it's important to realise that the 2 compounds here are just as potent.
What is important is the relative3D position between an aromatic ring and -OH function and an aromatic ring and the nitrogen lone-pairs relative position and orientation.
It's the lone-pair rather than the nitrogen itself because opioids like desmethyltramadol (the active metabolite of the prodrug tramadol) have a secondary amine and unusual opioids like dezocine have a primary amine.
You can see how some examples also have an ester or amide moiety. In this case it is the lone-pairs of the =O (carbonyl) function. Other examples have ketones (e.g. ketobemidone) or a bioisostere such as a sulfone (e.g. IC-26). In fact, the ketone moiety can usually be replaced with an ethylsulfone which is a bioisostere.
But why is their generally a 2-caron chain beyond the carbonyl function? This would appear to mediate if an opioid is an agonist, mixed agonist/antagonist or antagonist in it's action. In fact, in some cases a benzylic alkyl side-chain provides some activity with the n-propyl being agonist, ethyl being mixed agonist/antagonist and methyl as antagonit. BUT this rule only applies to opioids with phenol (or bioisostere) moiety.
Nobody has a full set of rules but by careful application of a training-set, it's possible to be fairly confident of a compounds MOR activity.
And something I have not seen written down (and Dan is no longer around to ask) is that the most potent opioids are 15 methylenes in length. From etonitazine to the most potent etorphine homologue to fentanyl derivatives and even really unusual opioids like AP-237 and viminol.
It is a lot to take in but if you refer back to this, you will see that it does apply to almost all potent opioids. Low potency opioids may lack one of the 4 key moieties and still have reasonable activity. In those cases it is usual for a 'magic methyl' to increase receptor recognition.
Don't forger that the 'address-message' concept of drugs is useful but slightly inaccurate. What a ligand does is allow the receptor to enter a lower energy state so it's 'lock and key' but it's the LOCK that can change shape to fit the key... which I appreciate is very hard to articulate.
People like fast&bulbous have a great deal of experience in testing the QSAR of drugs and sekio certainly knows a lot as do several other regulars here so their input would be useful.
But if anyone wants to ask how a particular opioid works, feel free to ask.