- Extract structured data from an unstructured prompt
- Verify a Boolean condition within a piece of content
- Generate or summarize text
For a full list of available methods, check out the reference section.
Installation
To install Zai for local development, run the following command in your terminal:- The official Botpress client, which is necessary to create a Zai instance
- The internal Zui library, which helps create Zod schemas for many of Zai’s methods
Quick start
To get started, import the libraries and create a newClient object using your Bot ID and Personal Access Token (PAT):
Zai instance and pass in the Client:
If you’re using Zai within Botpress Studio, you don’t need to create a new
Zai instance—it’s already available globally as zai.Usage examples
Here are some examples of how you can use Zai:Get structured data from text
Use theextract method to get structured data from a plain piece of text:
Verify a condition
Use thecheck method to verify a condition against some input:
Filter an array
Use thefilter method to filter elements of an array based on a condition:
Label content with categories
Use thelabel method to categorize content with predefined labels:
Rewrite text according to instructions
Use therewrite method to transform text based on specific instructions:
Summarize long content
Use thesummarize method to create concise summaries of lengthy text:
Generate text from prompts
Use thetext method to generate content based on prompts: