iOS SDK
Updated
The ChatFrom iOS SDK puts your chatbot inside your own iPhone and iPad app: a chat bubble in a corner, or a row in a list. Tapping it opens the chat, full screen on iPhone and as a card on iPad, with the same knowledge, tools and workflows as on your website, and every conversation in the same log.
How it works
The bubble and the chat's header are drawn by the app itself, in the colour, icon, size and corner you chose under Deploy. The chat inside them is ChatFrom's own chat page, so what improves there reaches your app without a new release. People can attach files, follow links, which open outside your app, and carry on where they left off.
The chat needs iOS 16.4 or later. The package can go into an app that still supports iOS 15, where it shows no bubble and its rows are grey, and ChatFrom.isSupported says which a device is.
Before you start
- In ChatFrom, open your chatbot, go to Deploy and turn on Mobile apps. Then go live. A chatbot that is not live, or not open to apps, shows no bubble.
- Copy the chatbot's id from its address in the dashboard: the part after
/dashboard/.
Anyone who has a chatbot's id can chat with it from an app, as with its share link, so it should only answer from what you would show the public.
Add the package
In Xcode, choose File > Add Package Dependencies, enter https://github.com/rouzbeh-abadi/chatfrom-ios, set the rule to Up to Next Minor Version, since before 1.0 a minor version may change the API, and add the ChatFromSDK library to your app. Or in Package.swift:
Show the bubble
One line, as your app starts, in application(_:didFinishLaunchingWithOptions:) or in a SwiftUI App's init():
- The bubble sits above a tab bar by itself, and steps aside while the keyboard is over it. Screens your app presents cover it.
- For a bar of your own that comes and goes, such as a player or a timer,
ChatFrom.setBottomInset(_:)moves the bubble out of its way. ChatFrom.setBubbleHidden(true)hides it on a screen where it would be in the way, such as your own lock screen or a first-run screen, andChatFrom.stop()takes it away.- A chatbot that shows the input bar on your website still shows a bubble in an app, as the bubble settings under Deploy set it.
Or add a row
In SwiftUI, in a List or a Form:
In UIKit, ChatFromCell is the same row for a table view, and ChatFromButton for anywhere else. To open the chat from something of your own, such as a menu item, call ChatFrom.open(botId:). A row is grey while the chatbot is not live.
Signed-in people
If people sign in to your app, say who is using it, so the next person on a shared device does not see the last person's chat:
userIdis your app's id for the person. Only a fingerprint of it is used, and it stays on the device.userTokenis optional, for a chatbot whose tools act for the signed-in user, as on your website. Get it from your own server and never sign it in the app. It goes only to the tool servers you marked to receive it.
What your app has to do
- Consent. The answers come from an AI model through ChatFrom, so Apple's App Review rule on sharing personal data with a third party's AI (guideline 5.1.2(i)) is yours to meet: say so in your app, and get consent before someone first uses the chat. The bubble and rows load the chat page and open it on a tap, so call
ChatFrom.start, or show a row, only once you have that consent. To ask on the tap itself, use a button of your own that asks first, then callsChatFrom.open(botId:). - Privacy. Your privacy notice has to cover what people write to the chatbot, and what its tools ask for, such as a name, an email address or a phone number to book a call. The SDK's privacy manifest declares these. What the chat keeps on the device follows Remember returning visitors under Deploy: across launches when it is on, and for the app's run when it is off.
- The camera. The file picker can offer to take a photo, so add
NSCameraUsageDescriptionto yourInfo.plist. - App-Bound Domains. If your
Info.plistlistsWKAppBoundDomains, addchatfrom.ioto it, or the chat cannot load.
Answers in an app use your monthly credits, as they do on your website.
The SDK's README has every call and option. To put the same chatbot on your website, see Getting started.