Telegram Bot Event When Users Join To Channel - bots

After create telegram bot, access and admin this bot to channel. how to get channel members list or event when users join to this channel?

Pretty disappointed with the current answers, so I'll leave an updated (as of February 2018) answer that explains how to do this with the Telegram API itself, as well as with the framework I am using, Telegraf for Node.
The Telegram API is both very powerful, and pretty simple as far as API's go. If you are using the polling method of getting updates, and not websockets which are a whole other issue, checking if someone new has been added to a group or channel is very easy.
The API method getUpdates returns an array of Update objects, which contain all of the possible information you could want including any messages sent, inline queries, and new chat members. To get any new chat members you simply need to access update.message.new_chat_members which will contain an array of new users. For reference you can look in the API documentation here.
To fetch the update objects in browser, or with curl, all you have to do is send a GET or POST request to https://api.telegram.org/botYOUR-BOT-TOKEN/getUpdates. Then just look for messages->new_chat_members.
If you are using the Telegraf bot framework with NodeJs you can use the bot.on method with the event new_chat_members.
Example:
bot.on('new_chat_members', (ctx) => console.log(ctx.message.new_chat_members))
I know this was asked a while ago, but I hope this helps other people searching.

From docs:
new_chat_members New members that were added to the group or supergroup and information about them (the bot itself may be one of these members)
So i think you can't.

To get updates on users join group or channel you must correctly setup webhook for your bot. This update type is disabled by default. See https://core.telegram.org/bots/api#setwebhook
allowed_updates
A JSON-serialized list of the update types you want your bot to
receive. For example, specify [“message”, “edited_channel_post”,
“callback_query”] to only receive updates of these types. See Update
for a complete list of available update types. Specify an empty list
to receive all update types except chat_member (default). If not
specified, the previous setting will be used.
Please note that this parameter doesn't affect updates created before the call to the getUpdates, so unwanted updates may be received
for a short period of time.
So, the request should look like this:
https://api.telegram.org/<BOT_TOKEN>/setWebhook?url=<WEBHOOK_URL>&allowed_updates=["chat_member"]

Yes! You can use this:
https://api.telegram.org/bot[TOKEN]/promoteChatMember?chat_id=#[channelname]&user_id=[user_id]
if user is joined response is ok, else response is not ok.

Related

How to get the Group chat added member list from ChatBot in msteams

how to collect all the group chat members from the chat bot using MSTeams?
You can use the GetPagedMembers capability for this - see the docs from Microsoft here: https://learn.microsoft.com/en-us/microsoftteams/platform/bots/how-to/get-teams-context?tabs=dotnet (switch to your language of choice in the samples blocks).
Note that, using this approach, you can only do this when the user is actually interacting with the bot (e.g. posting a message) because you need the context. If that's a problem let me know and I will send additional info.
Here are the two ways that can work for you
Using graph - List members of a chat. Refer this sample.
Get conversation member. (you are already aware about this as I can see.)

How to create a bot in lex/azure that respond in slack threads?

I have created 2 chatbots using AWS lex and Azure bot framework each. I have integrated them with slack and they respond to the mentions in channels.
Currently, the bot responds as a new message however I want it to respond in the slack thread of the original message posted by the user. I tried to look for articles in various places but could not find anything helpful. Does anyone have any idea on how to achieve this or a reference to a GitHub repo for a sample?
Since you are able to post replies, I am assuming that you are using chat.postMessage API.
https://api.slack.com/methods/chat.postMessage
To send the reply as a thread, all you need to do is that add thread_ts argument in the api call.
(Provide original message's ts (timestamp) value to make this message a reply.)

How to make twitter bot track tweets from our followers?

I was making a twitter bot with Twit, I found making tutorials using T.stream('user')
to get stream data about our account, now its deprecated. So in 2021, how can i achieve these?
requirements:
Know when someone follows my bot, and make a thanks post.
Know when someone in my followers list or following list makes a tweet.
Also I have a doubt, when we use stream, old data is also coming, so how exactly stream works? if i only want latest tweets, I have to sent get by setting interval?
For the new followers, you will need to build something using the Account Activity API, which uses webhooks to send you event messages. You will need to filter for the follow events.
For new Tweets from people you are following, you will need to poll the home timeline endpoint. There’s no realtime method for this.

Google Hangouts Chatbot Create Room

I am writing service for messaging between rooms using Hangouts chatbot. Is it possible to create a room with Hangouts chatbot?
https://developers.google.com/hangouts/chat/concepts
If it were generally possible to create a new room programmaticaly with the Hangous API, you could do it with the chatbot.
For example, if you implement the chatbox with Apps Script, you can create a function onMessage(event) and establish was will to happen in case of a certain event.message.text (e.g. create a new chat room if the message text contains the string create new room.
However, for the moment it is not possible to create a new chat room programmatically.
There is a feature request asking for this functionality, but given the potential of abuse, it is controversial either it will be implemented.
See comment #2:
Hello, thank you for the feature request! At the moment rooms cannot
be created via the API to prevent abuse such as a bot or script
spamming room creation. However, this kind of feature has been
discussed internally and may be coming in the future (with
limitations). I will update this issue if more information is
released.
And comment #25:
Thanks for the input. It's great to see some real life use cases. We
fully acknowledge the importance of a CreateRoom(DM) API and we are
actively looking into the right permission model to allow bots to do
so. Please continue to follow this bug as we will post updates here
when appropriate.

Server-side query using events or/and context?

I’m coding a bot using PHP-BotMan for complexity reasons and using Dialogflow query api to extract and manipulate the informations from the response. I saw examples and hints from people here and on dialogflow forum suggesting using context or events, some of them mixing both. What is the better way to handle this?
The flow of the application is:
user messages bot
bot queries (text or/and #event?) dialogflow
internally process a reply or return dialogflow slotfilling* request
text response bot reply user with last reply or asking to fill slot
Also, how can I be sure that a slotfilling process is finished with “actionIncomplete” only having two values, NULL or TRUE? The dialogflow query response doesn’t show wich slotfilling parameters are required or not…
Thanks for the help!!
slotfilling is when dialogflow sends a text response requesting required parameters to finish an intent, adding those replied values to the context
I was trying something similar to your scenario, here are few points i found helpful:
When Slotfitting with webhook, i can't use the "Required" params field since i have to control the input parameters via webhook (query database to provide options). Which means actionIncomplete field is not useful anymore.
I personally prefer to use context as it can add/remove params which gives you more control.
Hence the dialog was designed to use webhook to check all required params before move on to next conversation flow. and pop quick replies menu to ease and restrict possible input from users.
HTH.

Resources