chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import { ActionDefinition, IntegrationDefinitionProps } from '@botpress/sdk'
|
||||
import { sendTransactionalEmailInputSchema, sendTransactionalEmailOutputSchema } from './schemas'
|
||||
|
||||
const sendTransactionalEmail = {
|
||||
title: 'Send Transactional Email',
|
||||
description: 'Send a transactional email to a client',
|
||||
input: {
|
||||
schema: sendTransactionalEmailInputSchema,
|
||||
},
|
||||
output: {
|
||||
schema: sendTransactionalEmailOutputSchema,
|
||||
},
|
||||
} as const satisfies ActionDefinition
|
||||
|
||||
export const actions = {
|
||||
sendTransactionalEmail,
|
||||
} as const satisfies IntegrationDefinitionProps['actions']
|
||||
@@ -0,0 +1,59 @@
|
||||
import { EventDefinition, IntegrationDefinitionProps } from '@botpress/sdk'
|
||||
import { campaignOrLoopEmailEventSchema, fullEmailEventSchema } from './schemas'
|
||||
|
||||
const emailDelivered = {
|
||||
title: 'Email Delivered',
|
||||
description: 'Sent when an email is delivered to its recipient.',
|
||||
schema: fullEmailEventSchema,
|
||||
} as const satisfies EventDefinition
|
||||
|
||||
const emailSoftBounced = {
|
||||
title: 'Email Soft Bounced',
|
||||
description:
|
||||
'Sent when an email soft bounces. Soft bounces are temporary email delivery failures, for example a connection timing out. Soft bounces are retried multiple times and some times the email is delivered.',
|
||||
schema: fullEmailEventSchema,
|
||||
} as const satisfies EventDefinition
|
||||
|
||||
const emailHardBounced = {
|
||||
title: 'Email Hard Bounced',
|
||||
description:
|
||||
"Sent when an email hard bounces. Hard bounces are persistent email delivery failures, for example a mailbox that doesn't exist. The email will not be delivered.",
|
||||
schema: fullEmailEventSchema,
|
||||
} as const satisfies EventDefinition
|
||||
|
||||
const emailOpened = {
|
||||
title: 'Email Opened',
|
||||
description:
|
||||
'Sent when a campaign or loop email is opened. This event is not available for transactional emails because email opens are not tracked for transactional emails.',
|
||||
schema: campaignOrLoopEmailEventSchema,
|
||||
} as const satisfies EventDefinition
|
||||
|
||||
const emailClicked = {
|
||||
title: 'Email Clicked',
|
||||
description:
|
||||
'Sent when a link in a campaign or loop email is clicked. This event is not available for transactional emails because link clicks are not tracked in transactional emails.',
|
||||
schema: campaignOrLoopEmailEventSchema,
|
||||
} as const satisfies EventDefinition
|
||||
|
||||
const emailUnsubscribed = {
|
||||
title: 'Email Unsubscribed',
|
||||
description:
|
||||
'Sent when a recipient unsubscribes via the unsubscribe link in an email. This event is not available for transactional emails because unsubscribe links are not included or required for transactional emails.',
|
||||
schema: campaignOrLoopEmailEventSchema,
|
||||
} as const satisfies EventDefinition
|
||||
|
||||
const emailSpamReported = {
|
||||
title: 'Email Spam Reported',
|
||||
description: 'Sent when a recipient reports your email as spam.',
|
||||
schema: fullEmailEventSchema,
|
||||
} as const satisfies EventDefinition
|
||||
|
||||
export const events = {
|
||||
emailDelivered,
|
||||
emailSoftBounced,
|
||||
emailHardBounced,
|
||||
emailOpened,
|
||||
emailClicked,
|
||||
emailUnsubscribed,
|
||||
emailSpamReported,
|
||||
} as const satisfies IntegrationDefinitionProps['events']
|
||||
@@ -0,0 +1,14 @@
|
||||
import { ConfigurationDefinition, z } from '@botpress/sdk'
|
||||
|
||||
export { actions } from './actions'
|
||||
export { events } from './events'
|
||||
|
||||
export const configuration = {
|
||||
schema: z.object({
|
||||
apiKey: z.string().title('API Key').describe('The API key for Loops'),
|
||||
webhookSigningSecret: z
|
||||
.string()
|
||||
.title('Webhook Signing Secret')
|
||||
.describe('The secret key for verifying incoming Loops webhook events. Must start with "whsec_".'),
|
||||
}),
|
||||
} as const satisfies ConfigurationDefinition
|
||||
@@ -0,0 +1,119 @@
|
||||
import { z } from '@botpress/sdk'
|
||||
|
||||
export const sendTransactionalEmailInputSchema = z.object({
|
||||
email: z.string().describe('The email address of the recipient.').title('Email'),
|
||||
transactionalId: z.string().describe('The ID of the transactional email to send.').title('Transactional ID'),
|
||||
dataVariables: z
|
||||
.array(
|
||||
z.object({
|
||||
key: z.string().title('Key').describe('The key of the data variable'),
|
||||
value: z.string().title('Value').describe('The value of the data variable'),
|
||||
})
|
||||
)
|
||||
.describe('An object containing data as defined by the data variables added to the transactional email template.')
|
||||
.title('Data Variables'),
|
||||
addToAudience: z
|
||||
.boolean()
|
||||
.optional()
|
||||
.describe(
|
||||
'If true, a contact will be created in your audience using the email value (if a matching contact doesn’t already exist).'
|
||||
)
|
||||
.title('Add to Audience'),
|
||||
idempotencyKey: z
|
||||
.string()
|
||||
.optional()
|
||||
.describe(
|
||||
'Optionally send an idempotency key to avoid duplicate requests. The value should be a string of up to 100 characters and should be unique for each request. We recommend using V4 UUIDs or some other method with enough guaranteed entropy to avoid collisions during a 24 hour window. The endpoint will return a 409 Conflict response if the idempotency key has been used in the previous 24 hours.'
|
||||
)
|
||||
.title('Idempotency Key'),
|
||||
fileIds: z
|
||||
.array(z.string())
|
||||
.optional()
|
||||
.describe(
|
||||
'The Botpress client-generated IDs of the files to be attached to the email. They must have already been uploaded to your bot via the Files API. The name of the file will be used as the filename of the attachment. Use this for a list of templates the user can choose from.'
|
||||
)
|
||||
.title('File IDs'),
|
||||
fileData: z
|
||||
.array(
|
||||
z.object({
|
||||
filename: z.string().title('Filename').describe('The name of the file'),
|
||||
contentType: z.string().title('Content Type').describe('The MIME content type of the file'),
|
||||
data: z.string().title('Data').describe('The base64-encoded data of the file'),
|
||||
})
|
||||
)
|
||||
.optional()
|
||||
.describe('The name, base64-encoded data, and MIME content type of custom files to be attached to the email.')
|
||||
.title('File Data'),
|
||||
})
|
||||
|
||||
export const sendTransactionalEmailOutputSchema = z.object({})
|
||||
|
||||
const _commonEventSchema = z.object({
|
||||
eventName: z.string().title('Event Type').describe('The type of event as defined by Loops'),
|
||||
webhookSchemaVersion: z.string().title('Webhook Schema Version').describe('Will be 1.0.0 for all events'),
|
||||
eventTime: z.number().title('Event Time').describe('The Unix timestamp of the time the event occurred'),
|
||||
})
|
||||
|
||||
const _baseEmailEventSchema = _commonEventSchema.extend({
|
||||
contactIdentity: z
|
||||
.object({
|
||||
id: z.string().title('Contact ID').describe('The ID of the contact assigned by Loops'),
|
||||
email: z.string().title('Contact Email').describe('The email address of the contact'),
|
||||
userId: z
|
||||
.string()
|
||||
.nullable()
|
||||
.title('Contact User ID')
|
||||
.describe('The unique user ID created by the contact. May be null'),
|
||||
})
|
||||
.title('Contact Identity')
|
||||
.describe('The identifiers of the contact. Includes the contact ID, email address, and user ID'),
|
||||
email: z
|
||||
.object({
|
||||
id: z.string().title('Email ID').describe('The ID of the email'),
|
||||
emailMessageId: z.string().title('Email Message ID').describe('The ID of the sent version of the email'),
|
||||
subject: z.string().title('Email Subject').describe('The subject of the sent version of the email'),
|
||||
})
|
||||
.title('Email Details')
|
||||
.describe(
|
||||
'The details about an individual email sent to a recipient. Includes the email ID, the ID of the sent version, and the subject'
|
||||
),
|
||||
})
|
||||
|
||||
export const campaignOrLoopEmailEventSchema = _baseEmailEventSchema.extend({
|
||||
sourceType: z
|
||||
.enum(['campaign', 'loop'])
|
||||
.title('Source Type')
|
||||
.describe('The type of email that triggered the event. One of campaign or loop'),
|
||||
campaignId: z
|
||||
.string()
|
||||
.optional()
|
||||
.title('Campaign ID')
|
||||
.describe('The ID of the campaign email. Only one of Campaign ID or Loop ID must exist.'),
|
||||
loopId: z
|
||||
.string()
|
||||
.optional()
|
||||
.title('Loop ID')
|
||||
.describe('The ID of the loop email. Only one of Campaign ID or Loop ID must exist.'),
|
||||
})
|
||||
|
||||
export const fullEmailEventSchema = _baseEmailEventSchema.extend({
|
||||
sourceType: z
|
||||
.enum(['campaign', 'loop', 'transactional'])
|
||||
.title('Source Type')
|
||||
.describe('The type of email that triggered the event. One of campaign, loop, or transactional'),
|
||||
campaignId: z
|
||||
.string()
|
||||
.optional()
|
||||
.title('Campaign ID')
|
||||
.describe('The ID of the campaign email. Only one of Campaign ID or Loop ID must exist.'),
|
||||
loopId: z
|
||||
.string()
|
||||
.optional()
|
||||
.title('Loop ID')
|
||||
.describe('The ID of the loop email. Only one of Campaign ID or Loop ID must exist.'),
|
||||
transactionalId: z
|
||||
.string()
|
||||
.optional()
|
||||
.title('Transactional ID')
|
||||
.describe('The ID of the transactional email. Only one of Campaign ID, Loop ID, or Transactional ID must exist.'),
|
||||
})
|
||||
Reference in New Issue
Block a user