Sendgrid: How to add a dynamic link to an email template? - sendgrid

I am trying to have a link in my email template that would sort of look like this:
<a href={{url}}>click here</>
The above link has been added in de "designer" by adding a "custom" link. The value for this like I enterd as {{url}}.
I pass an url value in the dynamic_template_data, like so:
const msg = {
to: savedAdmin.email,
from: process.env.EMAIL_ADDRESS,
templateId: process.env.SENDGRID_NEW_ADMIN_TEMPLATE_ID,
personalizations: [
{
to: [{email: savedAdmin.email}],
dynamic_template_data: {
name: savedAdmin.first_name,
url: process.env.CMS_URL,
email: savedAdmin.email,
password: randomPassword,
},
},
],
};
However, the url gets rendered like this when I receive the mail in my inbox:
http://url9905.myweb.shop/ls/click?upn=BMmHdsRoNrbb0-2FMI-2BBVvCjpDiCceHLG5U2u5OCf29QV6iCtfuvZYId1FE95cTz9uyMY31z9fQ7iR-2BPgq-2FkquvxdAPC0oMKiLa3DRglYUSVP-2FRmYbDQ-2BdFGnczXk75K3Ym8rSodsrAy-2BfNDJwqA7RDeemPFjepjRsUdci9CA6Y0-....
How do I get this to work?

Sendgrid is replacing your link with a intermediary redirect for click tracking. This user experienced the same issue. From the Sendgrid dashboard, go to Settings->Tracking and click the edit icon on the right for Click Tracking, and disable the feature.

looks like the cause of this issue is due to not including the http/s prefix to your link. Please change your dynamic variable from "cms.mywebshop.com" to "http://cms.mywebshop.com" or "https://cms.mywebshop.com". Pretty sure this should resolve your issue. Please let me know.
I was able to test not having the http/s prefix on one of my href's and although the tag did not appear as show as plain text, it did fail to forward. It's possible that the folks from Sendgrid made it so the link is shown as plain text for troubleshooting purposes.

Related

Prevent SendGrid from replacing <a> tags in Dynamic Templates

I'm using the #sendgrid/mail library to send emails from our app, using a dynamic template. The template is created entirely with custom HTML.
When emails are delivered, any custom code in <a> tags is ignored.
More specifically, SendGrid adds a "data-saferedirecturl" attribute and strips out any other attributes I add.
I've already tried disabling SendGrid click tracking globally, as well as disabling it individually, but neither seems to make any difference.
Anyone know if it's possible to change this behavior, either via the SendGrid dashboard or API settings?
There is a trackingSettings parameter to the send() API call, so you can add something like:
trackingSettings: {
clickTracking: {enable: false}
},

Calendly not pre-filling a form in Webflow

I’m using Calendly in my Webflow project, and it works.
However, I would love to pre-fill the form in Calendly, and there is a guide to do so here: https://help.calendly.com/hc/en-us/articles/226766767-Pre-populate-invitee-information-on-the-scheduling-page
I’ve managed to make the url look like this, using custom code:
mywebsite.com/book-meeting?name=MyFirstname%20MyLastname&email=myemail#test.com
But for some reason Calendly is not pre-filling the form.
Is there anyone else, who has tried this and made it work?
Thanks!
It sounds to me look you would like to pass custom pre-fill values to your embedded Calendly Link.
The best way to do this is to use Calendly’s Advanced Embed Options: https://help.calendly.com/hc/en-us/articles/360020052833-Advanced-embed-options#4
In order to do this you will need to supply your pre-filled values like Name and Email directly to specific Calendly link being embedded. In your example: mywebsite.com/book-meeting?name=MyFirstname%20MyLastname&email=myemail#test.com, it looks like you are passing the pre-fill values to the entire page address rather than specifically to the calendly.com/… scheduling link found in the embedded script.
The best way to do this is as described in help article referenced above. You can add pre fill values script like so:
prefill: {
name:
email:
customAnswers:
}
so that the script to embed Calendly would look something like:
<script>
const params = (new URL(window.location)).searchParams
Calendly.initInlineWidget({
url: 'https://calendly.com/YOUR_LINK/30min',
prefill: {
name: params.get('name'),
email: params.get('email')
}
});
</script>
Where we are taking the parameters from the page url and passing them to Calendly embedded widget. (Note: in this example, I am using an Inline Widget but you can replace this portion of the script with the appropriate API method, ie. Calendly.initBadgeWidget or Calendly.initPopupWidget)
Hope this helps, happy scheduling!

How to open a draft created with Gmail API in browser?

