Skip to Content
SDKs

SDKs

AI

The AI function in functions.do and workflows.do allows Functions and Workflows to be defined in a strongly-typed way:

import { AI } from 'functions.do' const ai = AI({ // Define a Workflow as a Code Function ideaCaptured: async (idea, { ai, api, db }) => { const leanCanvas = await ai.leanCanvas({ idea }) await api.slack.postMessage({ channel: '#general', text: `${idea}\n${leanCanvas}` }) await db.idea.create({ idea, leanCanvas, status: 'Draft' }) }, // Define a strongly-typed Generation Function leanCanvas: { productName: 'name of the product or service', problem: ['top 3 problems the product solves'], solution: ['top 3 solutions the product offers'], uniqueValueProposition: 'clear message that states the benefit of your product', unfairAdvantage: 'something that cannot be easily copied or bought', customerSegments: ['list of target customer segments'], keyMetrics: ['list of key numbers that tell you how your business is doing'], channels: ['path to customers'], costStructure: ['list of operational costs'], revenueStreams: ['list of revenue sources'], recommendations: ['list of recommendations based on the analysis'], }, })

ai

The ai object in functions.do and workflows.do is extremely powerful and flexible. It can be used to call arbitrary object generation functions, generate text using template literals, and iterate over lists using async iterators:

import { ai } from 'functions.do' // Generate a Lean Canvas const leanCanvas = await ai.leanCanvas({ idea: 'Business-as-Code' })

Agent

The Agent function allows Agents to be defined in a strongly-typed way:

import { Agent } from 'agents.do' // Create a customer support agent const amy = Agent({ name: 'Amy', url: 'https://amy.do', role: 'Customer Support Agent', objective: 'Handles customer inquiries and resolves common issues', keyResults: ['ticketResponseTime', 'ticketResolutionTime', 'customerSatisfaction'], integrations: ['chat', 'slack', 'email', 'zendesk', 'shopify'], triggers: ['onTicketCreated', 'onMessageReceived'], searches: ['FAQs', 'Tickets', 'Orders', 'Products', 'Customers'], actions: ['sendMessage', 'updateOrder', 'refundOrder', 'resolveTicket', 'escalateTicket'], }) export const refundOrder = (orderId: number) => amy.do`refund order ${orderId} and send the customer confirmation`

do

The do function requests AI Agents and Human Users to take Action:

import { do } from 'agents.do' const research = await do`research about ${topic}`

browse

The browse function in agents.do and browse.do provide real-time web browsing:

import { browse } from 'agents.do' const findings = await browse`research about ${topic}`

research

The research function in agents.do and research.do provide deep-research in real-time:

import { research } from 'research.do' const findings = await research`research about ${topic}`

API

The API function allows an API to defined and deployed:

import { API } from 'apis.do' const api = API() api .get('/', () => ({ hello: 'world' })) .get('/:id', ({ id }) => ({ id })) .put('/:id', async ({ id, body, db }) => db.posts.set(id, body))

api

The api object provides access to not only all of the core .do APIs, but also tens of thousands of searches and actions from third-party integrations:

import { api } from 'apis.do' const customer = await api.users.get({ id: 'userId' }) const result = await api.stripe.createInvoice({ customer: customer.id, amount: customer.usageTotal, currency: 'usd', description: 'Pay-as-you-go usage', })

Business

The Business function allows Business goals to be defined through Objectives and Key Results:

import { Business } from 'businesses.do' const newCo = Business({ name: 'NewCo', url: 'https://new.co', goals: [ { objective: 'Grow revenue by 10% month over month', keyResults: ['revenue', 'growthRate'], }, ], })

plan

Analytics

track

Experiment

decide

Eval

score

Test

describe

it

expect

DB

The DB function allows a Database to be defined via Payload for either MongoDB, PostgreSQL, or SQLite:

import { DB } from 'database.do' const db = DB({ posts: { title: 'text', content: 'richtext', status: 'Draft | Published | Archived', // Select field with predefined options contentType: 'Text | Markdown | Code | Object | Schema', // Another select field example tags: 'tags[]', author: 'authors', }, tags: { name: 'text', posts: '<-posts.tags', // Join field to posts (reverse relation) }, authors: { name: 'text', email: 'email', role: 'Admin | Editor | Writer', // Select field with predefined options posts: '<-posts.author', // Join field to posts (reverse relation) }, })

db

The db object provides access to the database:

import { db } from 'database.do' const posts = await db.posts.find({ tag: 'ai' })

Event

on

every

Integration

trigger

act

Last updated on