# Write and automate a script (/use-cases/rd-product/automation-scripts)



Copy this prompt to start your first task:

<Prompt>
  Set up an automation that pulls from a data source, applies a processing rule, and writes the result to an output location on a schedule. Write the script with error handling, run it once on a sample, and only alert me if it fails or the results look anomalous.
</Prompt>

<LivePreview component="NewThread" scenario="{ draft: &#x22;Set up an automation that pulls from a data source, applies a processing rule, and writes the result to an output location on a schedule. Write the script with error handling, run it once on a sample, and only alert me if it fails or the results look anomalous.&#x22; }" />

## What is this workflow? [#what-is-this-workflow]

Writing and automating a script means giving a teammate a data source, a transformation rule, and a target format for a task that's too small to justify a real engineering ticket but too repetitive to keep doing by hand. It writes the script with error handling and a short runbook, not a bare script that breaks on the first edge case, and if you ask it to save and schedule the script, a one-time answer becomes a reusable tool.

## How to use this workflow [#how-to-use-this-workflow]

<Steps>
  <Step>
    ### Hire a software engineer [#hire-a-software-engineer]

    Open **AI Teammates** in the sidebar, click **Hire AI Teammate**, and pick the **Software Engineer** template. Confirm the name and click **Create teammate**. They land in their own channel, which is where you'll send everything below. [More on hiring →](/ai-teammates/hire-an-ai-teammate)

    <LivePreview component="CreateAssistantPage" />
  </Step>

  <Step>
    ### Give it the source, the rule, and the target [#give-it-the-source-the-rule-and-the-target]

    <Prompt>
      Write a script that takes our weekly signup CSV export, dedupes by email, and reformats it to match our CRM's import template. Add error handling for malformed rows, and a short note on how to run it.
    </Prompt>

    <LivePreview
      component="AssistantChat"
      scenario="{ assistantName: &#x22;Software Engineer&#x22;, messages: [
    { author: &#x22;user&#x22;, text: &#x22;Write a script that takes our weekly signup CSV export, dedupes by email, and reformats it to match our CRM's import template. Add error handling for malformed rows, and a short note on how to run it.&#x22; },
    { author: &#x22;assistant&#x22;, text: &#x22;Writing the script now: dedupe by email, reformat to the CRM's import template, with error handling for malformed rows. I'll include a short note on how to run it.&#x22; },
  ] }"
    />
  </Step>

  <Step>
    ### Turn a repeating task into an automation [#turn-a-repeating-task-into-an-automation]

    If this is something you'll run every week rather than once, open **Automations** in the sidebar, click **Create via Chat**, and pick this teammate in the New Thread composer that opens. Each week's data needs to land somewhere the teammate can reach; attaching it to the channel works:

    <Prompt>
      Every Monday at 8am, run this same cleanup on that week's signup export and post the result to #growth-ops.
    </Prompt>

    <LivePreview component="NewThread" scenario="{ populated: false }" />
  </Step>
</Steps>

## Tips for Better Results [#tips-for-better-results]

| Tip                                              | Description                                                                                             |
| ------------------------------------------------ | ------------------------------------------------------------------------------------------------------- |
| Name the source, the rule, and the target format | The three things the script actually needs. Leaving one vague gets you a script that guesses.           |
| Ask for error handling up front                  | A bare script that breaks on the first malformed row costs more time than writing the handling once.    |
| Schedule it if you'll run it again               | A one-time answer and a reusable automation start from the same script — the difference is just asking. |

## Common Questions [#common-questions]

<Accordions type="single">
  <Accordion title="What kind of task is this a good fit for?">
    Something too small to justify a real engineering ticket but too repetitive to keep doing by hand — a recurring data cleanup or reformat, for example.
  </Accordion>

  <Accordion title="Does it just hand me a script, or does it run it too?">
    Both are options. Ask once for a one-off answer, or ask it to save and schedule the script if you'll need it again.
  </Accordion>

  <Accordion title="Do I need to ask for error handling separately?">
    Ask for it in the same request. Naming it up front (handling for malformed rows, a short note on how to run it) gets it built in from the start, instead of a bare script you have to send back for revision.
  </Accordion>
</Accordions>

<Cards>
  <Card title="R&D & Product" href="/use-cases/rd-product" description="Back to the R&D & Product use case overview." />
</Cards>
