Docsvoxioagent 2.0.0

Build your own

Web actions

Let the agent fill in forms, click buttons and scroll your page while it talks.

When the flow decides to act on the page, the agent sends a web action alongside its speech. The SDK finds the element by what it's called on screen (its label, text or placeholder), does what a person would, and tells the agent whether it worked. Each action runs in the pause after the words that go with it, so the page moves while the agent says what it's doing.

Web actions are on in every voice session and widget unless you turn them off.

Built-in actions

ActionWhat it does
clickClicks a button, link or control.
fill_fieldTypes a value into a field the way typing would, so React, Vue and plain forms all notice.
focusMoves focus to an element.
scroll_toScrolls an element into view.
highlightDraws attention to an element.
navigateOpens a URL on an allowed origin.

Limit where actions run

Keep actions inside your app and away from other sites:

createSession({
flowKey: "YOUR_FLOW_KEY",
webActions: {
root: () => document.querySelector("#app"), // where to look (default: the whole page)
allowedOrigins: ["https://shop.example.com"], // where navigate may go (default: this origin)
timing: "after-speech", // or "immediate"
},
});

Add your own actions

To replace a built-in action or add a new one, give a handler for its name. Return "ok" or "error", and the agent hears which:

createSession({
flowKey: "YOUR_FLOW_KEY",
webActions: {
handlers: {
add_to_cart: async (action) => ((await addToCart(action.value)) ? "ok" : "error"),
},
},
});

An action carries action (its name) and, as needed, target, within, value, selector, url and timeout.

Handle actions yourself

To run every action with your own code, turn the runner off and answer each one:

const session = createSession({ flowKey: "YOUR_FLOW_KEY", webActions: false });
session.on("webAction", async (message, ack) => {
const ok = await myRouter.handle(message.action);
ack(ok ? "ok" : "error");
});

Next steps