import { definePlay } from 'deepline';
type SearchInput = {
query: string;
owner_email: string;
};
type Account = {
domain: string;
owner_email: string;
};
export default definePlay('weekly-new-accounts', async (ctx, input: SearchInput) => {
const companies: Account[] = [
{ domain: 'example.com', owner_email: input.owner_email },
{ domain: 'acme.com', owner_email: input.owner_email },
];
const enriched = await ctx.dataset('new_accounts', companies)
.withColumn('signals', (account, rowCtx) =>
rowCtx.tools.execute({
id: 'company_research',
tool: 'test_rate_limit',
input: { key: `${input.query}:${account.domain}` },
description: 'Research the new account.',
}),
)
.withColumn('salesforce', (account, rowCtx) =>
rowCtx.tools.execute({
id: 'create_salesforce_task',
tool: 'test_rate_limit',
input: {
key: `${account.domain}:${account.owner_email}`,
},
description: 'Create the owner follow-up task.',
}),
)
.run({ key: 'domain', description: 'Research new accounts and create Salesforce tasks.' });
return { rows: enriched };
});