Sending a private Teams message within Linux - linux

Is it possible to send a private message in Teams using the Linux command line or Linux app? Now it's well known how to send to a channel using a curl command. However, I require to send a Teams private message to an individual programmatically? Is this possible?

You can try using deep links to achieve some automation programmatically. https://teams.microsoft.com/l/chat/0/0?users=gaurav.kumar#xxx.com&message=Hi%20folks%2C%20kicking%20off%20a%20chat%20about%20our%20meeting%20tomorrow
See also: https://learn.microsoft.com/en-us/microsoftteams/platform/concepts/build-and-test/deep-links?tabs=teamsjs-v2

It's definitely possible to do this, but instead of controlling the Teams client directly, use the Microsoft Graph API - see https://learn.microsoft.com/en-us/graph/api/chatmessage-post?view=graph-rest-1.0&tabs=http
Specifically, you'd want to use the "Delegation" security option, to send the message as if it was coming from you personally.

Related

Slack API send commands via webhook

I am not sure if what I am trying to do is even possible. I have a Slack App and via that SlackApp I want to control another Slack App which is not mine.
That's probably too abstract, so let's get into detail:
There is the SlackApp Foodtrain. If you are a user you just type "/lunchtrain Location Time" and it does it's job. I want my App to activate a Lunchtrain but if I just send a Message via Webhook thats '/lunchtrain Location Time' it doesn't activate the command. You can see it in plaintext. Is there any way to do this properly?
Thanks everybody for the help!
The official Slack API does not allow you to issue slash commands, but there is an undocumented API method called chat.command that has this functionality.
Usage example:
https://slack.com/api/chat.command?token=TOKEN&channel=C123456789&command=/who
Check out the documentation for the method on this github for details.

How to send facebook message from linux console (command-line)

