Closed irazasyed closed 8 years ago
Telegram itself is not prepared to handle conversations, actually. There's no continuity when a user talks to a bot. This has to be done on application side. I use this on my Package Tracking Bot (when user is adding a package, he asks for the package description and etc) and I log what that user last command was and what the next step should be. I can try to decouple it from my app the best I can, but you'd still need a way to record the user current step so you can decided the next one (I currently use a SQLITE database for that).
That's right. We were working on one such project with same requirements and we ended up using database method to keep track.
But will leave this open to try someday with maybe some other option like Cache or such.
Yeah, it's kinda hard because even though it's not that hard to do, it's still mostly living inside the application and not on the framework itself...
Thanks to @nMado who offered to work on this feature. We've been discussing on how to implement this for the last few days on PHP Chat inside a private channel.
He'll be posting a TODO list of things that we'll be working on to implement into this project soon.
If anyone else want to join the discussion and contribute, feel free to join PHP Chat Slack Community. Once you do, Please Direct Message (DM) me or post in #hangout channel that you want to join telegram-bot-sdk
private channel and I'll invite you there. Thanks!
P.S Excited to see this feature implemented. Thanks again @nMado for coming forward to contribute to this project :)
Thank you @irazasyed .
TODO:
ConversationBase
class.
(Detects conversational commands, starts first question or continues from where the user left, manages cache ...)ConversationQuestion
class.
(Represents a question, contains a unique name for the question, holds the answer callback ...)Command
class. (i.e. $this->startConversation()
)If you think the to do list has to include more details or even if anyone wants to contribute on this, please let's now.
Thank you.
Any update @nMado ? Looking forward to hear from you.
Hi, so we are actually talking about the fact that there's no flow control for a conversation? and let say we refer to the 'wizard style' interaction BotFather does when a user creates a new bot.
BotFather: hi issue your command! Me: /newbot BotFather: Gimme the name me: aSampleName BotFather: gimme the nickname ending with bot me : aSampleBot
So are you guys saying that BotFather likely uses a Database to handle this flow?
Hey @edge33,
Yes. Telegram doesn't provide any way to build interactive bots. It's up to us.
Also, You don't need a database for it (Although it's good to store records). You can simply use any type of caching too.
If the questions like you've mentioned would always be the same, then you don't even need caching. The conversational system that we're building would support things which would enable you to build AI bots as well as remember the answer the user gave to your bot, which can later be extract and store into the DB. Lot of things planned for it.
As far as BotFather is concerned, I don't really have any idea about their tech stack but they could be using DB like you've mentioned.
I'm closing this issue, Since we've moved it to the new org.
@irazasyed
Ok let consider the flow is like the one I posted,
how can the bot know where the flow is at a precise slice of time? i.e If I issued /newbot and the next message i expect is the name of the bot.
And what happens if another user issues commands? how do keep track of users with no caching?
@edge33 Without caching or storing it into the db, it isn't possible to keep track of the flow. That's the problem which is being resolved in the new package that is under development.
However, what is possible right now is that, user asks for a question, you answer to them right away. No caching or storing required. But if you have a follow up question to ask which is supposed to get triggered only after you get an answer to the previous one, then its not possible without caching/tracking.
As far as other user asking the question, that has got nothing to do with the previous user or as such.
I would recommend you to wait until we release V3 to implement what you're requesting with caching and all. But if you want to do that yourself, you can ofc do it too :)
For example: User asks your bot: What's the weather like today in San Francisco? Your bot can user regex or an API to understand the query and respond to them. However, If the same user asks your bot a question like: What's the weather like today? Your bot wouldn't have a clue of where the user is from and the next obvious question your bot is supposed to ask them is the city. This is still possible to some extend but then its very much limited. It would be annoying if your bot keeps asking the end user to tell you their city instead of you remembering their city once you ask them initially at first.
Ok perfet, I understood correctly then. Thank you very much for taking your time to help us :)
Cool. Anytime :)
Stay tuned for V3. It's going to be awesome, So many major changes and new stuff coming soon!
Hi @irazasyed
Is conversation system implemented? if not there is any plan to implement it?
Thanks
Hey @kiasaty! It's WIP for now and may release with V4.
Please create a new issue ticket if you have any questions, let's not bump old issues :)
Thanks!
I have plans to create a system with which, we can build a Q/A kinda interactive bots easily.
Since the commands system is not designed to handle this nor it was intended to do that, A separate functionality makes sense.
The only part that's quite complex is to track the answers/responses and to map it to the right question and then move to next in a queue.
Any inputs would be good.