Search for "botpress flutter" and you find a gap. Botpress documents one mobile path, and it is for React Native: run the browser Webchat inside a WebView and talk to it with postMessage and injectJavaScript. Its docs say the @botpress/webchat package targets web React, and no page lists a Botpress mobile app SDK for Flutter, iOS or Android. The Flutter question on the Botpress Discord has no guide to point to.
So a Botpress Flutter integration means porting that WebView pattern yourself. This post does the port with working code, lists what the WebView costs on a phone, then sets it beside a native Flutter AI chatbot package, widget_chat.
How the bridge works
The Webchat is a browser client exposed as window.botpress. Flutter cannot call it directly, so messages cross a JavaScript channel in both directions.
Botpress Webchat in webview_flutter: the port
You need a published bot and the two script URLs from the Webchat settings in Botpress Studio: the inject.js loader (the React Native guide pins v3.6) and your generated embed script on files.bpcontent.cloud, which calls window.botpress.init with your botId and clientId.
- Add the packageRun flutter pub add webview_flutter (4.x, the WebViewController API).
- Build the HTML shellLoad inject.js, then your embed script, and hide the floating button so the chat fills the page.
- Register the channeladdJavaScriptChannel gives the page a BotpressBridge object to post events to.
- Relay eventsSubscribe with window.botpress.on and forward each event as JSON.
- Talk backCall window.botpress methods from Dart with runJavaScript once webchat:ready has fired.
The HTML shell
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';
const _injectUrl = 'https://cdn.botpress.cloud/webchat/v3.6/inject.js';
// Copy this URL from the Webchat settings in Botpress Studio.
const _embedUrl = 'https://files.bpcontent.cloud/YOUR_EMBED_SCRIPT.js';
const _html = '''
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<style>
html, body { margin: 0; height: 100%; }
.bpFab { display: none !important; }
.bpWebchat {
position: absolute !important; top: 0; left: 0;
width: 100% !important; height: 100% !important; max-height: 100% !important;
}
</style>
</head>
<body>
<script src="$_injectUrl"></script>
<script src="$_embedUrl" defer></script>
<script>
function post(event, data) {
BotpressBridge.postMessage(JSON.stringify({ event: event, data: data }));
}
var tries = 0;
var timer = setInterval(function () {
if (window.botpress && window.botpress.on) {
clearInterval(timer);
window.botpress.on('webchat:initialized', function () { window.botpress.open(); });
['webchat:ready', 'webchat:opened', 'webchat:closed', 'message', 'customEvent', 'error']
.forEach(function (name) {
window.botpress.on(name, function (data) { post(name, data); });
});
setTimeout(function () { window.botpress.open(); }, 400);
} else if (++tries > 240) {
clearInterval(timer);
post('error', 'webchat did not load');
}
}, 50);
</script>
</body>
</html>
''';
The polling loop, the 50 ms interval, the 12 second ceiling and the fallback open() all come from the Botpress React Native guide. The only change is the bridge call: window.ReactNativeWebView.postMessage becomes BotpressBridge.postMessage. The two CSS rules follow the "embed in a div" section of the Botpress embedding docs. Check them against the current page, because class names can change between Webchat versions.
The Flutter side
class BotpressChatPage extends StatefulWidget {
const BotpressChatPage({super.key});
@override
State<BotpressChatPage> createState() => _BotpressChatPageState();
}
class _BotpressChatPageState extends State<BotpressChatPage> {
late final WebViewController _controller;
bool _ready = false;
@override
void initState() {
super.initState();
_controller = WebViewController(
// Grants camera and mic to the page. Narrow this in production.
onPermissionRequest: (request) => request.grant(),
)
..setJavaScriptMode(JavaScriptMode.unrestricted)
..addJavaScriptChannel('BotpressBridge', onMessageReceived: _onMessage)
..setNavigationDelegate(NavigationDelegate(
onNavigationRequest: (request) {
if (!request.isMainFrame) return NavigationDecision.navigate;
final host = Uri.parse(request.url).host;
// Keep the shell, block links that would replace the chat.
return host.isEmpty || host == 'cdn.botpress.cloud'
? NavigationDecision.navigate
: NavigationDecision.prevent;
},
))
..loadHtmlString(_html, baseUrl: 'https://cdn.botpress.cloud/');
}
void _onMessage(JavaScriptMessage message) {
final payload = jsonDecode(message.message) as Map<String, dynamic>;
if (payload['event'] == 'webchat:ready') {
setState(() => _ready = true);
_controller.runJavaScript(
'window.botpress.updateUser({ data: { plan: "pro" } })',
);
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Support')),
body: SafeArea(
child: Stack(children: [
WebViewWidget(controller: _controller),
if (!_ready) const Center(child: CircularProgressIndicator()),
]),
),
);
}
}
SafeArea keeps the composer clear of the home indicator and the notch. Leave resizeToAvoidBottomInset at its default of true so the WebView shrinks when the keyboard opens. webchat:ready is the event Botpress documents as "ready to receive messages", so it is the right moment to call updateUser, sendMessage or sendEvent.
What the WebView costs on mobile
The code above works. These are the parts you keep maintaining after it does.
| Cost | What happens | What you do about it |
|---|---|---|
| Second page load | The shell, inject.js and the embed script download every time the screen opens | Show a spinner until webchat:ready, handle the timeout |
| No native theme | The chat is HTML styled in Botpress, it does not read your ThemeData or follow system dark mode by itself |
Set themeMode through window.botpress.config and keep colours in sync by hand |
| Keyboard | The composer can sit under the keyboard on Android. Botpress's own guide has a troubleshooting row for it | Test both platforms, keep the Scaffold resizing |
| Back button | Android back pops the route, or navigates inside the page, depending on history | Wrap in PopScope and decide per case |
| Links | A tapped link replaces the chat inside the WebView | Block it in NavigationDelegate and open it with url_launcher |
| Camera and mic | The page asks the WebView, the WebView asks you, and the OS still needs its own permission | onPermissionRequest, manifest and Info.plist entries, a runtime permission request, and a file chooser handler on Android through webview_flutter_android |
| Offline | No network means a blank page | Catch onWebResourceError and draw your own error state |
Botpress WebView vs a native ChatWidget
The Botpress alternative for Flutter in this post is Widget-Chat: a chat screen built from Flutter widgets, configured in a dashboard, added with one package.
Botpress Webchat in webview_flutter
- HTML shell, JavaScript channel and event relay to write and maintain
- Web page rendered inside the app
- Second page load before the chat appears
- Camera and mic go through WebView permission plumbing
Native ChatWidget from widget_chat
- One widget and a project key
- Flutter widgets, with light, dark and system themes
- No page to load, the screen is part of the app
- Image attachments and a mic button built in
| Criterion | Botpress Webchat in a WebView | Widget-Chat ChatWidget |
|---|---|---|
| Integration effort | The shell and bridge above, plus the table of costs | flutter pub add widget_chat, one widget |
| Native rendering | No, it is a web page | Yes, Flutter widgets on iOS, Android, web and desktop |
| Rich messages | Rendered by the Webchat as HTML | Markdown, image cards, carousels, product lists, button groups, colour swatch pickers, tap-to-zoom images |
| Identity | updateUser with name, picture, data and a userKey, called over the bridge |
userID in the configuration, with HMAC-signed user identity |
| Voice | Whatever the web page does, behind WebView mic permissions | Live voice call in the same widget (package 0.0.23 and later): speech-to-speech, barge-in, live captions |
| Offline behaviour | Blank page unless you handle the error | Neither answers without a network. The screen itself is native, so there is no page that fails to load |
| Bot building | Visual flow builder in Botpress Studio | No-code dashboard: content, theme, languages, custom HTTP tools |
| Channels | Web, WhatsApp, Messenger, Telegram, Slack and more from one bot | In-app and web: Flutter, FlutterFlow, native iOS and Android SDKs, web embed |
When Botpress is the better choice
Stay with Botpress, and accept the WebView, in two cases.
Your team needs the visual flow builder. If the conversation is a designed flow with branches, cards and handoffs that non-developers edit in Studio, that is Botpress's core strength and Widget-Chat does not replace it.
You deploy one bot to many channels. Botpress connects the same bot to WhatsApp, Messenger, Telegram, Slack and the web through its integrations. If the mobile app is one channel among five, the WebView is a fair price for keeping a single bot. Widget-Chat is built for chat inside your own app and site, not for messaging platforms.
If the app is the main surface and you want the chat to feel like the rest of it, the native widget is less work on day one and far less work after.
- Chatbase alternative for Flutter: WebView vs native widget
- Tawk.to alternative for Flutter: WebView vs native AI chat
- Widget-Chat vs Intercom for Flutter apps
The native option: ChatWidget from widget_chat
Widget-Chat ships the finished chat screen. The assistant answers from your own content, the model provider key stays server-side, and there is no chat backend to build or host.
flutter pub add widget_chat
ChatWidget(
configuration: BotConfiguration(
projectSecretKey: 'your-project-secret-key',
userID: 'user-123',
),
)
That is the whole integration: no HTML shell, no JavaScript channel, no permission relay. You get chat history with pagination, image attachments from camera or gallery, a UI in 46 locales with replies in 100+ languages, and action callbacks into your app. For voice, declare the mic permission (NSMicrophoneUsageDescription on iOS, RECORD_AUDIO on Android) and enable it in the dashboard. In FlutterFlow, add the package as a custom dependency and use it in a custom widget, as shown in the FlutterFlow guide.
- Botpress has no Flutter SDK, its documented mobile path is a WebView
- The React Native pattern ports to webview_flutter with a JavaScriptChannel
- The WebView brings a page load, theme, keyboard, back button and permission work
- Botpress wins on visual flows and multi-channel deployment
- A native ChatWidget wins when the app is the main surface
The free plan needs no credit card. Create a Widget-Chat project, copy the project key, and the chat is in your app in a few minutes.





