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) |
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:
<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 = click-to-call UI
)
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"] ?? "")
}
}
Chat Mode vs Click-to-Call Mode
The SDK supports two distinct UI modes controlled by EnxBotConfiguration.callingView.
Chat Mode (callingView: false)
- Displays the full chat interface (message list + input bar)
- 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
Click-to-Call Mode (callingView: true)
- Displays a full-screen click-to-call interface
- Shows a large call button; tapping sends
"Hi"to start the bot flow - Bot responds with handover status updates displayed on screen
- When bot triggers a call, a floating WebView appears with the video/audio session
- Use
EnxChatClient.getCallingView()to get audio/video call buttons for the navigation bar
// Click-to-Call setup
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)
// Add call buttons to nav bar
let callingView = EnxChatClient.getCallingView()
navigationItem.rightBarButtonItem = UIBarButtonItem(customView: callingView)
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 |
Architecture Overview
┌─────────────────────────────────────────────────────┐
│ Host Application │
│ │
│ ViewController ──────────────────────────────┐ │
│ │ │ │
│ │ EnxChatClient.connect(...) │ │
│ ▼ │ │
├─────────────────────────────────────────────────┤ │
│ EnxChatClient (Static API) │ │
│ │ │ │
│ ▼ ▼ │
│ EnxBotContainerView EnxChatClientDelegate │
│ ├── EnxChatListView ▲ │
│ ├── EnxChatInputView │ │
│ ├── EnxClickToCallingView didBotConnected(...) │
│ ├── EnxVideoContainerView │ │
│ └── EnxBotWebViewManager ─────────┘ │
│ ├── WKWebView │
│ └── EnxBotJSBridgeManager │
│ └── WKScriptMessageHandler │
└─────────────────────────────────────────────────────┘
Data Flow
User types → EnxChatInputView → EnxBotWebViewManager.sendMessage()
│
▼
WKWebView (JS)
sendMessageToBot()
│
Bot Server
│
▼
WKScriptMessageHandler
EnxBotJSBridgeManager
│
▼
EnxBotWebViewManager
onBotMessage callback
│
▼
EnxBotResponseParser
│
▼
EnxChatListView
(renders message)
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 (used when callingView = true) |
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 callingView is set to true but the bot does not support calling?
The click-to-call UI is displayed, but calling buttons will be inert since no audio_video_action events will be received from the bot.
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.