# Define site action | SmartOperator Documentation

> Site-specific tasks (add to cart, appointment form, coupon) are defined with SmartOperator.eylemTanimla. The agent can only call defined actions.

Source page: https://dblinx.net/en/smartoperator/belgeler/gelistirici/site-eylemi-tanimlamak

---

# Define site action

Site-specific tasks (add to cart, appointment form, coupon) are defined with SmartOperator.eylemTanimla. The agent can only call defined actions.

- Developer

## How to define a site action?

Site-specific tasks (add to cart, appointment form, coupon) are defined with SmartOperator.eylemTanimla. Who can do this: Developer. The agent can only call defined actions. Parameters are validated against your definition before reaching the handler: fields not in the definition are discarded; if type, en_az, or secenekler do not match, the handler is not called and a gecerersiz_parametre error is returned to the agent.

```
<script>
  SmartOperator.eylemTanimla("sepeteEkle", {
    aciklama: "Ürünü sepete ekler",
    parametreler: {
      urunId: { tur: "metin" },
      adet: { tur: "sayi", en_az: 1 }
    },
    onayGerekir: false
  }, async function ({ urunId, adet }) {
    await sepet.ekle(urunId, Number(adet) || 1);
    return { tamam: true, sepetAdedi: sepet.adet() };
  });
</script>
```

## Steps

Define the action on your pages, before or after the script tag; the tag's preparation line queues early calls.

aciklama: a short description so the agent understands when to use the action.

parametreler: for each parameter, tur (metin or sayi); optional en_az and secenekler (list of allowed values).

onayGerekir: if true, the action does not execute unless the visitor clicks “Confirm” in the chat.

The handler returns a result object (e.g., { tamam: true }); the result is passed to the agent. If an error is thrown, it is passed as { tamam: false, hata }.

**Parameter validation**Parameters are validated against your definition before reaching the handler: fields not in the definition are discarded; if type, en_az, or secenekler do not match, the handler is not called and a gecersiz_parametre error is returned to the agent. Business rules such as product availability should still be checked in your handler.

**Payment page**No actions run on payment pages; your handler is not called on these pages.

## Related pages

- [Trigger action on visitor's page](/en/smartoperator/belgeler/temsilci/sayfada-eylem-calistirmak.html)

- [Site actions](/en/smartoperator/site-eylemleri.html)
