MSGraph - Getting external email conversation from reply - microsoft-graph-api

My team is building a ticketing system. The goal is when we receive a new email we create a new ticket. All responses to that email are saved on the same ticket.
We have these basic goals working in simple cases, however, there is one case that we are struggling to find a good solution for. A client will email us, which creates a ticket, and we reply back requiring information. The client will send our reply to someone internal to their company. Then they will send the response back to us by replying with "see below". This response will have the conversation between them and their co-worker in the comment section of the email. The comment section will also contain our entire email chain which we don't want to duplicate.
The issue we are having is grabbing the conversation they had from the comment section to include with their response of "see below" and add them to the ticket. The only method we have come up with to solve this is manually parsing the comment section of the email, however, this is error-prone.
Does anyone know of a better way of tracking conversations they send you through the email?
We are using msgraph internally to send and receive emails and using their apis they have uniqueBody and body, but they don't seem to have a way to break the body up into its different parts.
What I need any of these options
1- get list of unique bodies from the email chain without using conversation Id as it will not be sufficient in some cases.
2- get the previous conversation Id of the incoming email. I mean if that email is a list of emails and it forwards to me.

UUID uuid = UUID.randomUUID();
message.addProperty("InternetMessageId", String.format("%s",uuid.toString()));
send InternetMessageId with a unique identifier to grab conversation id
change order only

Related

Send and receive email by Rails App

We have build custom crm app(rails 4.0). One of the features that we have build is that we send emails to our customers based on booking status or we send a custom email by our travel agents.
The next thing we want is that customers can replt on this email. So we can recognize the email thats replyed and related to the initial email is send, so we have a nice email dialog (send/receive) in the crm.
Someone ideas how we can "recognize" the replyed email so we can related it to the right email?
Thanks..remco
In your email client open a reply from someone and show full headers or raw source (how to get it depends on the client but you will find it!)
When you look at the email headers you will find References field
References: <CAAC3oDjZSFywS5mpAANO+svm-3xXwLciUhw_QEkBkNqT9A#mail.com>
<06AFEF94-53D2-4469-59B0A494830C#mail.de>
<E67E3945-D61E-8E45-63C52D111698#mail.net>
And more importantly
In-Reply-To: <6397034C-90CA-41B4-F47AE3F39E76#mail.de>
While every outgoing email has a Message-ID field
Message-ID: <569F22.8060202#mail.de>
To get an if of you outgoing message
result = SomeMailer.message(params).deliver
result.header['Message-ID'].value

How can I get sendgrid entries from send email?

I use one sendgrid account in multiple projects, and use a same send email per project. Now I want to fetch the "Bounces" and "Invalid Emails" entries for specify project, can I get them with the same send mail?
SendGrid does not store the from address for consumption with these API's so what you are looking to do unfortunately isn't possible this way.
Two options I recommend looking into as an alternative are:
1) Use subusers. This will allow you to have separate accounts under the same parent account. You'd have to change your credentials and query for the bounces and invalid emails separately.
2) Use categories and the event webhook. SendGrid will send you a post request containing the event type and the category you added to the email.
there is also unique arugments option to send with emails. use this option as a name or id of the project. then later fetch status of these emails via this unique arguments.
I recently done this work, let me know if you need any help.

SMS parameters through twilio

I'm new to twilio and have the following situation. I want to send an SMS to someone for an appointment confirmation. They'll text back CONFIRM or CANCEL etc to the message.
Is there any way to pass an internal database id in the SMS to them and get it back in their response so i know what they're confirming or canceling? I'd rather it not be shown to the end user receiving the text.
Thanks!
Twilio evangelist here.
Unfortunately there isn't any way to transparently include metadata in an SMS and have that metadata returned to you when they reply, but there ways to address your scenario.
If you are sending the user a text message you already have their phone number and you can use that as a unique ID. When the user replies to your message, Twilio will as part of our HTTP request to your application, pass you the users phone number. You can use that number to locate them in your database and mark them as confirming or canceling.
Hope that helps.

Rails and email openened notifications

I am developing an application on Rails and I need to know if its possible to write code which will notify me when the user opens an email that has been sent from my application (need to track this info) ?
The main bit of data I need is was it opened.
thanks
You can do this but there is no 100% certainty you will always get a notification.
SMTP has 2 standards, they are DSN and MDN. Both are in effect optional, there is no guarantee that the email system of the targeted email recipient (your user) will implement them too.
The easiest way is to pit in a "Return-Receipt-To:" (RRT) email header. Put some address as the content of the header. Now when a user opens an email message containing this header, the clients email reader will msot likely prompt your users whether or not to send a return receipt. If the do comply and email will be sent to the address you specified.
In Rails it could be something like:
themailer < ActionMailer::Base
def notify_read
headers['Return-Receipt-To:'] = 'notifyread#mysite.com'
mail(:to => 'users#somecompany.com')
end
end
You could just use an email address you monitor and read them manually OR you could set up rails to read these emails as well. But there is no guarantee you will ALWAYS get an acknowledgment.
Additionally you could check each email domain, many of the big free email providers have proprietary methods of requesting the return receipt. If you add ".readnotify.com" onto the end of your recipients email address you will get a return receipt. You will have to research all the big ones though.
For example:
user#yahoo.com.readnotify.com
Hope that helps
Source: http://railsforum.com/viewtopic.php?pid=147997#p147997
A common way of implenting this is to include a link to an invisible image file, with the link including sufficient details about the email for you to be able to identify which email is being viewed.
When the image is requested by the mail client, your server can then record the viewing attempt. If you use a 3rd party email provider (such as sendgrid, postageapp) then sometimes they'll do that for you and ping your server with the appropriate event. I strongly suspect that this is what readnotify is doing under the hood (someone took the trouble of looking at this a while ago
This isn't completely accurate as some (many?) users turn off remote image viewing in their mail viewers.

How can I integrate internal messaging with emails in asp.net?

in github when a user sends you a message two things happen. You get a "new Message" on your github dashboard and you receive an email.
if you reply to that email it triggers a new Github message internally... so the users can actually have a full conversation through their email client without going into github even though Github is managing it all.
I know Malgun/Sendgrid have apis to manage receiving of emails (they send a POST request to your app when an email is received) but I need a little more info on how to do it... how exactly can I set up my app so that when a user receives a message they can just hit reply on their favorite email client while still maintaining track of that conversation. (they can still check their messaging history through my site)
Does anyone have an idea how exactly they do it?
Please help.
How this is implemented really depends on how you can handle incoming messages. If you're able to receive your emails as a POST to your application, then the email is really no different to a user sending the message on your site, you just need to parse the From: header from the email, and look up the user, and strip the fluff out of the email.
If you're writing your own code to handle the emails (eg. that polls a mailbox), then you could just POST them over to your app in the same way, or parse them up and POST more structured data.
Once you have the data, it's easy to construct a message and write it to your DB (and fire off email notification to the user, remembering to set the Reply-To: or From: headers so your script gets the replies). Most of these kind of messaging systems don't keep track of conversations/threads, but just store a string subject (and use "Re: ...") to keep things simple, though you could obviously add this if you're feeling ambitious!
If you're doing this, you should be security in mind - malicious users may POST to your email script, and email headers can easily be forged. Spammers will also use any possible scripts they can find to relay mail through other peoples servers.

Resources