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
- Open Dashboard → Functions.
- Click Add Function.
- Set the function name to
handoff_to_operator. - Add a clear description so the assistant knows when to use it (example:
Escalate to a human support operator when needed). - Define the JSON schema for parameters (for example
reasonand optionalpriority). - Save the function and publish your environment changes.
3) What to test in the chat UI
- Open the AskVio preview/chat UI.
- Send a prompt like:
I need to talk to a human agent about my issue. - Confirm the assistant responds with a visible action button (for example, Handoff to operator).
- Click the button and verify your
onFunctionCallhandler runs and your backend receives the payload. - Confirm the expected outcome appears in UI (for example:
Your request has been sent to a human 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.