Functions Pro

Functions allow user-triggered actions from answers (for example, “Check order status”). Configure each function with a safe handler reference, description, and parameter schema.

Important: Functions can perform real operations. Validate inputs, require explicit user confirmation, and test in the test environment before publishing.

What functions are (and why they matter)

A function is a structured action your assistant can trigger from the chat UI when a user asks for something operational, such as handoff to a human operator.

Instead of returning only text, AskVio can show an actionable UI control (for example a button) that maps to a function call with validated inputs. This helps you move from answers to real workflows.

Example: handoff_to_operator

In this example, the assistant suggests escalation and exposes a button that triggers a handoff_to_operator function call with the current conversation context.

1) Declare the function on the front end

Your front-end integration must include the function definition and a handler for the function name. The exact setup can vary by implementation, but the shape should look like this:

window.AskVioWidget.init({
  clientId: "YOUR_CLIENT_ID",
  functions: [
    {
      name: "handoff_to_operator",
      description: "Escalate the conversation to a human support operator",
      parameters: {
        type: "object",
        properties: {
          reason: { type: "string", description: "Why the user wants escalation" },
          priority: { type: "string", enum: ["low", "normal", "high"] }
        },
        required: ["reason"]
      }
    }
  ],
  onFunctionCall: async ({ name, arguments: args }) => {
    if (name === "handoff_to_operator") {
      // Example: call your backend/ticketing API
      const response = await fetch("/api/handoff", {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify(args)
      });

      return await response.json();
    }
  }
});

2) Create the function in the AskVio UI

  1. Open Dashboard → Functions.
  2. Click Add Function.
  3. Set the function name to handoff_to_operator.
  4. Add a clear description so the assistant knows when to use it (example: Escalate to a human support operator when needed).
  5. Define the JSON schema for parameters (for example reason and optional priority).
  6. Save the function and publish your environment changes.
Screenshot placeholder: AskVio Dashboard Functions page with the Add Function button highlighted before creating handoff_to_operator.

3) What to test in the chat UI

  1. Open the AskVio preview/chat UI.
  2. Send a prompt like: I need to talk to a human agent about my issue.
  3. Confirm the assistant responds with a visible action button (for example, Handoff to operator).
  4. Click the button and verify your onFunctionCall handler runs and your backend receives the payload.
  5. Confirm the expected outcome appears in UI (for example: Your request has been sent to a human operator.).
Screenshot placeholder: AskVio chat UI showing the assistant response with a Handoff to operator button that calls handoff_to_operator.

Expected outcome

  • The function is listed in your AskVio Functions page.
  • The assistant can choose the function when the user intent matches escalation.
  • The chat UI shows a button/action that the user can click.
  • Clicking the action executes your front-end handler and connected backend flow.