Skip to main content
Client functions let you extend what AGO agents can do by registering JavaScript functions in the browser. When the agent determines that a registered function is relevant, it calls it automatically — the SDK executes the function locally and sends the result back to the agent. This enables use cases like:
  • Navigating your application — open a specific page, scroll to a section, or show a modal
  • Reading application state — return the current user’s cart, selected filters, or form values
  • Triggering UI actions — open a contact form, start a product tour, or play a video
  • Calling browser APIs — get the current time, geolocation, or clipboard contents

How It Works

The agent sees a description of each function and its parameters. Based on the conversation context, it decides whether and when to call a function — you do not need to trigger it manually.

Registering a Function

Use client.registerFunction() with three arguments: a name, a handler, and a schema that describes the function to the agent.

Function with Parameters

Schema Reference

Each property in parameters.properties accepts:

Naming Rules

Function names must follow these rules:
  • Only letters, numbers, underscores, and hyphens
  • Between 1 and 50 characters
  • No spaces or special characters
Valid names: getCurrentTime, add-to-cart, search_products Invalid names: get current time, ../hack, my@function

Unregistering a Function

Remove a function when it is no longer relevant:
This is useful when navigating between pages where different functions apply. For example, register cart functions only on the product page and unregister them when the user navigates away.

Listing Registered Functions


Listening to Function Events

Track when functions are invoked and when results are returned:

Error Handling

If a registered function throws an error, the SDK catches it and sends the error message back to the agent. The agent can then inform the user or try an alternative approach.

Best Practices

Write Clear Descriptions

The agent relies on the description field to decide when to call a function. Be specific about what the function does and when it should be used.

Return Structured Data

Return objects with descriptive keys so the agent can use the information in its response.

Keep the Number of Functions Low

You can send up to 30 client functions with a message. Above that, the request is rejected. Stay well under the limit whenever you can. The more functions the agent has to choose from, the harder it becomes to pick the right one — past 10 functions in a single message, expect the agent to call the wrong function or miss the right one more often. Register only the functions relevant to the current page or state, and unregister the ones that no longer apply.

Keep Functions Focused

Each function should do one thing. Register multiple focused functions rather than one function that does everything.

Register Contextually

Register functions that are relevant to the current page or state. On a product page, register product-related functions. On the checkout page, register checkout-related functions.

Complete Example