Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Send data to handleChatMessage() #669

Answered by fabio-ivona
romatexdev asked this question in Q&A
Discussion options

How to send data with a message from a user in a chat and intercept it in handleChatMessage()?

I ask the user to enter a number
Telegraph::message('Count')->send();

Next, I intercept the text in handleChatMessage()
protected function handleChatMessage(\Illuminate\Support\Stringable $text): void { $this->chat->html("Received: $text")->send(); }

Can you tell me how to send other data together and get it from handleChatMessage()?

When I receive in handleChatMessage(), the data contains only the entered text
{ "update_id": 564438053, "message": { "message_id": 586, "from": { "id": 9465464644, "is_bot": false, "first_name": "RDev", "username": "romatexdev", "language_code": "en" }, "chat": { "id": 9465464644, "first_name": "RDev", "username": "romatexdev", "type": "private" }, "date": 15546546464, "text": "3" } }

You must be logged in to vote

Reply does not use any payload of the received message

Replies: 4 comments

Comment options

Hi, just reply form the handle chat message method

$this->reply("hello");

And listen for the response inside handle chat message

For conversations you should better keep track of the conversation state, using telegraph storage or a custom implementation

You must be logged in to vote
0 replies
Comment options

And if I need to pass 2 or more parameters?

You must be logged in to vote
0 replies
Comment options

Hi, just reply form the handle chat message method

$this->reply("hello");

And listen for the response inside handle chat message

For conversations you should better keep track of the conversation state, using telegraph storage or a custom implementation

Thank you for the answer!

But? i didn't quite understand how to use $this->reply("hello") in handleChatMessage()?
To clarify, I need to receive the payload along with the entered message from the user in handleChatMessage().

You must be logged in to vote
0 replies
Comment options

Reply does not use any payload of the received message

You must be logged in to vote
0 replies
Answer selected by romatexdev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
Converted from issue

This discussion was converted from issue #666 on November 25, 2024 16:28.

AltStyle によって変換されたページ (->オリジナル) /