skip to Main Content

I have prepared one api in php for send message to bot. Every time, I need to pass chat_id in api call.
Anyone know how can i create unique chat id for send message to bot.

Thanks in advance.

2

Answers


  1. According the documentation:

    Bots can’t initiate conversations with users. A user must either add them to a group or send them a message first. People can use telegram.me/ links or username search to find your bot.

    You need to write (or user need to write) first to bot. After it, in response (that getting via webhook or getUpdates method) you can get chat_id that uses to write messages to user.

    Update: If I understand your comment right, you can do that:

    1. Create somepage or modal window, that can be used to send message to support.
    2. Catch this message and send it via sendMessage method to support team.

    Whom? You can manage this. I see two options:

    1. You can create a group for support team in telegram and add your bot to this group.
    2. You can store chat id’s for all support’s team members on your side and choice how recive message for every support request form website.
    3. When bot receive a message it goes to backend (webhook or getUpdates), and from the backend it’s can be shown to enduser.
    Login or Signup to reply.
  2. Each user’s chatID is unique and therefore you can send a message from your own Telegram account to your bot and save the chatID. After that when the website user sends a message in your site you can pass that message to your bot via php and force the bot to send it to yourself using your chatID .

    You don’t need to communicate with the user with telegram you should just use PHP to get the message and give it to the bot for sending to yourself.

    Note that bots can only send messages to people who have sent at least one message to them before.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search