@kumologica/kumologica-contrib-sendgrid
Version:
Node that send email using SendGrid platform
211 lines (190 loc) • 9.38 kB
HTML
<script type="text/x-kumologica" data-template-name="SendGrid">
<style scoped>
.hiddenAttrs {display:none;}
.visibleAttrs {display:block;}
</style>
<div class="kumo-window">
<!-- Display name -->
<div class="kumo-section">
<div class="kumo-row">
<label class="kumo-row-label" for="node-input-name"> <span>Display Name</span></label>
<input class="kumo-row-editable" type="text" id="node-input-name" placeholder="Name">
</div>
</div>
<!-- General Settings -->
<div class="kumo-section-title">General</div>
<div class="kumo-section">
<div class="form-row" id='Operation'>
<label class="kumo-row-label" for="node-input-operation">Operation</label>
<select class="kumo-row-editable" type="text" id="node-input-operation">
<option value="Regular">Email-Regular</option>
<option value="DynamicTemplate">Email-DynamicTemplate</option>
<option value="GetContactsById">Contacts-GetByContactId</option>
<option value="GetAllContacts">Contacts-GetAllContacts</option>
;
</select>
</div>
<br/>
<div id="AttrHolder">
<div class="form-row" id="toAttr" class='hiddenAttrs'>
<label class="kumo-row-label" for="node-input-to">To</label>
<input type="text" id="node-input-to" placeholder="To Address">
</div>
<div class="form-row" id="fromAttr" class='hiddenAttrs'>
<label class="kumo-row-label" for="node-input-from">From</label>
<input type="text" id="node-input-from" placeholder="From Address">
</div>
<div class="form-row" id="ccAttr" class='hiddenAttrs'>
<label class="kumo-row-label" for="node-input-cc">Cc</label>
<input type="text" id="node-input-cc" placeholder="Cc Address">
</div>
<div class="form-row" id="bccAttr" class='hiddenAttrs'>
<label class="kumo-row-label" for="node-input-bcc">Bcc</label>
<input type="text" id="node-input-bcc" placeholder="Bcc Address">
</div>
<div class="form-row" id="replytoAttr" class='hiddenAttrs'>
<label class="kumo-row-label" for="node-input-replyto">ReplyTo</label>
<input type="text" id="node-input-replyto" placeholder="Reply To">
</div>
<div class="form-row" id="subjectAttr" class='hiddenAttrs'>
<label class="kumo-row-label" for="node-input-subject">Subject</label>
<input type="text" id="node-input-subject" placeholder="Subject">
</div>
<div class="form-row" id="bodyAttr" class='hiddenAttrs'>
<label class="kumo-row-label" for="node-input-body">Body</label>
<input type="text" id="node-input-body" placeholder="Body">
</div>
<div class="form-row" id="templateidAttr" class='hiddenAttrs'>
<label class="kumo-row-label" for="node-input-templateid">TemplateId</label>
<input type="text" id="node-input-templateid" placeholder="Dynamic Template Id">
</div>
<div class="form-row" id="contentAttr" class='hiddenAttrs'>
<label class="kumo-row-label" for="node-input-content">Template data</label>
<input type="text" id="node-input-content" placeholder="Template data">
</div>
<div class="form-row" id="unsubAttr" class='hiddenAttrs'>
<label class="kumo-row-label" for="node-input-unsub" >Unsubscribe</label>
<input class="kumo-row-editable" id="node-input-unsub" type="checkbox" name="unsub_enable" value="1" onchange="unsubChange()"/>
</div>
<div id="asm">
<div class="form-row" id="group">
<label class="kumo-row-label" for="node-input-group">Group Id</label>
<input type="text" id="node-input-group" placeholder="Unique asm group id">
</div>
<div class="form-row" id="groupdisplay">
<label class="kumo-row-label" for="node-input-groupdisplay">GroupDisplay Id</label>
<input type="text" id="node-input-groupdisplay" placeholder="Unique asm group display id">
</div>
</div>
<div class="form-row" id="contactidAttr" class='hiddenAttrs'>
<label class="kumo-row-label" for="node-input-contactid">Contact Id</label>
<input type="text" id="node-input-contactid" placeholder="Unique Contact Id">
</div>
<div class="form-row" id="timeoutAttr" class='hiddenAttrs'>
<label class="kumo-row-label" for="node-input-timeout">Timeout</label>
<input type="text" id="node-input-timeout" placeholder="5000">
</div>
</div>
</div>
<!-- Security Settings -->
<div class="kumo-section-title">Security</div>
<div class="kumo-section">
<div class="form-row" id='apikey'>
<label class="kumo-row-label" for="node-input-apikey">API Key</label>
<input type="text" id="node-input-apikey" placeholder="API Key">
</div>
</div>
</div>
<script>
var nodeOps={
Regular:[
'#toAttr','#fromAttr','#subjectAttr','#bodyAttr','#timeoutAttr','#bccAttr','#ccAttr'
],
DynamicTemplate:[
'#toAttr','#fromAttr','#subjectAttr','#replytoAttr','#templateidAttr','#contentAttr','#timeoutAttr','#bccAttr','#ccAttr','#unsubAttr'
],
GetContactsById: [
'#timeoutAttr', '#contactidAttr'
],
GetAllContacts: [
'#timeoutAttr'
]
};
$('#node-input-operation').on('change',function(){
$('#AttrHolder').children().addClass('hiddenAttrs').removeClass('visibleAttrs');
if (nodeOps[this.value])
$(nodeOps[this.value].join()).addClass('visibleAttrs').removeClass('hiddenAttrs');
});
function unsubChange()
{
if($('#node-input-unsub').is(":checked"))
$("#asm").show();
else
$("#asm").hide();
}
</script>
</script>
<script type="text/javascript">
App.nodes.registerType('SendGrid', {
category: 'Platform',
icon: 'kumo_sendgrid.png',
color: '#0d98ba',
defaults: {
name: { value: 'SendGrid' },
operation: { value: 'Regular' },
to: { value: '',templateable: true , required: true },
from : { value: '',templateable: true , required: true },
cc : { value: '',templateable: true},
bcc : { value: '',templateable: true},
subject : { value: '',templateable: true , required: true },
body : { value: '',templateable: true },
templateid : { value: '',templateable: true},
replyto : { value: '',templateable: true},
content : { value: '',templateable: true},
apikey: { value: '', templateable: true , required: true },
contactid: { value: '', templateable: true },
unsub: { value: ''},
group: { value: '', templateable: true },
groupdisplay: { value: '', templateable: true },
timeout: { value: 5000}
},
inputs: 1,
outputs: 1,
label: function () {
return this.name || 'SendGrid';
}
});
</script>
<script type="text/x-kumologica" data-help-name="SendGrid">
<h4> Description </h4>
<p>SendGrid node connects with the SendGrid platform for sending email.</p>
<h4> Properties </h4>
<ul>
<li><i>Operation</i> - (Optional). Option for Regular,DynamicTemplate,GetAllContacts,GetContactById.</li>
<li><i>To</i> - (Required). To address of the email.</li>
<li><i>From</i> - (Required). From address of the email. The email id must be verified in SendGrid Platform.</li>
<li><i>Cc</i> - (Optional). Cc address of the email.</li>
<li><i>Bcc</i> - (Optional). Bcc address of the email. The email id must be verified in SendGrid Platform.</li>
<li><i>Subject</i> - (Required). Subject of the email.</li>
<li><i>ReplyTo</i> - (Required). ReplyTo address of the email.</li>
<li><i>Body</i> - (Required). Body of the email.</li>
<li><i>TemplateId</i> - (Required). Unique ID of the dynamic template configured in SendGrid.</li>
<li><i>Template data</i> - (Optional). JSON data used for furnishing the dynamic template configured in SendGrid platform.</li>
<li><i>Contact Id</i> - (Optional). Unique Id generated by SendGrid for each contact.</li>
<li><i>Timeout</i> - (Optional). Default timeout is 5000ms. Maximum time for connection to wait.</li>
<li><i>API Key</i> - (Required). API key generated by SendGrid for accessing the platform.</li>
<li><i>Unsubscribe</i> - (Optional). Enable to pass the ASM group details for unsubscribe option.</li>
<li><i>Group Id</i> - (Optional). Unique asm group id for unsubscribe option.</li>
<li><i>GroupDisplay Id</i> - (Optional). Unique asm display group for unsubscribe option.</li>
</ul>
<p><i>Note : </i> Create the dynamic template in the SendGrid UI using the dynamic template operation in the node. Ensure to have the subject enabled with substitute expression.</p>
<h4> Throws </h4>
<ul>
<li>SendGrid Client Failed</li>
</ul>
<h4> Returns </h4>
Payload will not be overwritten by this node.
None of the variables will be overwritten or enriched by this node.
<h4> More info </h4>
<a href="https://docs.kumologica.com/docs/references/SendGridNode.html">Kumologica Documentation</a>
</script>