Use generic-email
adapter
The Email Adapter (generic-email
) adds an element of reporting into your workflows by providing basic functionality to send emails using an SMTP server. For
the 1.0.0 adapter version, you can use the Send
activity to send an email with a message defined inside the workflow definition.
Get generic-email
adapter
Download the CWM 1.1 Software package. The cwm.v1.1.generic.email.v1.0.0.tar.gz
file is included inside the package.
Install adapter
To install the adapter, follow the instructions on how to install an adapter in the Operator guide.
Create SMTP resource and secret
Before going into the details of defining your email message inside a workflow, you need to add a resource and a secret to CWM. You will later need to reference them inside your workflow.
Add secret
Procedure
Step 1 |
In CWM, navigate to the Admin -> Secrets tab. |
Step 2 |
Click Add Secret. |
Step 3 |
In the New secret view, specify the following:
|
Step 4 |
After selecting the secret type, a set of additional fields is displayed under the Secret type details section. Fill in the fields with the following:
|
Step 5 |
Click Create Secret. |
Add resource
Procedure
Step 1 |
In CWM, navigate to the Admin -> Resources tab. |
Step 2 |
Click Add Resource. |
Step 3 |
In the New resource window, specify the following: |
Step 4 |
Click Create resource. |
Define the Send
activity in workflow
Learn how to use the adapter Send
activity in a workflow.
Set activity reference
In CWM, the adapter Send
activity is referred to as generic.email.smtp.Send
. When defining a workflow, you need to specify it as the value of the operations
parameter under functions
:
"functions": [
{
"name": "smtp.send",
"operation": "generic.email.v1.0.0.smtp.Send"
}
]
Note |
Inside the |
Define email message in actions
Now you can define an action in which an email will be sent as part of a workflow state.
The available input parameters for the action are:
Field | Type | Label | Description | |
---|---|---|---|---|
from | string | Sender email address | ||
to | string | repeated | List of recipient email addresses | |
cc | string | repeated | List of recipient cc email addresses | |
bcc | string | repeated | List of recipient bcc email addresses | |
subject | string | Email title | ||
text | string | Email body as text | ||
html | string | Email body as html |
Use the available fields as the input
key/value pairs within the arguments
that define the SendEmail
example action as shown below:
"states":[
{
"name":"EmailState",
"type":"operation",
"end": true,
"actions": [
{
"name": "SendEmail",
"functionRef": {
"refName": "smtp.send",
"arguments": {
"input": {
"to": ["recipient1@address.com", "recipient2@address.com"],
"from": "sender@address.com",
"text": "Hello, this is some placeholder email text.",
"subject": "A test email from CWM"
},
"config": {
"resourceId": "emailResource"
}
}
}
}
]
}
]
If you want to trigger the email action based on a condition, you can use the Switch state and define the dataConditions
parameter inside it. For details, check out the Serverless Workflow Specification documentation for the Switch state.