Built-in Utility Functions
Based provides built-in utility functions that are available in all deployments for common operations like debugging, notifications, and more.Print Line Debugging
Theprint function works like Python’s standard print, but outputs are captured and made available in the session trace for debugging purposes. This is invaluable for understanding flow execution and troubleshooting issues.
Syntax:
All print outputs appear in the session trace view, making it easy to debug conversation flows without interrupting the user experience. Print statements do not send messages to the user—they’re purely for developer debugging.
Sending SMS Messages with send_sms
The send_sms function allows you to send SMS messages programmatically from within your Based flow. This is useful for sending confirmations, notifications, or follow-up messages.
Syntax:
to(string, required): The recipient’s phone number in E.164 format (e.g.,"+12025551234")content(string, required): The SMS message content to sendfrom_number(string, required): Your phone number from your Brainbase phone number library
SMSResult object with the following properties:
Example:
send_sms function is designed to never interrupt your flow. All errors are captured in the result object, allowing you to handle failures gracefully:
The
from_number must be a phone number registered in your Brainbase phone number library with proper A2P (Application-to-Person) verification for SMS delivery compliance.Making HTTP Requests
Based provides the standard Pythonrequests module for making HTTP requests to external APIs. This gives you full compatibility with the widely-used requests library.
Examples:
.ask() with API Responses:
You can use the .ask() method on response data to extract structured information:
All HTTP requests are automatically logged in the session trace for debugging and observability. You can see request/response details, timing, and any errors in the trace view.
Legacy API Utility (Deprecated)
The legacyapi.get_req() and api.post_req() methods are still supported for backwards compatibility:
Third-Party Integrations
Based provides anintegrations client for connecting to third-party services configured in your Brainbase workspace.
Usage:
Integrations must be connected in your Brainbase workspace before they can be used in Based flows. See the Integrations documentation for setup instructions.