Im trying to create a gmail draft using gmail API and open it in a new tab.
When i try to open a draft using the following url : https://mail.google.com/mail/u/0/#drafts/ draft id , from a external web it does not open the draft. Instead it lists the drafts.
If i do the same in a Gmail tab it works as expected.
You can reproduce it following this steps
Chose any draft and copy its message id , you can use this
Create a url joining https://mail.google.com/mail/u/0/#drafts/ + the message id you got in the last step.
Open a new tab in Chrome and paste it, it will send you to your draft list.
If you paste the same url in the the same tab it will open the draft.
More information about the problem
It does not work with https://mail.google.com/mail/u/0/#drafts/?compose= neither
Chrome console throws this error when i try to open a draft from another tab
console error
I noticed if you open a draft the url is like this one https://mail.google.com/mail/u/0/#drafts?compose=JHrtffLJpZXxNwzKGMhcjvjBrqfPRwKWvkvJbtWpRffXldzxkNQhmkkBWJsHPbdSPdDgBVKpHKZMNtCVFgXrhwMCVjCdCRqTLJhGvqrXNKFZmJDGZ , this url works also to open the draft editor from other tabs, but where does the compose value come from?
I know it is not a API error or problem but if somebody had the same problem and know any way to solve it i will apreciate.
So the question is, how can i create a url to open a gmail draft using Gmail API ?
The way to make this url changed, now it works like this:
mail.google.com/mail/#inbox?compose=draft.message.id
If you list your drafts you get
{
"drafts": [
{
"id": "r5632827412362757569",
"message": {
"id": "174f4fa0dd96af123",
"threadId": "174f4f59344d6321"
}
}
],
...
}
So, to open this draft you need the following url :
mail.google.com/mail/#inbox?compose=174f4fa0dd96af123
Your goal:
To be able to open a browser tab directly focused on a specific draft of your choosing, from the drafts in your mailbox. (Correct me if I'm wrong).
Background:
You noticed that drafts have a "compose" parameter visible in the url when focused within the UI.
The drafts resource doesn't include the "compose" parameter, so we can't get it from the API, and it also isn't equal to the draft id.
Conclusion:
Since the parameter needed is not publicly available via API, you can't achieve your goal at the moment. You can request the feature to Google directly by creating a "Feature Request" for the Gmail API. Here's the link Issue Tracker.

Custom tags in Jira email handler

Is there a way to make a Jire email handler ignore the From field in an email and go for a custom tag instead? I know I could work with the API instead but that's in the pipe. this is a temporary solution that will be used until a more robust system is built.
To clarify what we have today:
Email is sent to inbox, (hr#company.com)
Jira picks is up and creates an issue.
Jira looks at the From field and creates a uses if none exist.
What we're trying to achieve:
Form is filled out, and an area is chosen (hr, facilities etc.).
Form is posted to an API that creates an email (basically a no-reply adress over SMTP) and sends it to the appropriate inbox (for example hr#company.com).
Email lands in the inbox and Jira looks in it and creates an issue in project or label 'HR'.
Jira now looks in the email and finds custom tags named [user] and [user-email] (or something) and creates a user from the tag.
Example email
From: no-reply#company.com
To: hr#company.com
Subject: Some problem
Body: Explanation of problem
Have a good day!
/Mike
[user:"Michael Smith"]
[userEmail:"michael.smith#company.com"]
If we were to implement this system now, we would loose the possibility to create new users because all emails would come from the same "no-reply" adress.
I have searched in the Atlassian forums and such, but with no luck. Have not found anything in the official documentation, but I fear that I might be looking in the wrong place.
I hope that I'm being clear, and that someone has any idea if it is possible.
Thank you!
You need to write your own plugin and create your own Mailhandler.
For example you can use a regex which looks for the tag
[userEmail:"michael.smith#company.com"] and retrieve the emailadress from the string. Do the same for the [user]-tag, if the user doesn't exist.
Here is a tutorial that shows how to create and setup custom Message Handlers:
https://developer.atlassian.com/jiradev/jira-platform/guides/email/tutorial-custom-message-mail-handler-for-jira#Tutorial-Custommessage(mail)handlerforJIRA-Step7:Implementarealmessagehandlerback-end
The rest should be easy from here.

Is it possible to hack mailto?

Sorry about the provocative subject but I could not think of a better word than "hack" to describe what I would like to do!
On my site, I provide links to other sites and on request by the user, display a page from the site in a frame or pop up window. Frequently these displayed pages have a mailto-tag.
I have found it extremely annoying that clicking the mailto link starts off my outlook which I no longer use but retain it as an installed program on my machine.
What I would like to do is:
1) Pick up the subject and email address part of the mailto tag.
2) Pop up an HTML form where the email address and the subject is prefilled.
3) Send the email message through my site's mailserver instead of through outlook or any other mail client.
Is there a way to do this?
Thank you in advance - and once again apologies for the provocative subject line!
Cheers!
Uttam
Try it using javascript.
With using a framework like jQuery its easy so find such tags inside a frame or popup window.
You can try it by something like this:
var allATags = $('myFrameId').find('a');
$(allATags).each(function(index, element){
var href = $(element).attr('href');
//here you shall try to find out if there a mailto Link or a normal link, e.g. using regular expression or indexOf()
[...]
if (isMailToLink){
//split the href String at the signs '&' with which the subject, mail, etc is splitted and removing the mailto, putting all in own variables
[...]
$(element).attr('href', 'javascript:void(0);');
$(element).click(function(){
showMyMailForm(toMail, mailSubject, mailBody);
});
}
});
On opening a document in a frame or a popup wait for the document being loaded and then run your code to replace all existing mailto-links on that document with your mailform-mailer.
The code is just a way trying to inspire, no working code.
Users can set their default email client, here are a couple of links that may be helpful:
Firefox
Chrome
Internet Explorer
Of course this is controlled by the user, so it will help you personally, but not force others to use a specific program.
You could easily pass url parameters onto your contact landing page/email form instead of a mailto link, something like a href="http://landingpage.com/index.php?email=you#you.com&subject=hello" could be used to pre-fill generic contact/email form fields.