Skip to main content

Based Crash Course

Welcome to the Based Crash Course! This guide introduces you to Based, a powerful, domain-specific programming language designed to build platform agnostic conversational agents. Deploy conversational workflows on chat, voice, email, SMS, and more with ease, enabling seamless data exchange and a unified user experience across platforms.

What Is Based?

Based is a high-level AI instruction language crafted to design dynamic conversational agents that operate flawlessly across multiple communication channels. It provides developers with an elegant, high-level syntax to build interactive workflows quickly and reliably. Key features of Based include:
  • Intuitive and Expressive Syntax: Develop complex conversational logic with clarity and brevity.
  • Specialized Constructs: Utilize built-in keywords like talk, loop, until, and ask to manage conversation flow and state effortlessly.
  • Cross-Platform Flexibility: Create agents deployable on chat, voice, email, SMS, and more—all while sharing data seamlessly across channels.

Core Conversation Flow Constructs

Based scripts use a trio of keywords to build interactive conversations:
  1. talk: Sends a message or prompt to the user and waits for a response (or specify False as the second argument to wait for the user to send a message first).
  2. loop: Begins a conversational block that allows for repeated prompting.
  3. until: Specifies the condition under which the loop should end.
In practice, the talk keyword is not used in isolation. It is usually enclosed in a loop/until structure. This pattern keeps the conversation repeating until valid input is obtained. Example Usage:

Core Language Constructs

The ask Method

The ask method is used to extract structured data from a response. By providing an example object, you can ensure that the output is formatted predictably for further processing. Example:

Tool Schema Until Conditions

Beyond string conditions, Based supports tool schema until conditions that extract structured parameters when a condition matches:
For full details, see Tool Schema Until Conditions.

State Persistence

Variables persist across conversation turns using the state dictionary:

Built-in Utilities

Use print() for debugging—outputs appear in the session trace:

Sending SMS

Send SMS messages programmatically with send_sms:

HTTP Requests

Use the standard requests module for API calls:

Full Example: An Interactive Workflow

Below is a complete example that combines talk, loop, until, and ask to build a seamless interactive conversation:

Voice Deployment Functions

When deploying Based agents for voice conversations, you have access to special functions for call control:

transfer(phone_number, options?)

Transfers the current call to another phone number, with optional extension dialing support.

end_call()

Ends the current call gracefully.
For more details on voice functions and their parameters, see the Language Fundamentals guide.

Additional Notes

  • Based’s design abstracts away complexity while providing powerful control over conversational flows.
  • The constructs loop, talk, until, and ask empower you to design robust, interactive workflows.
  • Tool schema until conditions enable structured parameter extraction directly from user intents.
  • State persistence automatically maintains variables across conversation turns.
  • Print line debugging helps troubleshoot flows via session traces.
  • HTTP requests use the standard requests module for full API compatibility.
  • SMS sending is available via send_sms() for notifications and confirmations.
  • For voice deployments, use transfer() and end_call() to control call flow.
For comprehensive documentation on all constructs, see the Language Fundamentals guide.

Conclusion

Armed with these constructs, you can build dynamic, platform-agnostic conversational agents using Based. This guide has provided enhanced examples that showcase how to structure interactive conversations effectively. Happy coding!