magento-hackathon / magebot

21 stars 2 forks source link

Connect Conversation Domain Logic with Botman #5

Closed schmengler closed 7 years ago

schmengler commented 7 years ago

Configure Botman conversations based on ConversationDefinition, let Botman control the Conversation instance

schmengler commented 7 years ago

This needs some performance considerations: Botman Conversation uses SerializableClosure to serialize the callbacks and the conversation instance in the Botman cache. Closure callbacks are bound to the conversation instance on unserialization. The originally bound object is serialized too though.

If the conversation uses any Magento classes (like ProductRepository in a ProductListAction) this is going to be ugly.

Possible approaches:

schmengler commented 7 years ago

To unserialize the actions that need to access botman, Botman should probably be instantiated via Magento object manager and kept as a shared instance.

And/or we extend Conversation->setBot() which is called on unserialization and pass the bot to the objects that need it.

schmengler commented 7 years ago

Relevant Botman issue: https://github.com/mpociot/botman/issues/195