eCG Cloud: data and actions

eCG Actions: server functions

eCG Actions are small server functions the agent writes for your app, such as taking a payment or sending an email. Learn to see, run and check them.

eCG Actions are the server-side work of your app. They do things a web page cannot do safely on its own: take a card payment, send an email, check a sign-in, or save an order using a private key.

You do not write them. The agent writes and changes every action. You use this page to see what exists, test an action, and read how it has been doing.

What an action is

Each action has a name, an optional description, and a list of inputs. It takes the inputs, does its work, and returns an output. For example, an action called send_receipt might take email and order_id and return sent: true.

Your app's pages call actions when a visitor does something, such as pressing Pay. Actions can read and write your eCG Data and can use your Secrets.

See the actions of all your apps

  1. In the left sidebar, under Platform, select Cloud.
  2. Select the eCG Actions tab.

Each app that has actions is one row:

Column What it shows
App name and Actions How many actions the app has and how many are active, for example "Actions: 4 (3 active)"
Calls (24h) How many times the actions ran in the last 24 hours
Failed (24h) How many of those runs failed. Shown in red when it is more than zero.
Last run Just now, "12 min ago", "3 hours ago", "2 days ago", or Not called yet

Apps with no actions yet are listed at the bottom under Apps without eCG Actions. Select one to open it in the editor.

If no app has actions, the tab says "No eCG Actions yet." and suggests: "Ask the agent in an app to add an action, such as saving an order or sending an email."

To see one app only, open it in the editor, open More actions, then Project settings, and choose eCG Actions under eCG Cloud. The page lists the actions with a number beside the title.

Open an app's actions

Select a row. A path such as eCG Actions > your app name appears at the top, with two buttons:

  • Open app takes you to the editor, where you can ask the agent for a change.
  • All apps returns to the list.

The note on the page repeats the rule: "The agent writes and changes these. Open the app and ask it to add or change one."

Each action is a row. Select it to open it. A row shows:

  • The action name and, if it has one, a description.
  • A Paused label if the action is switched off.
  • Under Input, the names of the values it expects, such as email or order_id, or none.

Run an action

Running an action is a good way to test what the agent built.

  1. Select the action to open it.
  2. Under Input, fill in a value for each name. Numbers, true, false, null and lists written in brackets are understood as such. Anything else is sent as text. Leave a field empty to leave it out.
  3. If the action takes no named input, the box says "This function takes no named input. You can still pass one:". Leave {} as it is, or write the input as JSON, which is a plain text format with curly brackets.
  4. Select Run. The button reads Running….
  5. Read the result under Output.

If your JSON is not valid you see "Input must be valid JSON" and nothing runs.

Read the output

You see It means
Name and value rows The action returned a result. Each name is one part of it.
"3 items" with the first few listed The action returned a list. "+2 more" appears for the rest.
"Empty object" It ran and returned nothing to show.
A red box with a message The run failed. The message says why.
"Not run yet. Run it to see what it returns." Nobody has run this action yet.
"Last successful run, 5 min ago" You are looking at the last good result, not a new run.

The time the run took, in milliseconds, is shown under the output.

Read the recent runs

Under Recent runs you see the last five times the action ran, whether you ran it or your app did. Each line shows a green or red dot, what went in (in), what came out (out), how long it took and how long ago it ran.

A red dot means that run failed. The out column then holds the error message.

When something is wrong

What you see What to do
A red number under Failed (24h) Open the app, open the action and read Recent runs. Copy the message of a red run.
A red message in Output Copy it. Paste it into the editor chat with "This action failed with this message. Please fix it." The agent can read it and repair the action.
Not called yet The app has not used the action. Press Run to test it, or check that a page of your app calls it.
Paused A paused action does not run for your visitors. Ask the agent in the chat why, and ask it to switch it back on.
A message that mentions a missing key or secret The action needs a secret that is not saved. Add it in Secrets. See Store keys and secrets safely.
A message that mentions a missing table Ask the agent to create it, or check eCG Data.

If a run fails with a message you do not understand, ask the agent: "Explain this error in plain words, then fix it."

Approving new actions

When the agent writes a new action or changes one that already exists, you may see a card in the chat for you to approve. See Approve database and server changes.