Socotra
Configuration GuidePlugins

Integrations Plugin

The Integrations Plugin allows you to customize email delivery logic used by the Socotra Assistant. When the assistant sends an email, such as an email composed through the email intake workflow, the plugin can deliver the email through your own email provider and return the delivery details to the platform.

Implementation

Create a new Java class in the src/main/java/com/socotra/deployment/customer folder. All plugin code must be contained within this folder. We named our class IntegrationsPluginImpl.java in the example below, but you can name your class whatever you'd like.

Implement the IntegrationsPlugin interface and override the sendEmail method.

For example:

public class IntegrationsPluginImpl implements IntegrationsPlugin {
    private static final Logger log = LoggerFactory.getLogger(IntegrationsPluginImpl.class);

    @Override
    public SendEmailPluginResponse sendEmail(SendEmailRequest request) {
        SendEmailPluginRequest email = request.email();

        log.info("Received send email request for email: {}", email.emailLocator());

        // Send the email using your email provider's API

        return SendEmailPluginResponse.builder()
                .externalId("provider-message-id")
                .from("underwriting@example.com")
                .to(email.to())
                .subject(email.subject())
                .body(email.body())
                .build();
    }
}

The method request object contains the email to be sent, which can be retrieved by calling the email() method. The email object contains the following fields:

  • emailLocator - The locator of the email
  • to - The email address of the recipient
  • subject - The email subject
  • body - The email body
  • replyTo - An optional reply-to email address
  • inReplyTo - An optional identifier of the original message to which the email is replying. This is used for email threads.
  • attachments - A list of email attachments. Each attachment contains a filename, a contentType, and the attachment content.

The method returns a SendEmailPluginResponse object containing the delivery details. The SendEmailPluginResponse object contains the following optional fields:

  • externalId - The identifier assigned to the email by your email provider
  • from - The email address of the sender
  • to - The email address of the recipient
  • subject - The email subject
  • body - The email body

HTTP requests can be performed using the Java HttpClient . Refer to the Plugins Overview for more information.

Credentials for your email provider can be retrieved from a Secret resource using the Resource Selector.

See Also

On this page