> ## Documentation Index
> Fetch the complete documentation index at: https://kapso-1adbad2d.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Started by external trigger

> How agents process execution initiated by API calls or webhooks

## External trigger flow

<Note>
  This flow is initiated programmatically, e.g., via an API call or a configured webhook trigger.
</Note>

The sequence is as follows:

<Steps>
  <Step title="External trigger">
    An external event (e.g., a `POST` request to an agent execution API endpoint) triggers the execution.
  </Step>

  <Step title="Agent execution begins">
    Kapso identifies the target Agent and starts a new Agent execution from the `Start` node.
  </Step>

  <Step title="Initiating WhatsApp conversation (requires template)">
    <Warning>
      * **Constraint:** To send the *first* message to a user via WhatsApp, the first node after `Start` *must* be a `WhatsappTemplateNode`.
      * **Reason:** Required by WhatsApp Business API policy.
      * **Action:** The `WhatsappTemplateNode` sends the specified approved template to the target user.
    </Warning>
  </Step>

  <Step title="Subsequent steps">
    Graph execution continues.

    * Nodes might send further messages (if allowed) or perform actions (e.g., call webhooks).
    * Execution pauses if a node requires user input.
  </Step>

  <Step title="User reply">
    If the user replies, their message initiates the [User message flow](./user-message-flow).
  </Step>

  <Step title="Ending execution">
    Execution concludes when an `End` node is reached.
  </Step>
</Steps>

## WhatsApp template requirements

When initiating WhatsApp conversations programmatically:

* **First Message:** Must use a pre-approved WhatsApp template.
* **Template Node:** The Agent Graph must use a `WhatsappTemplateNode` immediately after the `Start` node.

## Related topics

<CardGroup cols={2}>
  <Card title="User Message Flow" icon="message" href="./user-message-flow">
    Learn how agents process user-initiated messages
  </Card>

  <Card title="WhatsApp Template Node" icon="whatsapp" href="../nodes-and-edges/whatsapp-template-node">
    Learn how to configure template messages
  </Card>
</CardGroup>
