defstudio / telegraph

Telegraph is a Laravel package for fluently interacting with Telegram Bots
MIT License
646 stars 110 forks source link

Conversations #270

Open alglyzin opened 1 year ago

alglyzin commented 1 year ago

I need to collect information from the user using a conversation. So that the bot remembers the input context for a while. Example: https://botman.io/2.0/conversations

fabio-ivona commented 1 year ago

Hi, this is planned, until then you can handle a conversation through webhooks and storage

elephantux commented 1 year ago

Hi, this is planned, until then you can handle a conversation through webhooks and storage

It would be great to see the simplest example of a conversation. For example, asking the user for an email using validation - don't accept the answer until the correct email is provided.

henzel commented 1 year ago

Hi, this is planned, until then you can handle a conversation through webhooks and storage

It would be great to see the simplest example of a conversation. For example, asking the user for an email using validation - don't accept the answer until the correct email is provided.

Hi. You can use Storage (https://defstudio.github.io/telegraph/storage/entities_storage). For example you asked for a email. Set variable "waitemail{user_id}". After that in handleChatMessage (https://defstudio.github.io/telegraph/webhooks/webhook-request-types) check variable. And work with this :)

pou commented 1 year ago

i'm going to make it. Do you have any ideas or wishes?

bilogic commented 5 months ago

I like to think there are 2 ways:

  1. For a HTTP styled request, response transaction, we need a state machine and it has to remember its last state for each user
  2. Create PHP daemon and an input loop, much like how a CLI application works, but this will not scale nicely as 1 daemon can serve only 1 user