UNPKG

@vulture916/activepieces-piece-lemlist

Version:

Lemlist integration for ActivePieces - Email outreach and sales engagement platform

51 lines (47 loc) 1.58 kB
const { createAction, Property } = require('@activepieces/pieces-framework'); const { HttpMethod } = require('@activepieces/pieces-common'); const { lemlistAuth } = require('../../common/auth'); const { lemlistClient } = require('../../common/client'); exports.exportCampaignLeads = createAction({ auth: lemlistAuth, name: 'export_campaign_leads', displayName: 'Export Campaign Leads', description: 'Export the leads of a campaign', props: { campaignId: Property.ShortText({ displayName: 'Campaign ID', description: 'The ID of the campaign to export leads from', required: true, }), state: Property.StaticDropdown({ displayName: 'Lead State', description: 'Filter leads by their state', required: false, options: { options: [ { label: 'All', value: 'all' }, { label: 'Interested', value: 'interested' }, { label: 'Not Interested', value: 'notInterested' }, { label: 'Replied', value: 'replied' }, { label: 'Bounced', value: 'bounced' }, { label: 'Unsubscribed', value: 'unsubscribed' }, ], }, }), }, async run(context) { const { campaignId, state } = context.propsValue; const queryParams = state && state !== 'all' ? { state } ; const leads = await lemlistClient.makeRequest( context.auth, HttpMethod.GET, `/campaigns/${campaignId}/export/leads`, undefined, queryParams ); return { leads, count: Array.isArray(leads) ? leads.length : 0, }; }, });