Fonio

Build your own integration

Connect your assistant to any tool with the fonio SDK, test it live, and send it to us with one command.

An integration connects your fonio assistant to another tool, such as your CRM, your booking system or your ticketing software. We already offer many integrations under Integrations. If the tool you need isn't there yet, you can build the integration yourself with our free SDK.

What an integration does

An integration gives your assistant new abilities around a conversation:

  • Before the conversation

    It loads what your assistant should know, for example the caller's customer record or their open orders.

  • During the conversation

    It gives your assistant actions it can take while it talks to someone, for example booking an appointment, checking an order status or creating a ticket. We call each action a tool.

  • After the conversation

    It follows up, for example by saving a summary in your CRM or sending a notification to your team.

Every integration also brings its own settings form. Whoever adds the integration to an assistant connects their account there (with an API key or a sign-in) and chooses what the assistant may do.

What you need

  • Node.js 24 or newer
  • The ngrok CLI with your authtoken configured, so fonio can reach the integration while it runs on your computer
  • A fonio account with an API key
  • The API documentation of the tool you want to connect
1

Create your project

The SDK is the public npm package @fonio/sdk. It contains everything you need: the building blocks for your integration, a local development server and the fonio command line tool.

Create a new project with it:

npx @fonio/sdk new my-integrations
cd my-integrations
npm install

You get a ready-to-run project with one example integration in src/manifests/example, including one example tool. One project can hold several integrations. Add more with the generators, which also register the new files for you:

npx fonio g manifest <key>
npx fonio g tool <key> [integration]
2

Connect it to your fonio account

In fonio, open API Keys in the menu and create a key. Put it into the .env file of your project:

FONIO_API_KEY='<your key>'

Then start the development server:

npm run dev

Your integration now runs on your computer and is connected to your fonio account through a secure, temporary tunnel. You can add it to your own assistants right away and try every change live, because the server reloads as soon as you save a file. Press Ctrl+C to disconnect.

For development only

The development server is meant for building and testing. Don't use it to serve your customers. When your integration is ready, send it to us as described in the last step.

3

Describe your integration

Each integration is described in its manifest.ts. The manifest says what the integration is called, which settings it has, how it connects to the other tool and which tools it offers:

import { AgentKind, AuthenticationMethod, defineIntegration } from '@fonio/sdk';

export const orderManifest = defineIntegration<Config>({
  key: 'order-lookup',
  icon, // an inline SVG
  translations, // name, description and setting labels per language
  supportedAgentKinds: [AgentKind.VOICE, AgentKind.CHAT],
  configSchema, // the settings form
  authenticationMethod: { type: AuthenticationMethod.CUSTOM, connectionSchema, headers },
  tools: [getOrderStatusTool],
});
  • Settings

    configSchema is a zod object. Each field becomes one input in fonio, for example a text field, a switch, a dropdown or a template with variables.

  • Connection

    Choose how users connect their account: no connection, their own credentials (such as an API key), or OAuth 2.0. fonio stores the credentials and adds them to every request your integration makes through context.http.

  • Languages

    Give your integration a name, a description and labels for its settings. One language is enough. Add more so users see it in their own language.

If something in the manifest is missing or wrong, the SDK tells you at startup and lists every problem at once.

4

Give your assistant tools

A tool is an action your assistant can take during a conversation. You describe what it does and which details it needs, and you write the code that runs it:

const parameters = z.object({
  orderNumber: z.string().describe('The order number the caller gives'),
});

export const getOrderStatusTool: IntegrationToolDefinition<Config, typeof parameters> = {
  key: 'get-order-status',
  supportedAgentKinds: [AgentKind.VOICE, AgentKind.CHAT],
  displayName: async () => 'Get order status',
  description: async () => 'Looks up the current status of an order.',
  instanceName: async () => 'Orders',
  instanceDescription: async () => '',
  parametersSchema: async () => parameters,
  executor: async ({ http, parameters }) => {
    const order = await http.get<Order>(`https://api.example.com/orders/${parameters.orderNumber}`);
    return buildSuccessExecutionResult(`The order is ${order.status}`, parameters, { order });
  },
};

Your assistant decides on its own when to use a tool, based on its description and the conversation. Clear descriptions lead to better decisions.

Beyond tools, the SDK also supports:

  • Before and after the conversation: preConversation and postConversation hooks
  • Extra instructions: text that fonio adds to your assistant's instructions
  • Dynamic dropdowns: options loaded live from the other tool
  • Checks when saving: validate a user's settings or connection before fonio saves them
  • Helpers: phone number matching, retries, templates, transcripts, and sending SMS or emails

The SDK documentation explains every option with examples.

5

Test it with your assistant

While npm run dev is running:

  1. Open one of your assistants in fonio and add your integration under Integrations.
  2. Connect your account and fill in the settings.
  3. Start a test call or chat and ask for something your tool can do.

Errors from your code show up in your terminal, and your changes are live as soon as you save.

Treat outside content with care

Data from other systems can contain text that tries to give your assistant instructions. Mark such content clearly as data and never as instructions.

6

Send it to us with fonio publish

Once your integration works, submit it with one command:

npx fonio publish <integration>

The command packages your integration, checks that it starts, and sends it to us together with its name, description, icon and tools. We review every submission before it goes live. Each submission gets its own version, so you can send an update at any time by running the command again.

By default, a published integration is available only to the companies you resell to, if you are a reseller. If you want to release it for all fonio customers, write us at support@fonio.ai.

Good to know

  • Allowed packages

    A published integration can only use @fonio/sdk, zod and the modules built into Node.js. fonio publish stops if your code imports anything else. For common tasks such as HTTP requests, phone numbers and retries, use the helpers in the SDK.

  • Limits

    The packaged integration can be up to 1 MB. It needs an icon (up to 20,000 characters of SVG), names can be up to 100 and descriptions up to 1,000 characters, and an integration can have up to 50 tools.

  • One session at a time

    Every npm run dev starts a new session and ends the previous one. Keep it running while you test.

  • Channels

    An integration can work for phone calls, chats and emails. You choose the channels for the integration and for each tool.

If something isn't working

What happensWhat to check
npm run dev stops right awayIs FONIO_API_KEY set in .env? Is the key still listed under API Keys in fonio?
The tunnel doesn't startIs the ngrok CLI installed and on your PATH, with your authtoken configured?
The SDK reports problems with the manifestEvery setting needs a renderer and a label in at least one language. The error lists every field that is affected.
Your integration doesn't appear in fonioIs npm run dev still running? Are you in the fonio account the API key belongs to?
fonio publish stops because of an importRemove packages other than @fonio/sdk and zod, and use the SDK helpers instead.
fonio publish says the integration is too largeKeep the package under 1 MB, for example by removing large data from your code.

Need help?

Just write us at support@fonio.ai, we're happy to help.