Quick Start

Integrating Userize into your application is simple and has a minimal impact on your existing codebase — it can take as little as 2 lines of code (plus imports):

import { registerAction, triggerActions } from "userize-js";
import { doSomething } from "lib/my-functions"; // Import your custom logic
 
registerAction("do_it", doSomething);
 
triggerActions("YOUR USER QUERY GOES HERE");

Following these steps, you’ll be ready to run your first AI-triggered action in minutes!

Step 1: Set up your Project

To get started, visit the Userize platform and either log in or create a new account.

Create a new project

Once you’re logged in, you can create a New Project. Click on the button and choose:

  • Project’s Name and Description: This information helps you and your team easily identify the project.
  • Invite Members: You can immediately invite people to collaborate on the project, or you can do it at a later stage.

Get your API key

In the Project Settings page, you can generate your unique API key.

⚠️

This API key is unique for your account on this project. Do not share it with anyone.

Ensure you copy and securely store the key: it will authenticate your API requests.

ℹ️

The Userize package will automatically attempt to import the key from the environment variable USERIZE_API_KEY.

Step 2: Configure the Actions

Configuring actions is a crucial step in setting up your project. A clear explanation of your actions and their respective parameters can significantly improve the relevance of actions selected by the GenAI model to fulfill the user’s request.

That is why we recommend you to start from Example Templates, that you can fully customize to suit your needs:

Explore Actions Templates

Alternatively, just navigate to the Actions configuration page and… ask Userize to create actions for you! Under the hood, it will simply trigger actions with userize-js, just like you’ll be doing shortly.

Write an Actions Overview

On the Actions configuration page, you have the possibility to describe what your actions will be used for. The API will work fine even without it, but providing this overview on you app can help generate more accurate results.

Click on the empty description at the top of the page, and explain what your application does and how it will use the actions.

Customize an Action

You can deeply customize an action to ensure the behavior matches your expectations. You can find examples of actions ready for real-case scenarios here.

To start, click on the New action button to create a new action.

Then, update the action configuration:

  1. Click on the action name, and update it to a meaningful_name.
  2. Click on the action description, and explain what the action does.
  3. Add a parameter and rename it.
    • Describe how the parameter is useful to the action.
    • Set the datatype your action expects.
    • Optionally, include a list of values to limit your parameter to.
  4. Save the action.

Step 3: Add Userize to your App

Install userize-js

First, install userize-js using your preferred package manager:

npm install userize-js

Add your API key

If you have stored your API key in the environment variable USERIZE_API_KEY, you can skip this step.

Otherwise, you should explicitly set the API key in your code:

example-userize.js
import { initClient } from "userize-js";
 
initClient("YOUR-API-KEY");

Register the actions

When you register an action, it becomes ready to be triggered by the API. Assuming your app logic is implemented, registering an action takes just 1 line of code:

example-userize.js
import { initClient, registerAction } from "userize-js";
import { doSomething } from "lib/my-functions"; // Import your custom logic
 
initClient("YOUR-API-KEY");
 
// The action name "do_it" should match the name you chose on the platform
registerAction("do_it", doSomething);

Or, if your action doesn’t need the additional cascade parameter:

example-userize.js
import { initClient, registerAction } from "userize-js";
import { doSomething } from "lib/my-functions"; // Import your custom logic
 
initClient("YOUR-API-KEY");
 
// The action name "do_it" should match the name you chose on the platform
registerAction("do_it", (cascade, ...rest) => doSomething(...rest));
ℹ️

Every action’s first argument is a UserizeActionCascade. It embeds useful information on the Actions Cascade, and allows exchanging data between actions.

Step 4: Trigger Actions Cascade

Finally, you are ready to trigger your actions by Generative AI.

To initiate the Actions Cascade, simply pass a user’s request to triggerActions:

use-userize.js
import { triggerActions } from "userize-js";
 
// You can trigger actions whenever you want,
// for instance, when a user submits a request
function onInputSubmit(text) {
  // Your logic to handle the user's input
 
  triggerActions(text);
}

🎉 Congratulations!

You’ve successfully built and tested your first AI-powered action cascade with Userize! 🚀

Next Steps

  1. Customize Actions for Your Project: Tailor actions to suit your specific project needs and workflows.
  2. Explore Advanced Topics: Dive into advanced features to achieve more accurate results, enhance your project’s security, and build more complex action cascades.
  3. Collaborate: Share your feedback and contribute to the project by reporting issues or suggesting improvements.