Adapters

This section covers the following topics:

Use the generic-email adapter

The generic email adapter (generic-email) enables you to add email reporting into your workflows. The adapter provides the ability to send emails using an SMTP server. For the latest adapter version, you can use the Send activity to send an email with a message defined inside the workflow definition.

You can get the generic email adapter by downloading the CWM package cwm.v2.0.generic.email.v1.0.3.tar.gz from the Cisco Software Download page.

To install the adapter, follow the instructions in Install an adapter.

Add an SMTP secret

Let's start by defining an SMTP secret.

Before you begin

Before going into the details of defining your email message inside a workflow, you need to add an SMTP secret and resource to CWM. You will later need to reference them inside your workflow.

Procedure

  Command or Action Purpose

Step 1

In CWM, choose Administration > Workflow Administration > Secrets.

Step 2

In the Secrets view, click Add secret.

Step 3

In the New secret view, provide the required input:

  • Secret ID: Name your secret. You'll need to reference this secret ID later in the resource and inside the workflow. E.g. emailSecret.

  • Secret type: Select basicAuth.

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:

  • Password: Enter the password for the sender's email address.

  • Username: Enter the sender's email address, in the following format: sender@address.com.

Step 5

Click the Create Secret button.

You can edit the secret type and its details later.

Once you've added a secret and its details, create a resource in and associate it with the secret, as explained in Add an SMTP resource.

Add an SMTP resource

Now we can create the resource.

Before you begin

Ensure that you have already created an email secret, as explained in Add an SMTP secret

Procedure

  Command or Action Purpose

Step 1

In CWM, choose Administration > Workflow Administration > Resources.

Step 2

In the Resources view, click Add resource.

Step 3

In the New resource view, provide the required input:

  • Resource name: Name your resource. You'll need to provide the resource ID later inside the workflow as a reference. For example: emailResource.

  • Resource type: Select generic.email.resource.v1.0.3.

  • Connection:

    • Host: Enter the URL or IP address of the SMTP email server to be used.

    • Port: Enter the outgoing SMTP port on the server. The default outgoing SMTP port for encrypted email transmission is 587. Port 465 is still supported by some providers, 25 is supported for SMTP relay, and 2525 is a popular alternative when 587 is blocked.

    • Scheme: Leave blank (it's not required for this workflow).

    • Timeout: Leave blank (it's not required for this workflow).

    • Allow insecure: Select true.

Step 4

Select a Secret ID from the drop-down menu to associate a previously created secret with this resource.

Step 5

Click the Create resource button.

Once created, your resource is displayed on the list in the main Resources view.

Define the Send activity in a workflow

Once you've created the adapter, secret and resource, you can use it 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.2.smtp.Send"
    }
  ]

Inside the name parameter, provide an activity name that you will later refer to in the refName parameter while defining the action.

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"
              }
            }
          }
        }
      ]
    }
  ]