sarufi library
A modern, null-safe Dart & Flutter SDK for the Sarufi Conversational AI platform.
Authenticate with an API key, then build, train and chat with bots:
import 'package:sarufi/sarufi.dart';
void main() async {
final sarufi = Sarufi('YOUR_API_KEY');
final bot = await sarufi.getBot(42);
final reply = await bot.respond(message: 'Habari');
print(reply.messages);
sarufi.close();
}
To create or update bots from JSON/YAML files, import
package:sarufi/sarufi_io.dart (requires dart:io, not available on the
web).
Classes
- Bot
- A chatbot returned by the Sarufi API.
- ChatResponse
-
The reply returned by the bot after a
chat/respondcall. - ChatState
- The position of a conversation within a bot's flow state machine.
- EndpointDoc
- Full, human-readable documentation for a single API operation.
- FieldDoc
- One field in a request body, or one query/path parameter.
- IntentPrediction
- The result of asking a bot to classify a message into one of its intents.
- Sarufi
- Entry point to the Sarufi Conversational AI platform.
- SarufiDocs
- Inline documentation for every Sarufi operation.
Enums
- Channel
- The channel a conversation is happening on.
- MessageType
- The kind of content carried by a chat message.
Exceptions / Errors
- SarufiApiException
- A generic API error that does not map to a more specific subtype.
- SarufiAuthException
- Authentication or authorization failed (HTTP 401 / 403) - usually a missing or invalid API key.
- SarufiException
- Base type for every error raised by the SDK.
- SarufiNetworkException
- The request never completed - a timeout, DNS failure, dropped connection or other transport-level problem. Has no statusCode.
- SarufiNotFoundException
- The requested resource does not exist (HTTP 404).
- SarufiServerException
- Sarufi returned a server-side error (HTTP 5xx).
- SarufiValidationException
- The request was rejected because it was malformed or failed validation (HTTP 400 / 422).