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.
Related
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.
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.
I am following this Echo Bot Tutorial, and have gone through all of the basic steps regarding setup and registration. I am following the steps (near the bottom) regarding local testing, and have been using ngrok successfully.
I was able to add my Skype Bot as a contact, and I also have the latest version of the Skype app (Mac). When I send a message to the bot via the Skype app, I see the message appear in the debug notes in my terminal window. So I know that the messages I type are coming through.
I also see this:
skype-sdk.MessagingServiceClientV2 Sending message to 8:username with content Hey 8:username. Thank you for your message: "test".
However, I do not see any kind of reply in my Skype application. My expectation is that the bot would echo back my message to me.
My questions are:
1) When testing locally using the ngrok method described in the tutorial, should I be able to see activity from the Skype bot (in terms of messages to me)?
2) I am guessing this may be some an authentication issue? How can I best troubleshoot things, and get the Skype bot to actually respond in the Skype app?
I feel like I am incredibly close to getting this working, in that the messages I send are coming through... but the messages I expect from the Skype bot are not coming through. Any help or ideas greatly appreciated!
Found the fix, and posting it here should anyone else run into the same issue.
During the setup process, when I was using the Application Registration Portal, I selected the wrong string as my Application Secret.
Originally, I clicked on Generate New Key Pair, which resulted in a new entry appearing in the admin labeled Private Key. I used this string as my App Secret.
However, it appears that what I should have done was click on Generate New Password and used *that string instead**. Just gave it a try, and my bot is now responding back to me locally (in the Skype app), when testing with ngrok.
I think this particular distinction could have been made clearer in the documentation, as I lost a great deal of time due to this one oversight. Oh well, at least I can start developing now...
I tried to execute gmail api's watch on my two gmail accounts and it works fine.
But when the other user tried to do so, it shows this error:
HTTP error 400 : "Only one user push notification client allowed per developer (call /stop then try again)">
I don't know if the problem is on the pub/sub client configuration or doing stop and watch will resolve the problem?
Can someone explain the meaning of this statement "Only one user push notification client allowed per developer"?
Try using a different project for the Cloud Pub/Sub topic that the other user wants to set up a Gmail API watch on.
You can always renew a watch by first stopping the watch and then immediately initiating a new watch right after. So, try to use users.stop once before you use users.watch.
I have encountered a similar issue. Although this might not be helpful to the OP, for me the solution was to abandon Google's Pub/Sub and use IMAP IDLE instead, which is much better suited for OP's use case of monitoring several inboxes.
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!