Scoopika for the Web
This guide provides a walkthrough for integrating Scoopika into your web application, covering both server-side and client-side setup.
Key concepts
Scoopika Endpoint: A central container that handles API requests related to Scoopika functionalities. It can be easily added to an API route and should work with any web frameworks that supports HTTP streaming.
AI Agents: Personalized LLM-powered assistants. Created from the platform and executed on your servers.
Tools: Custom functions that extend the capabilities of agents. Allowing the agent to call the function to perform actions or fetch data based on the context.
Client-side Actions: A special type of tools defined and executed on the client-side, enabling agents to safely execute tools on the client-side in real-time (example: clicking a button).
We provide examples for integrating Scoopika with a lot of frameworks, check the Usage page for more info based on the framework you’re using.
However, This example shows how to use Scoopika in a simple Express server (for its simplicity).
Server-Side Integration
1. Installation
The first step involves installing the Scoopika package for server-side use:
2. Initialize
Let’s initialize Scoopika and set up your agents. Here’s a basic example:
Refer to the following resources for more details:
Custom setup
For more advanced scenarios where you want to add tools to your agents,
the agents
property can take a function that allows for custom agent setup logic and returns
an array of agents:
3. Add API Route
Now, create an API route within your framework (e.g., Express) to handle Scoopika requests using the Scoopika Endpoint. This example demonstrates usage with Express:
This route will now be able to handle running anything related to Scoopika from running agents or boxes, getting their info, and managing history sessions. Refer to the Scoopika Endpoint documentation for more info.
Client-side
1. Installation
On the client-side, install the Scoopika client package:
2. Initialize and Run
Now you can initialize a Scoopika client, an agent, and run it:
This example shows almost all the actions you can do on the client-side:
For comprehensive instructions and API reference, refer to the Scoopika Client documentation.
Tools (optional)
Scoopika allows you to equip your agents with tools, extending their capabilities. These tools can be defined and executed on either the server-side or client-side.
For full docs on tools, refer to the Tools documentation.
API Tools
API tools are added from the platform with no-code. they can be used to give agents the ability to call external APIs. you define the API url, headers, body, and method. the tool also takes inputs that are passed from the agent when calling it, and they can be used in the tool’s url or request body.
Server-side Tools
Server-side tools are custom functions that you add to agents on the server. You can define the tool’s arguments using a Zod schema, allowing Scoopika to validate the agent’s outputs when calling the tool, ensuring stability and type safety. The results returned by this function are sent back to the agent for further processing (learn more about tools).
To add tools from the server-side, you need to use a custom agents setup function:
Client-side Actions (Client-side Tools)
Similar to server-side tools, you can equip agents with tools defined and executed on the client-side. These are called Client-side actions.
Key Difference
Unlike server-side tools, results from client-side actions are not returned to the agent. This means they cannot be used for data retrieval but are ideal for allowing the agent to perform actions on the client-side in real-time, such as clicking buttons or typing in inputs. Refer to the Client-side actions documentation for details and examples.
Adding Client-side Actions
The process for adding client-side actions is similar to server-side tools. You just define a schema and pass a custom function from the client-side as a tool.
Example:
Remember: When the agent calls a client-side action, it executes on the client-side in real-time, enabling dynamic interactions within the web application.
See how to build your tools for more information on how to define your tools schema.
Next steps
Now that you have setup Scoopika on both the server-side and the client-side, the fun part starts. Memory is managed for you, streaming is managed for you, validation is also managed for you, what you gonna do? well just focus on building your application and unique features. good luck!
We strongly recommend you check the full docs and API reference for both Packages.
Was this page helpful?