Z
Z
ZeroBot2018-01-28 11:18:48
PHP
ZeroBot, 2018-01-28 11:18:48

How to write a chat bot for Telegram?

Hello.
Please help. I want to write a dialog bot for Telegram.
Now it certainly works, but not as we would like :(
Example:

User: Art123456
Bot: Looking for SKU 123456
Bot: Found <information about the product with this SKU>

User: NameTEST
Bot: Looking for a product with the name TEST
Bot: Found <information about a product with this name>

Made according to the principle
...
switch (mb_substr($text,0,3)) {
            case 'Арт':
...

And I really want to do a search like this:
User: Article
Bot: Search mode by article, send it
User: 123456
Bot: Found the following for article 123456 ...

Throw a link at me :)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
Ernest Faizullin, 2018-01-28
@erniesto77

you are looking for a product by a search query, this query is 123456
UPD: I misunderstood the question. You need to create a command like /search_by_articul and call it if the user has typed the word "Article"

O
OKyJIucT, 2018-01-28
@OKyJIucT

And what prevents you from using the / article 123456 command? Display buttons with search directions, when pressed, a command is added and it remains only to specify and send the value.

R
Ramm, 2018-01-29
@rammtw

You need to create a table in the database: user_context (id, user_id, context), the current user context is written in the context field (for example, choose_articul). Further, depending on the current context, call the necessary methods.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question