Can a slackbot pull messages from a private channel and post in another slack channel? - automation

I am wondering if a slack bot can pull messages that are tagged with a certain string of characters from a private channel and then post that "tagged" message in another channel (private or public). All within the same slack group.

Yes, a Slack bot can do that. But he needs to be invited to a channel (public and private) to be able to monitor it. He then receives all messages in that channel and can react to it in any way you want. Bots can only use a subset of all Slack API methods, but yes they can post a copy of a message to another channel based on keywords.
See the Slack documentation on bots for more information.

Also try setting up a webhook from that slack channel, I've had success with that

Related

Inviting new user to private channel after inviting him by Slack API

I invited new user into slack team using slack API method users.admin.invite. I need to join him into some public and some private channels. Channels I gave as params in my inviting request, but with private channels I have trouble. It is not channels and it have another method to join user into it.
Method groups.invite need userId to join him.
Is it possible to add this user in the slack private channels (groups) using slack API?
The undocumented API method users.admin.invite has a channels property, where you can specify a list of IDs for the channels your want a new user to be automatically invited to.
This also works with private channels (I just tested it to confirm). All you need to do is to specify a private channel ID instead, which start with a G instead of a C.
You can use the API method groups.list to get the correct private channel ID. (private channels are called groups in the Slack API)
Example request:
https://slack.com/api/users.admin.invite?token=TOKEN&email=name#example.com&channels=G12345678
If you still getting errors using this approach than its most likely due to other issues, e.g. Slack does not recognize the email address or your access token does not have the admin right.
For more details please see the unofficial documentation of users.admin.invite on github, which I have updated accordingly.
Seems like this API endpoint isn't currently documented by Slack because it's still in development and could change in the future(which may be what you're running into now). Here's a link to a github issue talking more about it. https://github.com/slackhq/slack-api-docs/issues/30
I was able to find a github with documentation for the undocumented slack API endpoints, but those could have changed since they're not official https://github.com/ErikKalkoken/slackApiDoc/blob/master/users.admin.invite.md
From these unofficial API documentation it seems like you'll have to pass in the channelID instead of the channel name. To get channel IDs you'll just need to call the channels.list end point

Google GMail callback when someone reply to thread

I'm using Google GMail Api. All works fine with synchronous requests. However I would like to get notified when someone reply to given thread_id to a callback somehow.
I found this article https://developers.google.com/gmail/api/guides/push?hl=pl about push notifications and it's great but still I don't know how to setup Observer I have described above.
I'm using PHP btw, but I just need concept how it works and how I can setup that kind of communication between API and app.
There is currently no available API that detects/observes (something that behaves like a callback) if there is a reply for a specific thread_id.
You'll have to do the checking yourself, doing some polling (with users.threads.get) to see if there is a reply. Similar to what the OP was doing in this post (emphasis mine):
We have a web application that makes use of the Gmail API to automate certain emails on our users' behalf. When the application sends an email, it stores the threadId returned by the Gmail API. It then uses this threadId to poll the Gmail users.threads.get API, looking for replies. When a reply is detected, it pauses future emails.
You can use the Push notifications provided by Gmail API. The document is available here:
https://developers.google.com/gmail/api/guides/push?hl=pl#python
It's pretty much straight forward. Create a topic, then create a push subscription for the topic. It requires a webhook pointing to your web app. Grant necessary permission to the Gmail service account as mentioned in the document.
Use the below Python code to get notified:
request = {
'labelIds': ['INBOX'],
'topicName': 'projects/myproject/topics/mytopic'
}
gmail.users().watch(userId='me', body=request).execute()
We get a response with HistoryId. Tracking all the messages since the HistoryId can be done like this:
history = (service.users().history().list(userId=user_id, startHistoryId=start_history_id)
I found the below video helpful:
https://www.youtube.com/watch?v=wjHp9_NAEJo

Is it possible to build a telegram bot that aggregates posts of multi telegram channel?

Requirments:
1- Have a feed of posts that aggregate all posts of multi channels
2- have actions (bot command) on each post
3- When post of channel edited, correspondent post in the telegram bot edited too.
(If it is not possible, I want to know is it possible to edit a message that was sent to multiple recipients in one action or i have to change each of them by message id, chat id)
You can assume you are owner of all these channels and you set your bot as admin of all of them
Only creator/admins can add bots to channels and only as admins.
Bots (for now) can't read messages in channels.
Bots (for now) can't view any counters in channels.
So no such bot for now :(

How to have a telegram bot join a channel via link?

I would like to program a crawler bot which would surf channels and find the message with high view counts.
Is it possible to have a bot added to a channel via link?
Is it possible for a bot to read messages broadcast in a channel?
Is it possible for a bot to read view count value of a message in a channel?
If any of the above questions are possible, what is/are the solution(s)?
Only creator/admins can add bots to channels and only as admins.
Bots (for now) can't read messages in channels.
Bots (for now) can't view any counters in channels.
Finally, for now, bots can only post messages to channels and only if added to channel by creator or admin.

Send message to th all of bots users (telegram api)

how to send Send message to the all of bots users?
There is no way to sned message to all ?
what is the method name ?
From Official API FAQ:
How can I message all of my bot's subscribers at once?
Unfortunately, at this moment we don't have methods for sending bulk messages, e.g. notifications. We may add something along these lines in the future. (...)
Obviously, if you store users chat_id, you can send individual message to all users (I use this method).
Navid wants to send message to all subscribers via bot.
If subscribers are more than 100 persons bot will very slow to sending all messages and may doesn't send messages to all.
Navid's question was how we can send message without this problem?
you can send with curl_multi_exec
Currently, a developer would need to implement a special broadcasting function that would send the message to each active user at the time adding a small delay to avoid hitting the rate limit of 30 messages per second (see https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once). This would mean that a very popular bot with say 10K active users cannot give timely notification as the last user would get the message about 5 minutes after the first user.
Here is a feature request to ask to add a method in the Bot API to broadcast a message to all its active users at once. You can upvote this feature request. https://bugs.telegram.org/c/8463