How do Lewis acids interact with 1,4-diketones and amines to form an alkaloid?
This is a variant of the Mannich reaction. The methoxymethyl groups on the amine are a form of captured Mannich intermediates or masked formaldehyde equivalents. The Lewis acid unmasks them by binding to the oxygen of the methoxy group, creating the functional equivalent of H2C=N+. These are reactive electrophiles which react with the active methylenes of the B-ketoester to give the alkaloid.

More on the Mannich reaction here