Overview

When writing a skill that will send an email when an event occurs, you need to use the sendEmail power to create and send the email in the run.ts file. This article will cover the parameters of the sendEmail power.

 

sendEmail Power

The sendEmail power will be called via the email property of the Andi® powers in the skills context as a return statement with the following shape:

return skillContext.powers.andi.email.sendEmail(
    emailCategory,
    frequencyType,
    toAddress,
    fromAddress,
    subject,
    body,
    footer,
    bodyHeader
),

 

emailCategory

The emailCategory parameter, entered as a string, is used to provide a category name for your email message. If you are sending multiple messages with the same parameters (category, subject, frequency, recipients) this allows emails to be sent as one email so you aren't overloaded with email messages. Otherwise, this field can be left blank.

As part of the skill code, this will look like:

return skillContext.powers.andi.email.sendEmail(
    "email-category-name-here",

frequencyType

The frequencyType parameter, entered as an enumeration property, is used to indicate the frequency at which emails should be sent. You will indicate the frequency using

andiSkills.EmailFrequencyTypes.frequencyTypeSelectionHere

Available options are:

  • OneMinute - an email will be sent every minute containing the defined email criteria in the run file.
  • FiveMinute - an email will be sent every five minutes containing the defined email criteria in the run file.
  • Hourly - an email will be sent every hour containing the defined email criteria in the run file.
  • Daily - an email will be sent daily at 9 AM EST containing the defined email criteria in the run file.
  • Weekly - an email will be sent every Monday at 8 AM EST containing the defined email criteria in the run file.
  • EndofMonth - an email will be sent on the actual month end date (28th, 30th, or 31st) at 8 AM EST containing the defined email criteria in the run file. If the month end date is on a weekend, the email will be sent the preceding Friday (ie if the 31st is on a Saturday, the email will be sent on the 30th).
  • BeginingofMonth - an email will be sent on the first of the month at 8 AM EST containing the defined email criteria in the run file. If the first of the month is on a weekend, the email will be sent the following Monday (ie if the 1st is on a Saturday, the email will be sent on Monday the 3rd).

As part of the skill code, this will look like:

return skillContext.powers.andi.email.sendEmail(
    "email-category-name-here",
    andiSkills.EmailFrequencyTypes.OneMinute,

toAddress

The toAddress parameter is used to indicate the name and email address of the email recipients, entered as a string or pre-defined variable (recommended and further recommended to define the variable using skill configurations), as part of the EmailUserModel array using

[new andiSkills.EmailUserModel(name: string, emailAddress: string)]

As part of the skill code, this will look like:

//Option 1 - name and email entered as a string

return skillContext.powers.andi.email.sendEmail(
    "email-category-name-here",
    andiSkills.EmailFrequencyTypes.OneMinute,
    [new andiSkills.EmailUserModel(name: "John Banks", emailAddress: "johnbanks@onpurpose.com")],

//Option 2 - name and email entered as a variable

let toAddress = "johnbanks@onpurpose.com"; 
let toName = "John Banks";

return skillContext.powers.andi.email.sendEmail(
    "email-category-name-here",
    andiSkills.EmailFrequencyTypes.OneMinute,
    [new andiSkills.EmailUserModel(toName, toAddress)],

fromAddress

The fromAddress parameter, entered as a string or predefined variable (recommended and further recommended to define the variable using skill configurations), is used to identify the address that the email is sent from, and consequently, where any replies will be directed.

As part of the skill code, this will look like:

//Option 1 - name and email entered as a string

return skillContext.powers.andi.email.sendEmail(
    "email-category-name-here",
    andiSkills.EmailFrequencyTypes.OneMinute,
    [new andiSkills.EmailUserModel(name: "John Banks", emailAddress: "johnbanks@onpurpose.com")],
    "branchmanager@onpurpose.com",

//Option 2 - name and email entered as a variable

let toAddress = "johnbanks@onpurpose.com"; 
let toName = "John Banks";
let fromAddress = "branchmanager@onpurpose.com";

return skillContext.powers.andi.email.sendEmail(
    "email-category-name-here",
    andiSkills.EmailFrequencyTypes.OneMinute,
    [new andiSkills.EmailUserModel(toName, toAddress)],
    fromAddress,

subject

The subject parameter, entered as a string or predefined variable (recommended and further recommended to define the variable using skill configurations), is used to indicate the subject of the email message. All emails with the same subject, frequency, and to address will be combined as one email to reduce noise.

As part of the skill code, this will look like:

//Option 1 - name and email entered as a string

return skillContext.powers.andi.email.sendEmail(
    "email-category-name-here",
    andiSkills.EmailFrequencyTypes.OneMinute,
    [new andiSkills.EmailUserModel(name: "John Banks", emailAddress: "johnbanks@onpurpose.com")],
    "branchmanager@onpurpose.com",
    "Opportunity Saved",

//Option 2 - name and email entered as a variable

let toAddress = "johnbanks@onpurpose.com"; 
let toName = "John Banks";
let fromAddress = "branchmanager@onpurpose.com";
let subject = "Opportunity Saved";

return skillContext.powers.andi.email.sendEmail(
    "email-category-name-here",
    andiSkills.EmailFrequencyTypes.OneMinute,
    [new andiSkills.EmailUserModel(toName, toAddress)],
    fromAddress,
    subject,

body

The body parameter, entered as a string or predefined variable (recommended and further recommended to define the variable using skill configurations), is used to indicate the body of the email. The body can be formatted using HTML coding. When formatting, make sure to consider email client rules.

As part of the skill code, this will look like:

//Option 1 - name and email entered as a string

return skillContext.powers.andi.email.sendEmail(
    "email-category-name-here",
    andiSkills.EmailFrequencyTypes.OneMinute,
    [new andiSkills.EmailUserModel(name: "John Banks", emailAddress: "johnbanks@onpurpose.com")],
    "branchmanager@onpurpose.com",
    "Opportunity Saved",
    "Opportunity Name: ${applicationEventData.opportunityName} has been saved!",

//Option 2 - name and email entered as a variable

let toAddress = "johnbanks@onpurpose.com"; 
let toName = "John Banks";
let fromAddress = "branchmanager@onpurpose.com";
let subject = "Opportunity Saved";
let body = "Opportunity Name: ${applicationEventData.opportunityName} has been saved!";

return skillContext.powers.andi.email.sendEmail(
    "email-category-name-here",
    andiSkills.EmailFrequencyTypes.OneMinute,
    [new andiSkills.EmailUserModel(toName, toAddress)],
    fromAddress,
    subject,
    body,

footer

The footer parameter, entered as a string or predefined variable (recommended and further recommended to define the variable using skill configurations), can be used to enter any special messaging. It is not required to enter a footer. If not including a footer, enter "" for the parameter.

As part of the skill code, this will look like:

//Option 1 - name and email entered as a string

return skillContext.powers.andi.email.sendEmail(
    "email-category-name-here",
    andiSkills.EmailFrequencyTypes.OneMinute,
    [new andiSkills.EmailUserModel(name: "John Banks", emailAddress: "johnbanks@onpurpose.com")],
    "branchmanager@onpurpose.com",
    "Opportunity Saved",
    "Opportunity Name: ${applicationEventData.opportunityName} has been saved!",
    "",

//Option 2 - name and email entered as a variable

let toAddress = "johnbanks@onpurpose.com"; 
let toName = "John Banks";
let fromAddress = "branchmanager@onpurpose.com";
let subject = "Opportunity Saved";
let body = "Opportunity Name: ${applicationEventData.opportunityName} has been saved!";

return skillContext.powers.andi.email.sendEmail(
    "email-category-name-here",
    andiSkills.EmailFrequencyTypes.OneMinute,
    [new andiSkills.EmailUserModel(toName, toAddress)],
    fromAddress,
    subject,
    body,
    "",

bodyHeader

The bodyHeader parameter, entered as a string or predefined variable (recommended and further recommended to define the variable using skill configurations), can be used to display any special header text at the beginning of the email body in bold font format. It is not required to enter a bodyHeader. If not including a bodyHeader, enter "" for the parameter.

As part of the skill code, this will look like:

//Option 1 - name and email entered as a string

return skillContext.powers.andi.email.sendEmail(
    "email-category-name-here",
    andiSkills.EmailFrequencyTypes.OneMinute,
    [new andiSkills.EmailUserModel(name: "John Banks", emailAddress: "johnbanks@onpurpose.com")],
    "branchmanager@onpurpose.com",
    "Opportunity Saved",
    "Opportunity Name: ${applicationEventData.opportunityName} has been saved!",
    "",
    ""
);

//Option 2 - name and email entered as a variable

let toAddress = "johnbanks@onpurpose.com"; 
let toName = "John Banks";
let fromAddress = "branchmanager@onpurpose.com";
let subject = "Opportunity Saved";
let body = "Opportunity Name: ${applicationEventData.opportunityName} has been saved!";

return skillContext.powers.andi.email.sendEmail(
    "email-category-name-here",
    andiSkills.EmailFrequencyTypes.OneMinute,
    [new andiSkills.EmailUserModel(toName, toAddress)],
    fromAddress,
    subject,
    body,
    "",
    ""
);

 

For an example of a skill using the sendEmail power, see 'Email' Skill Template.

Was this article helpful?
0 out of 0 found this helpful