> ## Documentation Index
> Fetch the complete documentation index at: https://docs.flowyte.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Take an order with a delivery check

> A phone agent that knows your menu, confirms the delivery address is in range, and sends the order to your kitchen.

This guide builds a phone agent for a restaurant that answers menu questions, takes an order,
checks that the delivery address is in your zone, and posts the confirmed order to your kitchen.
Every step is one API call against `https://builder.flowyte.com/api/v1`.

<Note>
  Authenticate every request with a secret API key: `Authorization: Bearer flowyte_sk_…`. See
  [Authentication](/get-started/authentication) to mint one.
</Note>

<Steps>
  <Step title="Create the agent">
    Capture `data.id` as your `AGENT_ID`.

    ```bash theme={null}
    curl -X POST https://builder.flowyte.com/api/v1/agents \
      -H "Authorization: Bearer $FLOWYTE_API_KEY" -H "Content-Type: application/json" \
      -d '{ "name": "Tony's Pizza", "primaryLanguage": "en" }'
    ```
  </Step>

  <Step title="Load the menu as knowledge">
    Add your menu so the agent answers "what's on the supreme?" and "how much is a large?" from the
    real thing. Ingestion is **asynchronous** — poll the source until `status` is `indexed`.

    ```bash theme={null}
    curl -X POST https://builder.flowyte.com/api/v1/agents/$AGENT_ID/knowledge/sources \
      -H "Authorization: Bearer $FLOWYTE_API_KEY" -H "Content-Type: application/json" \
      -d '{ "kind": "url", "label": "Menu", "url": "https://tonyspizza.com/menu" }'
    ```
  </Step>

  <Step title="Add a delivery-area check">
    A free `geo` skill with the `check_service_area` action. Set your shop address as the origin and
    your delivery radius. The agent asks for the address and confirms coverage before taking a
    delivery order — and offers pickup if it's out of range.

    ```bash theme={null}
    curl -X POST https://builder.flowyte.com/api/v1/agents/$AGENT_ID/skills \
      -H "Authorization: Bearer $FLOWYTE_API_KEY" -H "Content-Type: application/json" \
      -d '{
            "name": "Check delivery area",
            "description": "Check whether the caller's delivery address is within our delivery zone before taking a delivery order.",
            "skillType": "geo",
            "executionConfig": {
              "action": "check_service_area",
              "originAddress": "120 Main St, Boulder, CO",
              "radiusMiles": 5
            }
          }'
    ```
  </Step>

  <Step title="Send the order to the kitchen">
    An `http_webhook` skill posts the confirmed order to your kitchen display or POS. The agent fills
    in the parameters it collected on the call.

    ```bash theme={null}
    curl -X POST https://builder.flowyte.com/api/v1/agents/$AGENT_ID/skills \
      -H "Authorization: Bearer $FLOWYTE_API_KEY" -H "Content-Type: application/json" \
      -d '{
            "name": "Submit order",
            "description": "Send the confirmed order to the kitchen. Use after the caller confirms items and (for delivery) the address is in range.",
            "skillType": "http_webhook",
            "executionConfig": {
              "method": "POST",
              "url": "https://tonyspizza.com/api/orders",
              "parameters": [
                { "name": "items", "description": "The ordered items with size and quantity" },
                { "name": "fulfillment", "description": "delivery or pickup" },
                { "name": "address", "description": "Delivery address, if delivery" },
                { "name": "phone", "description": "Callback number" }
              ]
            }
          }'
    ```
  </Step>

  <Step title="Publish and test">
    Publish, then simulate an order. `simulate` streams over SSE — read it with `fetch()` streaming
    and stop on `event: done`.

    ```bash theme={null}
    curl -X POST https://builder.flowyte.com/api/v1/agents/$AGENT_ID/publish \
      -H "Authorization: Bearer $FLOWYTE_API_KEY"

    curl -N -X POST https://builder.flowyte.com/api/v1/agents/$AGENT_ID/simulate \
      -H "Authorization: Bearer $FLOWYTE_API_KEY" -H "Content-Type: application/json" \
      -d '{ "message": "Can I get a large supreme delivered to 200 Pearl St?", "draftMode": false }'
    ```
  </Step>

  <Step title="Put it on a number">
    Buy a number and point it at the agent — see [Buy a number & go live](/guides/buy-a-number).
  </Step>
</Steps>

<Tip>
  The agent only spends on a geocode when it has to look up a caller's address; the in/out-of-zone
  math itself is free.
</Tip>
