Getting message info from Messages.app with AppleScript - applescript

I’m looking to get information about individual messages in chat threads in Messages.app.
I can get individual chat threads:
set firstChat to first chat
I can get everything I ever wanted to know about file transfers (media sent/received via iMessage):
get properties of the last file transfer whose direction is incoming
I can handle messages as they arrive (which is pretty magical):
on message received msg from bud
processIncomingMessage(msg, bud)
end message received
I just can’t figure out how to get information about individual messages. I’ve pored over the dictionary for Messages.app. It’s been super helpful up until I reach chat, then it seems I can’t get more specific than a chat thread.
The incoming message handler is great, but it doesn’t give me anything interesting in the message parameter. I can’t even get an index of the message.
Have I missed something, or is it not possible to get information about individual messages?
I have officially declared “f**k it” and given up on finding an AppleScript-y way of getting messages. Everything I need is encased in glorious SQLite (~/Library/Messages/chat.db). Thank you all for your help, I couldn’t have done it without you, keep up the good work, etc. etc.

tell application "Messages" to set lastmessage to subject of first text chat

Related

Unable to get timestamp of the message posted by Slack App

Whenever my app posts ephemeral message to Slack channel (in response to a query by a user), I am unable to get the timestamp of my Slack app response. As I want to delete it once the user has made a selection using one of the buttons. Although I have subscribed to 'message.channels' event, I don't get a notification to my app whenever my app posts in the channel (in response to the user input), therefore, I am unable to get the timestamp of the message which I'll use to delete it. All I want is the timestamp of the message posted by my app so that I can delete it but I am unable to receive the timestamp. Please help!
For e.g. in Giphy app for Slack. Let's say the user invokes the app by calling '/giphy [dog]' where 'dog' is just an example of a search term. The app responds by sending a gif and user can either send it, shuffle to the next one or cancel it. I want a similar capability of cancelling the app response but I need the timestamp of the message in order to do so therefore I am asking for help.
Thanks.
Your approach can not work, because Slack is handling ephemeral messages differently from "normal" messages. They are only visible by one user and can not be modified by API methods (e.g. deletion).
But of course its possible to replace ephemeral messages. Here is how:
Your app can just reply to the interactive message request from Slack with a new message. That new message will by default override the original message including ephemeral messages.
You can reply in two ways:
Directly reply to the request from Slack with a message within 3 seconds
Send a message to the response_url from the Slack request within 30 minutes.
See here for the official documentation on how to respond to interactive messages.
This approach works both with interactive messages and slash commands.
See also this answer for a similar situation.

Laravel/SES sporadically not sending emails?

Sorry about the vague title, I only have very vague information and have no idea where to get any more.
Some of the users of our app have reported they're not receiving emails now and again. We're using SES with Laravel to send them, when I went to test, they weren't sending for about half an hour, and then suddenly were sending correctly again.
Here's what we know:
All items in the queue were processed without issue
There's nothing at all in my error logs
Nothing of note in my SES console
Emails were definitely not sending
I changed nothing, and they suddenly are again
I understand that's probably way too vague for a meaningful answer, but does anyone know where/how I'd debug this? I can't find any record of any failed/successful sends.

SMS sent from twilo blocked by tmobile I believe

So to help debug we even take it out of our code and put it on twilio portal that lets us test the API. When I send to most of our group everyone gets the text message, but when we send to someone with tmobile, the message says it's delivered on twilio logs, but the person never gets it.
If we test and send him an 'Hello world' message, he gets it, but when we test with out SMS
'XXXXXX wants to make plans with you on the HotSauce App. :tada::hot_pepper:
Get the app now to join in on the action. https://rts2t.app.goo.gl/FGYB'
The message doesn't get delivered. Maybe there's a whitelist for Tmobile we can get on?
FYI, we have a USA number and this is a USA person and we are on the paid version, not trial.
I've encountered the same issue working on another app, and unfortunately I do not think there's a conclusive single answer. Carriers intentionally keep their spam filtering techniques secret so that they cannot be gamed. From Twilio's support page on the topic:
There is no standard practice for carrier filtering across all carriers. For some, filtering can range from a simple static list of prohibited terms to advanced machine learning systems that work in real time. Regardless of the system, carriers keep their filtering systems closely guarded secrets. In turn, Twilio cannot say definitively how these systems work or why a particular message was filtered.
Note that not all carriers report errors to Twilio, so some messages may appear to go through even though they were not delivered. You may or may not see error 30007 in the Twilio console when a message is blocked.
I don't believe any type of universal white-list exists, and once a number has been black-listed by a carrier there is no easy process to have it white-listed. However, short-code numbers are generally less prone to getting spam filtered (though they are more expensive).
While there isn't any one thing you can do to guarantee delivery, there are several things you can try:
Make the language of the text message more conversational as opposed to promotional
Don't obscure the url with a link shortener
Don't over-use a single number by implementing something like Twilio co-pilot
Include clear opt-out instructions

Receiving messages back to my platform

Use Case SMS leaves my platform and goes out to a receiver (SMS). I would like to attach some sort of custom identifier so when the user responds back to the SMS..and my platform received the message..I know how to internally route the response back in my platform.
Any ideas?
Maybe set up a system where when the code is sent out
For instance:
Code - 11832
The user then has to enter this code on your website. A program will then match to see if it's the identical code. So you are then able to log the information
No expert on this though and Where is your code ?
Twilio evangelist here.
There isn't really a great way to attach an identifier to the message itself. You could force the user to prepend/append a code in their reply, but depending on your specific scenario that might not be a great user experience.
Another option is to save the to/from phone number as a unique pair when you send the message. Then as your application receives replies you can check the incoming to/from phone number against what you saved.
Hope that helps.

HL7 2.X Standard Ackknowledgement

I am trying to write an HL7 message parser that will send a specified acknowledgment back to a messaging engine so that my applicaiton may receive the next message in line.
The interface engine that is sending the messages is call VISTA (has anyone ever worked with it?) I have been told that it expects to receive an 'Ackknowledgement ACK' if there is a value in MSH field 15. In all of the messages that I am currently receiving, I am getting a value of 'AL'.
I have basically set up my application to send a TCP message to a hostname/ip:portnumber that can be set before the applicaiton is started.
If possible, could someone provide a sample ACK message (without sensitive data of course) AND the non-whitspace characters that wrap the message?
I would like to make sure that I know what I need to send back to the sending application.
After some further research of my own, and the help of responses to this post, I have found that the following items are required to be included for the sending applicaiton to accept my ACK and move onto the next message.
The ACK must contain the following:
MSH|^~\&|Receiving App|Receiving App ID|Sending App|Sending App ID|DateTime of Message||"ACK"|Message Control ID|Processing ID|Version ID
MSA|AE <or> AR <or> AA|Message Control ID (MSH 9 from the sent message)
ERR| This particular segment is not required by the sending application
The problem I was experiencing pertained to my Sending and Receiving App IDs and Names were swapped.
Thanks for the help!
I haven't worked with VISTA, and my only current setup is returning an error ACK due to some application issue that I won't be able to debug right now, but in case it's helpful here's the error ACK:
MSH|^~\&|||||20100630130105.496-0500||ACK|20||2.3
MSA|AE|H20091222063637.9834
ERR|^^^207&Application Internal Error&HL70357
Note that this is HL7 v2.3 - the format may be different for other versions.

Resources