Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PEER_ID_INVALID and business bot #700

Open
alexey-sh opened this issue Jul 24, 2024 · 0 comments
Open

PEER_ID_INVALID and business bot #700

alexey-sh opened this issue Jul 24, 2024 · 0 comments

Comments

@alexey-sh
Copy link
Contributor

I have Premium Telegram account and created Business Telegram bot. So it is able to receive notifications from all my chats, but when I try to send message, it throws the following error

Fail RPCError: 400: PEER_ID_INVALID (caused by InvokeWithBusinessConnection)
    at RPCMessageToError (/Users/alexeysh/dev/tg-api-no-bot/node_modules/telegram/errors/index.js:28:12)
    at MTProtoSender._handleRPCResult (/Users/alexeysh/dev/tg-api-no-bot/node_modules/telegram/network/MTProtoSender.js:546:58)
    at MTProtoSender._processMessage (/Users/alexeysh/dev/tg-api-no-bot/node_modules/telegram/network/MTProtoSender.js:476:15)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async MTProtoSender._recvLoop (/Users/alexeysh/dev/tg-api-no-bot/node_modules/telegram/network/MTProtoSender.js:424:17) {
  code: 400,
  errorMessage: 'PEER_ID_INVALID'
}

this is my code

   console.log('started', await client.start({
        botAuthToken: BOT_TOKEN,
    }));

    client.addEventHandler(async (update: Api.TypeUpdate) => {
        if (update instanceof UpdateBotNewBusinessMessage) {
            try {
                const result = await client.invoke(new Api.InvokeWithBusinessConnection ({
                    connectionId: update.connectionId,
                    query: new Api.messages.SendMessage({
                        // @ts-ignore
                        peer: update.message.fromId,
                        message: "Hello there!",
                        // @ts-ignore
                        // sendAs: update.message.peerId, // does not help
                    })
                }));
                console.log('ok', result);
            } catch (e) {
                console.error('Fail', e);
            }
        }
    });

Business users can connect Telegram bots that will process and answer messages on their behalf. This allows businesses to seamlessly integrate any existing tools and workflows, or add AI assistants that manage their chats.

The documentation says it is possible, but it seems not to be.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant