Signature extraction in Nylas v2
The Nylas Neural APIs are the intelligence center of the Nylas platform. They provide machine learning capabilities that abstract complex AI techniques into functional capabilities, and can be applied to any data connected to Nylas. You can easily implement the Neural API without any previous AI training or machine learning expertise.
Signature Extraction extracts email signatures by removing extra images and HTML. You can use the extracted signatures to create contacts and keep your data up to date.
This page explains how to extract signature data and train the Nylas machine learning model.
Parse a signature
Before you can parse an email signature you’ll need to have the message_id
of the message you want to parse the signature from. Use the /messages
endpoint to get a list of message IDs.
Then you can parse the signature by sending a PUT request to /neural/signature
. You can parse up to 20 messages.
Example: Parse signature request
- message_ID: The ID of the message. Required.
- ignore_links: Remove links in the conversation or signature. Default
true
. - ignore_images: Remove images in the conversation or signature. Default
true
. - ignore_tables: Remove tables in the conversation or signature. Default
true
. - remove_conclusion_phrases: Remove phrases such as
best
andregards
in the signature. Defaulttrue
. - images_as_markdown: If set to false, returns images as HTML. Default is true. This only works if
ignore_images
is set to false. - parse_contacts: A contact object is returned that includes phone number, email, job_title, and url. Default
true
.
curl --location --request PUT 'https://api.nylas.com/neural/signature' \
--header 'Authorization: Bearer <access_token>' \
--header 'Content-Type: application/json' \
--data-raw '{
"message_id": ["<message_ids"],
"ignore_links": false,
"ignore_images": false,
"ignore_tables": false,
"remove_conclusion_phrases": false,
"images_as_markdown": true,
"parse_contacts": false
}'
Parse signature response
Some of the fields returned in the JSON response are:
- body: The body of the email message the signature came from.
- signature: The parsed signature information. Extra HTML and images are removed.
- model_version: Version of the model parsing out the signature.
- contacts: Returns a contact object if
parse_contacts:true
.
[
{
"account_id": "5tgncdmczat02216u7d6uypyi",
"bcc": [],
"body": "......" [{
"email": "swag@example.com",
"name": "example Swag"
}],
"contacts": {
"job_titles": [
"Director of Engineering"
],
"links": [{
"description": "Albert Einstein",
"url": "https://www.example.com/"
}],
"phone_numbers": [
"123-456-8901"
],
"emails":["al.einstein@example.com"],
"names":[{
"first_name":"Albert",
"last_name": "Einstein"
}],
},
"date": 11234567890,
"events": [],
"files": [],
"from": [{
"email": "albert.einstein@example.com",
"name": "Albert Einstein"
}],
"id": "b2l4g9qk0k85mx5dqm1q9sse8",
"labels": [
{
"display_name": "Important",
"id": "c2ig7rwrpethf9bqoaq7tnerm",
"name": "important"
},
{
"display_name": "Inbox",
"id": "cgf6uw9mvagi1fibv67kgz7z",
"name": "inbox"
}
],
"model_version": "0.0.1",
"object": "message",
"reply_to": [],
"signature": "Best Regards,\n\nAlbert\n\nAlbert Einstein\n\nDirector of Engineering\n\nPhone: +1.234.567.8901\n\nSkype: AlbertEinstein \n\nParticle Technologies™",
"snippet": "Hi Nylas, Thanks for reaching out. I look forward to working with you in the future.",
"starred": false,
"subject": "Welcome To Nylas",
"thread_id": "9x4ymoysw7p0pwabpkbt1o0ql",
"to": [{
"email": "swag@example.com",
"name": "Nylas Swag"
}],
"unread": false
}
]
[
{
"account_id": "**********",
"bcc": [],
"body": "<div dir=\"ltr\">Welcome to Nylas! Visit us at <a href=\"https://nylas.com\">nylas.com</a>.<br><br clear=\"all\"><div><br></div>-- <br><div dir=\"ltr\" class=\"gmail_signature\" data-smartmail=\"gmail_signature\"><div dir=\"ltr\"><br><table style=\"border:none;border-collapse:collapse\"><colgroup><col width=\"84\"><col width=\"540\"></colgroup><tbody><tr style=\"height:79pt\"><td style=\"vertical-align:top;padding:5pt;overflow:hidden\"><p dir=\"ltr\" style=\"line-height:1.2;margin-top:0pt;margin-bottom:0pt\"><a href=\"https://www.nylas.com/\" target=\"_blank\"><span style=\"font-size:11pt;font-family:Arial;color:rgb(17,85,204);background-color:transparent;vertical-align:baseline;white-space:pre-wrap\"><span style=\"border:none;display:inline-block;overflow:hidden;width:70px;height:70px\"><img src=\"https://lh6.googleusercontent.com/zJp7cuIKWhNYHc6KsuHUsfrhyCp9DKxg243bjSLP9JKi9SEX-uMtTAr5qy54Kdlr3RNkTwAEvIDHKBCjodqu8uVLLbReY47_-KtRilUatWsZRRfO2LH9ZTCykLEVBOj8iJ7XmNeX\" width=\"70\" height=\"70\" style=\"margin-left:0px;margin-top:0px\"></span></span></a></p></td><td style=\"vertical-align:top;padding:5pt;overflow:hidden\"><p dir=\"ltr\" style=\"line-height:1.8;margin-top:0pt;margin-bottom:0pt\"><span style=\"font-size:10pt;font-family:"Source Sans Pro",sans-serif;color:rgb(0,0,0);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap\">Nylas Product Team</span></p><p dir=\"ltr\" style=\"line-height:1.38;margin-top:0pt;margin-bottom:0pt\"><span style=\"font-size:8pt;font-family:"Source Sans Pro",sans-serif;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap\">Nylas Team, </span><a href=\"https://www.nylas.com/\" target=\"_blank\"><span style=\"font-size:8pt;font-family:"Source Sans Pro",sans-serif;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap\">Nylas</span></a></p><p dir=\"ltr\" style=\"line-height:1.38;margin-top:0pt;margin-bottom:0pt\"><span style=\"font-size:8pt;font-family:"Source Sans Pro",sans-serif;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap\"><a href=\"mailto:swag@example.com\" target=\"_blank\">swag@example.com</a></span></p></td></tr><tr style=\"height:63pt\"><td colspan=\"2\" style=\"vertical-align:top;padding:5pt;overflow:hidden\"><p dir=\"ltr\" style=\"line-height:1.2;margin-top:0pt;margin-bottom:0pt\"><a href=\"https://www.nylas.com/resources/savings-calculator-integrations/\" target=\"_blank\"><span style=\"font-size:11pt;font-family:Arial;color:rgb(17,85,204);background-color:transparent;vertical-align:baseline;white-space:pre-wrap\"><span style=\"border:none;display:inline-block;overflow:hidden;width:306px;height:45px\"><img src=\"https://lh3.googleusercontent.com/bTFwY25C4D9lD4GJHxsVEWr8--YG25chLhjDJb3rWpmXPw5RngwZHUWhbDracmaXL7n6mtt5JPM9egiGaFwU2bNKMrvMcctgvrHFOI7YxIzze7CTKKVJRqD8kq2hNUE2IJiPWFmL\" width=\"306\" height=\"45\" style=\"margin-left:0px;margin-top:0px\"></span></span></a></p></td></tr></tbody></table></div></div></div>",
"cc": [],
"date": 1608244897,
"events": [],
"files": [],
"from": [{
"email": "carver@example.com",
"name": "George Washington Carver"
}],
"id": "177hfdrslcgl6x1srf3d3arez",
"labels": [
{
"display_name": "Important",
"id": "c2ig7rwrpethf9bqoaq7tnerm",
"name": "important"
},
{
"display_name": "Inbox",
"id": "cgf6uw9mvagi1fibv67kgz7z",
"name": "inbox"
}
],
"model_version": "0.0.1",
"object": "message",
"reply_to": [],
"signature": "\\-- \n\n[![](https://lh6.googleusercontent.com/zJp7cuIKWhNYHc6KsuHUsfrhyCp9DKxg243bjSLP9JKi9SEX-\nuMtTAr5qy54Kdlr3RNkTwAEvIDHKBCjodqu8uVLLbReY47_-KtRilUatWsZRRfO2LH9ZTCykLEVBOj8iJ7XmNeX)](https://www.nylas.com/)\n\n|\n\nNylas Product Team\n\nNylas Team, [Nylas](https://www.nylas.com/)\n\n[swag@example.com](mailto:swag@example.com) ",
"snippet": "Welcome to Nylas! Visit us at nylas.com. -- Nylas Product TeamNylas Team, Nylasswag@example.com",
"starred": false,
"subject": "Welcome to Nylas!",
"thread_id": "bhqzyakvpbepbn04lhnkj6rki",
"to": [{
"email": "dorothy@example.com",
"name": "Dorothy Vaughan"
}],
"unread": true
}
]
What the signature was extracted from.
Signature feedback
If a signature was parsed up in the way you didn’t expect, you can send us feedback using the /neural/signature/feedback
endpoint. We will use this data to retrain our model for better results in the future.
Send a POST request to /neural/signature/feedback
with the request body:
- message_id - ID of the message you want to give feedback on.
Example: Signature feedback request
curl --location --request POST 'https://api.nylas.com/neural/signature/feedback' \
--header 'Accept: application/json, application/gzip' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <access_token>' \
--data-raw '{
"message_id":"<meesage_ID>"
}'
Example: Signature feedback response
The JSON response includes:
- model_version: Version of the model parsing out the conversation.
- message_id: ID of the message that was not parsed correctly.
- feedback_at: Unix time feedback about the message was most recently given.
{
"model_version": "av45hcbkka",
"message_id": "812yzs4goqf4sl4ofswvalt4u",
"feedback_at": "1607537180",
}
Keep in mind
- Only English is supported.
- No SDK support.
- Job Status and Webhooks are not available.