A
A
Anton2020-01-24 02:43:59
Bots
Anton, 2020-01-24 02:43:59

Are there examples of a bot so that the bot responds to requests?

Created a bot in telegram and got a token and chat id.
I send messages to chat in php. This works especially interesting for site event notifications via get requests. Everything is great.
But in my implementation it is one-way communication.
I would like to learn how to do such a thing: The user writes a phone number or order number to the bot, somehow all this is processed and in response to the user a message about the status of the order is received.
How can this be done, preferably in php? Are there simple examples?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
mt_max, 2020-01-24
@mt_max

You need to install a database, for example mysql. It stores records of orders: number, status and everything else. When the user writes a message with the order number, it is necessary to execute a query to the database "SELECT status FROM table_name_with_orders WHERE order_number=entered_number_by the user;" send the result of the request to the user.
To respond to incoming messages, you need to set up a webhook

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question