Get Message Without History From Gmail API - google-api

I'm using the Gmail RESTful API directly (not from some library).
Looking at the documentation here Gmail Documentation.
I have managed to get the content of the message body, however it also returns the whole history chain for the current message.
Is there a way to get a response from the API only the requested message body, without the whole thread history?

According to this thread, it is not possible because it is part of the email's body content and you're specifying the ID of the message to retrieve.
You are getting the full reply message. When the report replied, they quoted the original message and this the text of the original is in the reply message. You may just want to do what Gmail and many other modern emails apps do and collapse/hide any reply text which begins with >.
References:
How to get the reply message without the original message from the Gmail API
GMAIL API : How to get the reply without the original message
Most efficient way to get new messages

Related

Message sent by Microsoft Teams bot is not displayed in the conversation

I have tried to send MS Teams bot message request via rest api:
End point: https://smba.trafficmanager.net/ca/apis/v3/conversations/{conversation id}/activities
{"text":"test","type":"message"}
And got empty response:
{}
The message i sent did not appear in the conversation.
Any idea where i could have misconfigured?
It is possible that trustServiceUrl needs to be run before a message is sent, i can't find equivalent rest api to call.
You definitely do need call trustServiceUrl before sending the message. In addition, you need to have additional properties on your activity, like the destination user or tenant id. Please refer to the documents on this, and good starting places are here and here.

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.

Twilio: responding to incoming SMS message

After I send a sms message to a particular phone number, how do I track the potential conversation?
I see that there is the URL within my Twilio account that Twilio sends http requests to.
Do I just keep checking this URL and go through the messages from the user, using the "from" field in the JSON data?
Twilio developer evangelist here.
When someone responds to your Twilio number then that URL you set in your account will receive a POST or GET request (your choice) with all the details of the message. You don't need to check that URL, the information will come to you.
You could then use the REST API to gather the messages that have gone back and forth between your app by calling for all the messages sent to the user's number and all the messages received from the users number.
You can also, in response to an incoming SMS message, set cookies that can be retrieved as part of the HTTP request. So, if you want to save some data between messages that's a way to achieve that. Here's a guide on using cookies to track SMS conversations.

How track responses for an SMS to multiple recipients with the Twilio API?

I would like to send a text message survey (eg. "How happy were you with X service? Reply 1 for satisified, Reply 2 for not satisfied") to multiple recipients. From the responses, I would like to create a report on the recipients that responded 1 vs the ones that responded 2. What is the best way to do this with the Twilio API? Does my app need to store the results from my incoming SMS message or does Twilio store these so I can query the results? If the former is the case and TwiML is involved, how do I parse the response and store the result? Thanks!
** Disclaimer: Twilio evangelist here **
Chirag:
So it sounds like you have two requirements here:
Use Twilio to send outbound text messages to different recipients
Capture a users reply to that message
For the first requirement, you can start by going to Twilio.com and signing up for a new account. Its free to start and we give you a Twilio phone number you can use to start to build your app. Once you have the Twilio phone number, you can use the REST API to start sending outbound text messages from that Twilio phone number. We have a quickstart that shows you how to do this:
http://www.twilio.com/docs/quickstart/php/sms/sending-via-rest
Note that this link goes to the PHP sample, but you can use the drop down at the top of the page to pick from other stacks like .NET, Java, Python or Ruby.
Once you've sent an outbound message you need to capture the replies to that message (your second requirement). Twilio uses something called a webhook to notify you about incoming SMS messages.
A webhook is basically a URL exposed by your application and associated with your Twilio phone number. You can configure the URL associated with your phone number in the Twilio dashboard.
Each time we receive an incoming SMS message on your Twilio phone number, we will make an HTTP request to that URL. As part of that HTTP request we send along metadata about the inbound message like the phone number that the message was sent from and the Body of the message. The full list of parameters we send is here:
http://www.twilio.com/docs/api/twiml/sms/twilio_request
Now your app can pull those parameters out of the request and do whatever it wants with them. Since we already are sending the body of the message as we receive it, Tims suggestion of tracking the responses based on the From parameter and storing the message body in your own database is a good suggestion.
This quickstart shows receving an incoming text message, grabbing the From parameter and then responding by sending back from TwiML:
http://www.twilio.com/docs/quickstart/php/sms/replying-to-sms-messages
In your case, if you don't want to reply to the incoming message, just omit the TwiML response.
Hope the helps. Lets me know if you need more info.
Devin
Track the responses using the From parameter (and using Body to identify the selection). Yes, Twilio stores those messages, and you could query the API - but it's likely better to just store it in your own database.

Sending XMPP message to offline Google Talk user with ruby xmpp4r

When using Perl's Net::Jabber, sending a simple message to an offline user causes the message to be delivered to the user when he comes online (it even show's in the user's gmail account as unread messages). That's as simple as doing
my $msg = Net::Jabber::Message->new();
$msg->SetMessage(...);
$connection->Send($msg);
In Ruby xmpp4r, doing the same equivalent thing does not send the message to an offline user, instead returning (async) a xmpp service-unavailable stanza or even not returning anything, and also not working. Message is simply lost.
How can one send an offline message with xmpp4r?
Also, in related subject, in xmpp's api docs for Jabber::Stream's send method, there is a "block" parameter. How does one use that?
Thanks
Make sure that you're doing type=:chat on the message.
client.send(Jabber::Message.new(jid, contents).set_type(:chat))
(code copied from Ricardo Pardini's comment, for long-term clarity)

Resources