Jump to content

I need an AppleScript that give random reply if conditions are met

Recommended Posts

I am wondering if it would be possible to write a very simple chat room bot which is fairly dependent of what kind of message is received.


The scenario is that I’m working on auto reply to my friends that are often posing messages on our own chat page.

So, the script would continually check the browser for new messages (without reloading the page) for a particular string just appearing from the bottom of the field. If the string contains the following text: “... has just logged in!” the script is to select the first word of the string, place a comma “,” behind it and then write “Hi, buddy, I’ll be back in a bit.” and then respond by pushing the ENTER bottom. But before pushing ENTER/posting the message it has to wait 7 seconds


After posting this, wait again for 5minutes before replying to Anyone, based on the same conditions as above. Repeat indefinitely. 


I would also like to have random replies from the following list:
1. Hi, buddy, I’ll be back in a bit.
2. I’m not available at this moment. Contact me by mobile. 
3. Please don’t disturb or ping me. I’m studying.
4. In my way to grandma. Will log in when I get there.
5. REMINDER: Scoccer training on Monday. 



I was thinking Applescript could be an easy way to do this. Can anyone possibly help get me started? Like I said, I'm a beginner, so please keep that in mind. Trying to use this as a learning experience, as I learn best by trying to come up with a solution to a particular scenario rather than by books or tutorials.

Should be executed on the active/open safari browser 

Thank you very much in advance.

Link to comment

Welcome @Sonny,


This problem isn’t Alfred-related (it’s not even macOS-specific, really) and isn’t something Alfred will be able to help you with. It should be asked about somewhere else more general, like Stack Overflow (but not there).


AppleScript would be a terrible choice for this. It’d be one thing if you were chatting via iMessage (where Apple gives you tools for automated replies), but if the chat is in a webpage you’ll have to do it via JavaScript. It’s not straightforward, and it’s made even worse by you wanting to do it in Safari (not impossible, but the final implementation might be more cumbersome due to how restrictive it is with extensions).


From your description, you seem to be too novice for such a task. My suggestion is that you either pay someone to do it for you or scrape the thought for now and go start with something simpler (basic understand of using JavaScript to manipulate a web page).

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...