The Monday Brief Every week: what your customers asked for, what they couldn't find, and the one fix worth making first. See a brief →
ProblemHow it worksSafe to go liveIntelligenceFree auditPricingBlogDocs

Functions Pro

Functions turn an answer into an action. When a visitor asks for something your site can do, for example "talk to a person", the assistant shows a button. Clicking it runs a JavaScript function on your page with the details the assistant collected.

Important: functions run your own code. Validate the inputs, ask for confirmation before doing anything irreversible, and test in the Test environment before publishing.

How it works

  1. You describe the function in Functions: when to use it, the button label, the parameters to collect, and the handler reference, the name of a JavaScript function on your page.
  2. When a question matches, the assistant answers and shows the button.
  3. When the visitor clicks, the widget calls your handler with one object: { name, arguments, conversationId, history }.

Example: hand off to a person

1) Create the function in the dashboard

FieldExample
Namehandoff_to_human
DescriptionWhen the visitor asks for a person, suggest a handoff to support.
Button labelContact support
Handler referenceAskvioHandlers.contactSupport
Parameters (JSON schema){"type":"object","properties":{"reason":{"type":"string"}},"required":["reason"]}

2) Define the handler on your site

Add it to the same page as the widget (directly or in a tag manager tag). The handler reference must be a plain dotted path to a function on window.

<script>
  window.AskvioHandlers = {
    contactSupport: async ({ name, arguments: args, conversationId, history }) => {
      await fetch("/api/support-handoff", {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify({ reason: args.reason, conversationId })
      });
    }
  };
</script>

3) Test it

  1. In the preview, ask "I need to talk to a person about my order".
  2. Check that the answer shows the Contact support button.
  3. Click it and check that your handler runs. If nothing happens, the console shows [AskVio] Handler not found when the handler reference doesn't match a function on the page.

Each click is also sent to GA4 as function_invoked. Free plans don't include functions; Pro includes 3, Business and above unlimited.