Send Templated Email

communication/send-templated-email@1.0.1
Supported by 5 providers
M
M
M
P
S

Send Templated Email

Send templated transactional email to one recipient. Requires template defined on provider side.

Input
From
To
Template Identifier
Template Data
Result
Message Identifier

1.Choose a provider

2.Use SendTemplatedEmail with mock in your code

npm i @superfaceai/one-sdk
const { SuperfaceClient } = require('@superfaceai/one-sdk');

const sdk = new SuperfaceClient();

async function run() {
  // Load the profile
  const profile = await sdk.getProfile('communication/send-templated-email@1.0.1');

  // Use the profile
  const result = await profile
    .getUseCase('SendTemplatedEmail')
    .perform({
      from: 'no-reply@example.com',
      to: 'jane.doe@example.com',
      templateId: 'user-invitation',
      templateData: {
        invited_by: 'Bob',
        invitation_link: 'example.com/invite?code=invite'
      }
    }, {
      provider: 'mock'
    });

  // Handle the result
  try {
    const data = result.unwrap();
    console.log(data);
  } catch (error) {
    console.error(error);
  }
}

run();

Structure details

Input (object)

from
The sender's email address.
to
The recipient's email address.
templateId
The template to use when sending email message.
templateData
Template data to be applied to the specified template to generate html, test, and subject. The value is a collection of key/value pairs following the pattern `variable_name`: `value to insert`. This field should be used in combination with `templateId` to identify what template to use.

Example

{
  "from": "no-reply@example.com",
  "to": "jane.doe@example.com",
  "templateId": "user-invitation",
  "templateData": {
    "invited_by": "Bob",
    "invitation_link": "example.com/invite?code=invite"
  }
}

Result (object)

messageId
The identifier is provider-specific and not unique.

Example

{
  "messageId": "gyax6ce9QLKQ80VOqsRX2g"
}

Implementation details

Provider
mock
Use case
SendTemplatedEmail
Author
@superface
Source
Verified