question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

sendMessage - Could not find the input entity for ${peer}

See original GitHub issue

Work:

let result = await client.invoke(
        new Api.messages.SendMessage({
            peer: 'username',
            message: 'hello'
        })
    )
    console.log(result);

if peer is a number, which is chat_id :

let result = await client.invoke(
        new Api.messages.SendMessage({
            peer: 123456789,
            message: 'hello'
        })
    )
    console.log(result);

got error:

throw new Error(`Could not find the input entity for ${peer}.

Error: Could not find the input entity for [object Object].

Any solution?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
painorcommented, Aug 2, 2021

Still encountering this error, tell me how to make the library see the address where I want to send the message.

When I put userId there the message is sent, but when I put chatId the error appears.

If you are using a bot then the bot need to be in that chat or has talked to that user before. If you are using a user then you need to get that chat somehow either with an event being sent there (like a new message) or by getting all dialogs on startup (client.getDialogs())

0reactions
painorcommented, Aug 3, 2021

I do through the user, added (client.getDialogs ()) and it worked. Thanks!

An error popped up in the process:

function iterDialogs(client, { limit = undefined, offsetDate = undefined, offsetId = 0, offsetPeer = new tl_1.Api.InputPeerEmpty(), ignorePinned = false, ignoreMigrated = false, folder = undefined, archived = undefined, }) { ^ TypeError: Cannot read property ‘limit’ of undefined

Specified the “limit” value and everything worked!

Great. I forgot to add the limit in the example I sent. Usually something like 100 or 50 is enough.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ValueError: Could not find the input entity for PeerUser
To “encounter” an ID, you would have to “find it” like you would in the normal app. If the peer is in your...
Read more >
Could not find the input entity for <telethon.tl.types.PeerUser ...
This is my Code: client(ImportChatInviteRequest(gruppoF)) except Exception: print("Gia' ci sono") ...
Read more >
Entities — Telethon 1.26.1 documentation
If the entity cannot be found, additonal calls like ResolveUsernameRequest or GetContactsRequest may be made to obtain the required information. Entities vs.
Read more >
Users, Chats and Channels — Telethon 1.7.7 documentation
Peers are enough to identify an entity, but they are not enough to make a request with them use them. You need to...
Read more >
gram-js - Bountysource
I couldn't find any information on deployment best practices. ... Can I cache the peer information to redis and use it to send...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found