How to open a new slack channel with hubot - hubot

I want to open a new channel on slack using hubot. The use case is straight forward. Hubot observes external events and in case of a certain events I want to open a new channel and and invite other users.

it seems to me that once you have the correct api key setup, you just need to send a call to the following end point
https://slack.com/api/channels.create
The api is documented here

Related

Simplest way to get a list of new posts from a telegram channel via API

I'm trying to write a simple server side script that will run every once in a while and check for new messages in certain Telegram channels. I've created a bot, but it looks like a bot can't me a member of a channel, so bot API is of no use here. So what I fugured I need to do is to write a very basic set of requests to do authentication with my own credentials and then fetch messages from certain channels I'm subscribed to and then check if any new messages are there.
Is it possible to do this on a very basic level with HTTP requests, without having to learn and use bot frameworks and such?

How do I send & receives Telegram messages programmatically?

I want to create an app that sends telegram messages to different people by phone number, and/or telegram id.
I've heard about the "Telegram Bot API", but from my understanding it has some limitations (like it can't send messages unless users authorize it and send the first message to it, and it doesn't support sending messages using phone number)
And there is the "Telegram API", which looks like a lot of work and coding..? I'm a 1 man developer and I don't want to spend years to create a Telegram app from scratch that talks to telegram servers and does all the protocols and then I have to update it constantly and so on and so fourth.
I just want something that is easy to code & maintain, and can use my telegram account to programmatically send/receive messages. That's it. Something like :
send.message(phone number, message)
or some sort of REST API that let's me authenticate my telegram account and then provides methods that I can use to send messages to contacts.
Any ideas on how I can implement this? Any pointers would be appreciated!
Have a look at MTProto libraries like telethon or pyrogram. They are user-friendly (with lots of helper functions to abstract raw telegram api calls and their interfaces somewhat resemble the telegram bot api)
Here is a sample code (from the telethon docs):
from telethon import TelegramClient
# Remember to use your own values from my.telegram.org!
api_id = 12345
api_hash = '0123456789abcdef0123456789abcdef'
client = TelegramClient('anon', api_id, api_hash)
async def main():
# You can send messages to yourself...
await client.send_message('me', 'Hello, myself!')
# ...to some chat ID
await client.send_message(-100123456, 'Hello, group!')
# ...to your contacts
await client.send_message('+34600123123', 'Hello, friend!')
# ...or even to any username
await client.send_message('TelethonChat', 'Hello, Telethon!')
with client:
client.loop.run_until_complete(main())
Actually, telegram did a decent job to provide a powerful yet very simple API for its Bots (Attention: You can also use telegram applications like MadelineProto or telegram CLI to send messages and this is different from using Bot APIs. The applications are like your mobile/desktop app and use a real account with a particular authenticated phone numbers and you can do mostly anything that you can do with your phone app. But this is a different story).
For sending messages using bots, you can find all the documentations here. To use these APIs, you need:
Create a bot using Bot Father robot: he will help you to create a robot and will eventually give you some secret token that you should use with your robot
Some users should "/start" your robot. After starting a robot or any communication from user, you have two different options: (i) you can read the updates by a polling the updates from Telegram server using update method or (ii) setting a webhook: this way, telegram will call that webhook to make you inform about the message. Either way you use, to send message to an account you need the so called "chat_id" of that user (and you should obtain it using one of the mentioned approach)
The final step is to send a message: for the simplest case, you want to send a simple text message to a person with some particular chat_id. You only need to call this URL (i.e. the API):
https://api.telegram.org/bot{BOTTOKEN}/sendMessage?chat_id={CHAT_ID}&text={SOME_TEXT}
With this sort of calling REST api, you can call many of the functions and this is only the first step and you can do much more complex and fun stuff! For many languages, there are some packages to work with the API which make everything simple and abstract to developers. A list of most popular packages could be found here.

I want to know how the botbuilder listen,and where it listen?

We have created Robot on hipchat and yammer with hubot, and they worked very well.
Recently, our team want to create a bot using hubot on Microsoft Teams, but met some problems.
I read the guide document and find that we should first allow external apps in Microsoft Teams .We should ask our Microsoft Admin team to help to open this on. Now, we are review this with our security team about this.
There is something I want to get from you:
1.I find if I want to active the hubot, I should first set an endpoint, what is this used for? Why should we set this?
When we enterprise hubot with hipchat and yammer, we just need an account, set the user name and password, tell hubot the group
Name we want hubot join, and it worked like a normal user.
2.I found “#robot.router.post #endpoint, #connector.listen()” in the code,
So, how the botbuilder listen,and where it listen?
3.Are messages all transport by http? Is it safe enough?
I just went through setting up our Hubot in teams as we will be moving from Hipchat and thought I could answer some of these questions.
The endpoint is used to send messages to your bot since it does not join as a user like Hipchat. When run with the botframework adapter /api/messages is used for communicating with your bot by Microsoft.
I'm not certain where in the code it listens but you have to # mention the bot in order for the app in teams to send the message to the bot's endpoint
The endpoint has to be HTTPS, meaning you have to proxy Hubot. The endpoint also has to be publicly available, or at least available to the Microsoft IP range. However, I found there is authentication that happens:
while anyone can technically post to your api/messages endpoint, the message coming in has a JWT token signed by AAD to verify that it came from a proper source. The botbuilder SDK (package that this adapter relies on) does this check for every message. Every response is also authorized with a JWT token that your bot retrieves from AAD for us to verify as well.
Reference:
https://github.com/Microsoft/BotFramework-Hubot/issues/25#issuecomment-402223551

Check SIM status by USSD query from site

I want to check anyone phonenumber's online status by query from serverside without any notice to user. Is it even possible?
An operator can see the latest location updates etc from a mobile device, but I am guessing this is not your use case.
To do it as a third party service, you would need to either implement an instant messaging like availability service or leverage or extend an existing open source one like Tox (https://tox.chat), Telegram (https://telegram.org), Linphone (http://www.linphone.org) etc.

With the GMail API, what's the preferred way to get new messages?

The app I'm making needs to monitor the Inbox for new messages. As far as I am aware, there is no way yet for the GMail API to push a notif to me when a user has a new message (Push notification for new gmail).
I could check every minute for new messages by using the history IDs. Is that the current best method outside of implementing a full IMAP solution (which would no longer be utilizing the GMail API)?
The most efficient Gmail API method would be to use history.list(). Specify a labelId of Inbox (so you're not seeing updates on other labels) and a historyId of whatever the largest historyId you've previously seen is (you'll need to track this). If you get back a 404 error, you'll need to use messages.list() instead to perform a full sync.

Resources