Old days many admins use sms-gates for sending important informations from their systems e.g. "Power down, UPS is working now!", "Power Up, UPS is off!" or "CPU Temp too high!". Today in Facebook era we use messenger instead of SMS, so I wonder if I could create a command-line bash or php script for such thing.
The idea - cron checks every 10 minutes the condition and if it is true, sends message to my messenger.
The issues:
I don't want to use my fb account for sending - I'd like to get message
from "System 1", "System 2", because i have more than one system to
admin.
The bash part is easy for me, I need tips for Facebook solutions:
do I have to get FacebookAppId (and do I have to create AppId for
each system or just one AppId)
how to "join/confirm/accept" "System 1" account with my Facebook Account
is it possible to send messages to more than one FBAccount
any other hints what should i look for.
I found Notification App, but i think that it doesn't send message to messenger, so it would be useless.
The Chat API was removed with v2.0 of the Graph API, there is no way to send messages with an API anymore. Btw, messages are for communcation between real users, they should not be used as notification system anyway. SMS is still a good option for those kind of warnings imho.
Using a Page and the /conversations endpoint would not work either:
Pages can only reply to a message - they cannot initiate a conversation. Also, a Page can only respond twice to a particular message, the other party will have to respond before they can reply again.
Source: https://developers.facebook.com/docs/graph-api/reference/v2.3/conversation/messages#publish
I think for your special purpose, twitter may be a better option. Twitter accepts tweets from API. So what you need to do is to set up an account to publish your system status either regularly or event-triggingly and follow it in your own personal account.
And there are already plenty of open source projects focusing on tweeting via API, and t is the one I am currently using.
So there are a couple of command line apps to do this.
There is a libpurple extension (https://github.com/dequis/purple-facebook) which works. However purple doesn't seem to support the idea of message history. This is a shame since I imagine offline messages is the default way most people use facebook.
There is an single use command tool for facebook as well: https://www.npmjs.com/package/fb-messenger-cli which does support history. Unfortunately this is a TUI rather than a command line application and doesn't seem to depend on a separate facebook library.
Some hacking or terrible expect glue could work around this.
I just published a service exactly for that use case :
https://www.nimrod-messenger.io/
It's at an early stage. Feedbacks are more than welcome :-)
Sending facebook message in bash script
IDEA
I needed a script (which work on my work/local mac) that checks server. If there are problems, script will send me messages on Facebook.
Dependencies
need to install: https://github.com/mjkaufer/Messer
Solution, bash script
FB_SENDER_LOGIN=""
FB_SENDER_PASSWORD=""
function send_fb_message {
FB_MESSER_COMAND="messer $FB_SENDER_LOGIN $FB_SENDER_PASSWORD --command='m \"$1\" $2'"
eval "$FB_MESSER_COMAND"
}
RECIPIENT_NAME_DISPLAYED_IN_FACEBOOK_WEBSITE="Vasily Bodnarchuk"
MESSAGE="Houston, we have a problem!!!"
send_fb_message "$RECIPIENT_NAME_DISPLAYED_IN_FACEBOOK_WEBSITE" "$MESSAGE"
Automated Facebook message
I was looking for something like this exactly and found that Messer is the way to go.
Solution
Look at this repo called Messer https://github.com/mjkaufer/Messer
(it works with 2FA too but not with app passwords)
Implementation
See Readme
I needed it to run automatically so I used it's non-interactive mode with a bash script:
message="Hey, what\'s up bro"
FULLPATH/node_modules/.bin/messer --command="m \"Myfriends Name\" $message"
I don't like to install something like this globally through NPM so I used the /node_modules/.bin/messer executable in the project's folder.
Used double quotes escaped instead of single quotes to be able to use variables inside command.
Drawback: Messer can only send, not receive.

trigger a .sh script when a specific subject email is received

Anyway, I have a script that I want to run whenever I receive an email on gmail. And if possible a subject specific email. is such a thing possible and if so, what programs do I need to allow it.
You can't instruct gmail to trigger an external script for you. I think you've got a few basic choices. In order of increasing difficulty and complexity:
1) Configure a gmail filter to deliver your desired messages to a special folder. Write a script to poll that folder, download (or delete or mark as read) messages it finds there, and then launch your local script. Set up a cron on your local machine to run the script every few minutes. You can poll the folder with IMAP or the GMAIL API. IMAP is probably easier. This will be tricky with shell, you're better of with Python, PHP, or similar.
2) Configure a gmail filter to forward your desired messages to an address on a mail server that you control. Use procmail or similar to intercept the incoming messages and launch your script.
3) Set up an account at Mailgun and configure the emails so they get delivered there directly. (Or forward from gmail as in #2.) Configure Mailgun to launch an API request when it receives messages. Build an API handler to receive the request. Launch your process from your API handler.
I have never done it, but I guess the first thing you should do is to take a look at the Google's Gmail API...
What is the Gmail API?
The Gmail API gives you flexible, RESTful access to the user's inbox,
with a natural interface to Threads, Messages, Labels, Drafts, and
History.
It seems to fit what you want - at least, without knowing the details of what you want to do.
The Gmail API can be used in a variety of different applications,
including, typically:
Read-only mail extraction, indexing, and backup
Label management
(add/remove labels)
Automated or programmatic message sending
You can use several programming languages - maybe the trick is using your programming language of choice to write a wrapper for the .sh script... I hope this helps!

Can I build an addin for Gmail?

Is there a way I can create an addin for my Gmail account? Is GreaseMonkey the only real way?
I use Gmail for customer service, and I'd like to create a tool that looks up the customer and preps a response to them based upon who it is in my database... instead of looking by hand for the client and typing it out.
You can add gadgets (same as iGoogle and wave) and add them to the side bar in GMail, but you will not have access to the e-mails themselves. You could create small lookup forms and such, though.
I don't see how else you could do it. You won't be able to run your own app on Google's backend, so that leaves the client (with javascript and something like GreaseMonkey) and your server (perhaps communicating with the client via AJAX).

How to Send Group Sms?

Can we send SMS programatically by selecting group from the address book using J2me?
yes... it is possible to have access to the users phonebook (if supported on the device(most modern devices do allow it)) via PIM(JSR 75).
And sending SMS's from j2me is also possible(again if the user allows this).
It turns out you can only send a single message to a single recipient at a time using JSR-205.
If you want to send the same message to many recipients, you have to loop around
javax.wireless.messaging.Message.setAddress();
javax.wireless.messaging.MessageConnection.send();
There is no way to add a javax.microedition.pim.ContactList to a Message or to a MessageConnection because there can't be any API dependancy between JSR-205 and JSR-75.
The latest JavaME SDK contains example code that shows how to read contact data in a MIDlet.

Resources