
With QuickBlox it’s easy to add iOS app features with AI. Whether you’re developing a chat app from scratch or choose to use our convenient iOS UI Kit, you can now utilize the QuickBlox iOS AI library to seamlessly integrate with OpenAI GPT to add exciting functionality.
We now offer AI Answer Assist. This feature allows app users to offer swift and accurate responses to user queries, by utilizing an OpenAI GPT model to analyze the context and provide relevant and concise answers in real-time. AI Answer Assist leads the way for iOS app user experience enhancement.
In the following tutorial we outline two approaches to implementing iOS in-app AI assistance:
I. Install our iOS AI library – QBAIAnswerAssistant – within your existing iOS project
II. Utilize our iOS UI Kit which already includes AI Answer Assist
QBAIAnswerAssistant can be installed using Swift Package Manager. To include it in your Xcode project, follow these steps:
To use QBAIAnswerAssistant in your project, follow these steps:
1. Import the QBAIAnswerAssistant module:
import QBAIAnswerAssistant
2. Create an array of Message objects representing the chat history:
let message1 = OwnerMessage("Hi there, how can I help you today?") let message2 = OpponentMessage("I need help with the iOS UI Kit. How do I set it up? ") let messages = [message1, message2]
3. Call the openAIAnswer method to generate an answer using an API key:
do { let apiKey = "YOUR_OPENAI_API_KEY" let answer = try await QBAIAnswerAssistant.openAIAnswer(to: messages, secret: apiKey) print("Generated Answer: \(answer)") } catch { print("Error: \(error)") }
Alternatively, you can use a QuickBlox user token and a proxy URL for more secure communication:
do { let qbToken = "YOUR_QUICKBLOX_USER_TOKEN" let proxyURL = "https://your-proxy-server-url" let answer = try await QBAIAnswerAssistant.openAIAnswer(to: messages, qbToken: qbToken, proxy: proxyURL) print("Generated Answer: \(answer)") } catch { print("Error: \(error)") }
To use the OpenAI API and generate answers, you need to obtain an API key from OpenAI. Follow these steps to get your API key:
Using a proxy server like the QuickBlox AI Assistant Proxy Server offers significant benefits in terms of security and functionality:
Enhanced Security:
Protection of API Keys:
Rate Limiting and Throttling:
Request Logging and Monitoring:
Flexibility and Customization:
SSL/TLS Encryption:
We have already integrated the AI Answer Assist feature within our iOS UI Kit. This feature allows you to generate answers in a chat, based on the chat history using the QBAIAnswerAssistant Swift package. This feature leverages the OpenAI API key or proxy server to generate responses more securely and efficiently.
To use the AI Assist Answer feature in your QuickBlox UI Kit project, follow these steps:
1. Enable the AI Assist Answer feature:
QuickBloxUIKit.feature.ai.assistAnswer.enable = true
If enabled, a button will appear next to each incoming message in the chat interface.
When the button is clicked, the Assist Answer feature will be launched, and a response will be generated, based on the chat history.
2. Set up the AI settings by providing either the OpenAI API key:
QuickBloxUIKit.feature.ai.assistAnswer.openAIAPIKey = "YOUR_OPENAI_API_KEY"
Or set up with a proxy server:
QuickBloxUIKit.feature.ai.assistAnswer.proxyServerURLPath = "https://your-proxy-server-url"
We recommend using a proxy server like the QuickBlox AI Assistant Proxy Server.
Implementing the “AI Answer Assist” feature into your iOS chat app has never been easier. By following the straightforward steps outlined above you can seamlessly unlock the power of AI-driven interactions and provide your users with instantaneous, relevant, and context-aware responses.
QuickBlox’s commitment to crafting user-friendly tools and easy-to-implement software ensures that businesses across industries can harness the potential of AI without the complexity typically associated with such integrations.
QBAIPROXY Server – GitHub – QuickBlox/qb-ai-assistant-proxy-server
QBAIAnswerAssistant – GitHub – QuickBlox/ios-ai-answer-assistant
Documentation – AI Features | iOS UIKit | QuickBlox