how to create db driven botman? #1387
Replies: 4 comments
-
Use a Conversation: https://botman.io/2.0/conversations The should have a protected property with the current question ID from the DB (null at the beginning). Create a method that uses the question ID to load the question from the database. If the question ID is null, load the first question. Within the ask() callback, store the answer in the database. |
Beta Was this translation helpful? Give feedback.
-
Thank you for responding, but I actually don't get what you mean... However let me show you what I tried doing...
The text and image works without an issue. The generictemplate isn't fully tested but it works without an error. The question however throws an error. [2023-11-02 12:31:40] local.ERROR: Call to undefined method Closure::toArray() {"exception":"[object] (Symfony\Component\Debug\Exception\FatalThrowableError(code: 0): Call to undefined method Closure::toArray() at \vendor\botman\botman\src\Messages\Outgoing\Question.php:94) |
Beta Was this translation helpful? Give feedback.
-
Use a Convesation class. |
Beta Was this translation helpful? Give feedback.
-
im fairly new to this kind of thing. But i'll try and follow your finger. Thank you |
Beta Was this translation helpful? Give feedback.
-
I wish to create something like this but should by dynamically loaded from the database
$bot->reply(Question::create('Please click from the options below to know more about our shop.')->addButtons([
Button::create('Product Menu')->value('product_menu'),
Button::create('How to Order')->value('how_to_order'),
Button::create('Our Location')->value('our_location'),
Button::create('Delivery Rates')->value('delivery_rates'),
Button::create('Product Availability')->value('product_availability'),
Button::create('Payment Modes')->value('payment_modes'),
]));
the Button::create part should be loaded from the database and must be looped. tried array but it wont work.
Someone help please?
Beta Was this translation helpful? Give feedback.
All reactions