iOS Chatbot SDK
dialogs_Chatbot_iOS embeds a fully functional EnableX Dialogs chatbot into any
native iOS application. The SDK renders its own complete chat UI on top of an internal
WKWebView — a WKScriptMessageHandler JS bridge (EnxBotJSBridgeManager)
connects the embedded bot engine to native Swift callbacks, so your app never touches the
WebView directly.
First release of the iOS Chatbot SDK. See Release Notes for what's included.
Download iOS Chatbot SDK v1.0.0Requirements
| Item | Requirement |
|---|---|
| iOS | 15.0 or later |
| Swift | 5.0 or later |
| Xcode | 15.0 or later |
| Network | Active internet connection required |
| Permissions | Camera, Photo Library (only if attachment features are used); Microphone (only if audio/video calls are used) |
Installation
Manual XCFramework
- Copy
dialogs_Chatbot_iOS.xcframeworkinto your Xcode project - In Xcode → Target → General → Frameworks, Libraries, and Embedded Content
- Add
dialogs_Chatbot_iOS.xcframework→ set to Embed & Sign
Swift Package Manager
// Package.swift
.binaryTarget(
name: "dialogs_Chatbot_iOS",
url: "https://your-release-url/dialogs_Chatbot_iOS.xcframework.zip",
checksum: "YOUR_CHECKSUM_HERE"
)
Project Setup
Info.plist Permissions
Add the following keys to your Info.plist if you enable media/file attachments or audio/video calls. The camera key is also needed for video calls:
<key>NSCameraUsageDescription</key>
<string>Required to take photos and videos for the chat bot</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Required to attach images and videos from your library</string>
<key>NSMicrophoneUsageDescription</key>
<string>Required for audio and video calls</string>
App Transport Security
The SDK connects to remote bot servers over HTTPS. Ensure ATS is not blocking your bot's host domain.
Step 1 — Import
import dialogs_Chatbot_iOS
Step 2 — Create Configuration
let config = EnxBotConfiguration(
botId: "YOUR_BOT_ID", // from EnableX/Dialogs dashboard
host: "https://dialogs.enablex.io",
path: "", // optional, leave empty if not needed
callingView: false // true = you place the call buttons via getCallingView()
)
Step 3 — Connect and Display
class ViewController: UIViewController {
var botView: EnxBotContainerView!
override func viewDidLoad() {
super.viewDidLoad()
botView = EnxChatClient.connect(
configuration: config,
eventListner: self
)
botView.attach(to: self.view)
}
}
Step 4 — Handle Delegate
extension ViewController: EnxChatClientDelegate {
func didBotConnected(_ botInfo: [String: Any]) {
print("Bot name:", botInfo["name"] ?? "")
}
}
Call Buttons & Click-to-Call
Two separate things control the calling UI. EnxBotConfiguration.callingView decides where the audio/video call buttons live. The full-screen click-to-call screen is switched on by the bot, not by any configuration flag.
Built-in call buttons (callingView: false, default)
- Displays the full chat interface (message list + input bar)
- The container shows its own audio/video call buttons
- Input bar includes attachment options: camera, photo, video, file
- Bot can send: text, images, videos, files, suggestions, action cards, date picker
- User can send: text messages + media attachments
Your own call buttons (callingView: true)
- The chat interface is the same, but the container hides its built-in call buttons
- Call
EnxChatClient.getCallingView()to get anEnxCallingView(an audio button and a video button) and place it in your own toolbar or navigation bar - Tapping a button routes the call into the active
EnxBotContainerView, exactly as the built-in buttons would
let config = EnxBotConfiguration(
botId: "YOUR_BOT_ID",
host: "https://dialogs.enablex.io",
callingView: true
)
let botView = EnxChatClient.connect(configuration: config, eventListner: self)
botView.attach(to: self.view)
// Place the call buttons in your navigation bar
let callingView = EnxChatClient.getCallingView()
navigationItem.rightBarButtonItem = UIBarButtonItem(customView: callingView)
Call getCallingView() only after connect(configuration:eventListner:). The returned view reflects that configuration's callingView flag.
Click-to-call screen (started by the bot)
- When the bot signals a click-to-call session, the input bar is replaced with a full-screen click-to-call interface (
EnxClickToCallingView). This happens with eithercallingViewsetting - Shows a large call button; tapping sends
"Hi"to start the bot flow - Bot responds with handover status updates displayed on screen
- When the bot triggers a call, a floating WebView appears with the video/audio session
Resetting the Bot
To clear the current conversation and restart:
botView.resetBot()
This sends a JavaScript command to the embedded WebView to call resetConversation() or equivalent on the bot engine.
Supported Message Types
| Type | Direction | Description |
|---|---|---|
text | Bot ↔ User | Plain text or markdown formatted text |
photo | Bot ↔ User | Image with optional caption and action buttons |
video | Bot ↔ User | Video attachment |
file | Bot ↔ User | Document/file attachment |
action / card | Bot → User | Card with action buttons (URL or call) |
single-choice | Bot → User | Single-select suggestion chips |
multi-choice | Bot → User | Multi-select suggestion chips |
calendar | Bot → User | Date picker modal |
system | Bot → User | System status message (handover events) |
typing | Bot → User | Animated typing indicator |
Supported Media Types
Sending (User → Bot)
| Type | Source | Format |
|---|---|---|
| Image | Photo Library | JPEG (compressed to 30% scale, 75% quality) |
| Image | Camera | JPEG (compressed) |
| Video | Photo Library | Original format (MP4, MOV, etc.) |
| File | Files App | PDF, images, text, data files |
Image compression: Images are automatically resized to 30% of original dimensions and compressed to 75% JPEG quality before sending. Maximum recommended: images under 10 MB original size.
Receiving (Bot → User)
| Type | Rendered As |
|---|---|
| Remote image URL | Inline image with tap-to-fullscreen |
| Remote video URL | Video player |
| Remote file URL | Downloadable file attachment |
Layered Architecture
Your app talks only to the public API. Below it, the SDK has a view layer that draws the whole chat and calling UI, and a WebView + bridge layer that runs the bot engine and talks to your bot server. Click any diagram on this page to open it at full size.
didBotConnected(_:) is delivered back to your app through EnxChatClientDelegate.| Layer | Responsibility |
|---|---|
| Public API | A single static entry point (EnxChatClient) plus the EnxBotConfiguration value object and the EnxChatClientDelegate callback. Your app never touches the view or WebView classes directly. |
| View layer | EnxBotContainerView and its children: the chat list, the input bar with attachments, the click-to-call screen and the floating call container. |
| WebView + bridge layer | EnxBotWebViewManager runs a WKWebView with the bot engine; EnxBotJSBridgeManager (a WKScriptMessageHandler) turns its JavaScript events into Swift callbacks. |
Calls run in a WebView. Audio and video calls open in a floating WebView (EnxVideoContainerView). For native EnableX video calls, use the iOS Chatbot UI Kit, which adds a native calling layer on the same chat engine.
Sequence Diagrams
Connecting & messaging
From EnxChatClient.connect() to the bot being ready, then one user message and the bot's reply.
EnxBotJSBridgeManager. Messages sent before the bot is ready are queued and sent once it is.Click-to-call & calls
From the bot signalling a click-to-call session to an active call in the floating call window.
audio_video_action event; see What happens if the bot does not support calling?Component Diagram
This diagram shows internal classes for orientation only. Your app can use only EnxChatClient, EnxBotConfiguration, EnxChatClientDelegate, EnxBotContainerView and EnxCallingView.
Component Descriptions
| Component | Role |
|---|---|
EnxChatClient | Public static API. Entry point for all SDK usage |
EnxBotConfiguration | Value object holding bot connection settings |
EnxBotContainerView | Root UIView. Orchestrates all child views and the web engine |
EnxBotWebViewManager | Manages WKWebView lifecycle, JS initialisation, message sending/receiving |
EnxBotJSBridgeManager | WKScriptMessageHandler bridge between JS and Swift |
EnxChatListView | UITableView displaying all chat messages grouped by date |
EnxChatInputView | Bottom input bar with text field, send button, and attachment panel |
EnxChatMessageCell | UITableViewCell rendering text, media, suggestion chips, actions |
EnxClickToCallingView | Full-screen click-to-call UI, shown when the bot signals a click-to-call session |
EnxCallingView | UIStackView with audio + video call buttons for nav bar |
EnxVideoContainerView | Floating draggable WebView container for video/audio calls with PiP |
EnxImagePreviewController | Full-screen image preview presented when user taps a received image |
EnxTypingIndicatorView | Animated three-dot typing indicator |
EnxDatePickerView | Modal date picker presented for calendar-type bot messages |
EnxBotResponseParser | Parses raw JSON payloads from the bot into EnxChatMessage models |
EnxMarkdownParser | Converts markdown text from the bot into NSAttributedString |
EnxChatSetting | Singleton storing session state (sessionId, conversationId, botInfo) |
Feature Support (v1.0.0)
| Feature | Supported | Notes |
|---|---|---|
| Full chat UI | Yes | Message list grouped by date with date section headers, input bar, animated typing indicator. |
| Markdown rendering | Yes | Bold, italic, links in bot messages via EnxMarkdownParser. |
| Text messages | Yes | Plain text, user ↔ bot. |
| Suggestion chips (single/multi-choice) | Yes | |
| Image / video / file attachments | Yes | Send from photo library, camera, or Files app; receive from bot with tap-to-fullscreen. |
| Action cards | Yes | Buttons with URL or call actions. |
| Calendar (date picker) prompts | Yes | |
| System / handover status messages | Yes | initiated, assigned, unassigned, noAgent, resolved, expired, disconnected. |
| Click-to-call (audio / video) | Yes | Full-screen click-to-call UI plus a floating, draggable PiP WebView for active calls. |
| Conversation reset | Yes | EnxBotContainerView.resetBot(). |
| Message queueing before ready | Yes | Messages sent before the bot is ready are buffered and flushed automatically. |
| Objective-C interop | Yes | EnxChatClient, EnxBotConfiguration, EnxBotContainerView, and EnxCallingView are @objcMembers. |
| Multi-bot support | No | EnxChatClient uses static properties — only one bot connection per app session. |
| UI customization API | No | Not available in v1.0 — the SDK renders its own complete UI. |
Error Handling
The SDK handles most errors internally. The host app does not need error handling for normal flows.
| Scenario | SDK Behaviour |
|---|---|
| No internet on start | WebView fails to load; bot stays in idle state |
| Message sent before ready | Message is queued and sent automatically once ready |
| Camera not available on device | Silent no-op (camera option still shown; permission denied by OS) |
| Directory selected in file picker | Alert shown: “Unsupported File” |
| JS evaluation error | Logged to console; message not sent |
| Bot JS reset function not found | Tries multiple function names (resetConversation, clearConversation, reset) |
FAQ
Can I add the bot view without using attach(to:)?
Yes. attach(to:) is a convenience helper. You can add EnxBotContainerView to your view hierarchy manually and set constraints yourself.
Can I use the SDK with multiple bots simultaneously?
Not in the current version. EnxChatClient uses static properties — only one bot connection is supported per app session.
Does the SDK support Objective-C?
Yes. EnxChatClient, EnxBotConfiguration, EnxBotContainerView, and EnxCallingView are annotated with @objcMembers and public visibility, making them accessible from Objective-C.
How large can attachments be?
The SDK compresses images to ~30% of original size before sending. Videos and files are sent at original size. There is no hard limit enforced by the SDK — limits are applied server-side.
What happens if the bot does not support calling?
The click-to-call screen never appears, because it is shown only when the bot signals a click-to-call session. Any call buttons (built-in, or from getCallingView()) stay visible but have no effect, since no audio_video_action events will be received from the bot.
Can I run the SDK in the iOS Simulator?
Yes. The XCFramework ships an ios-arm64 slice for devices and an ios-arm64_x86_64-simulator slice. Camera capture still needs a real device.
Are calls native EnableX video sessions?
No. In the SDK, calls run in a floating WebView (EnxVideoContainerView). If you need native EnableX video calls, use the iOS Chatbot UI Kit. See Layered Architecture.
How do I customise the UI?
UI customisation is not available in the public API in v1.0. The SDK renders its own complete UI.