Quick start
Table of contents
Use this Quick Start guide to get you up and running with a working AI or live chat hosted by your App.
System Requirements
platform :ios, '10.0'
Note: M1 Mac is supported from v3.10.0.
- Automatic Reference Counting (ARC) is required in your project.
- With the release of iOS 9 and Xcode 7, a new feature called App Transport Security (ATS) was introduced.
- CocoaPods.
Set up the SDK on your App.
Note: Using CocoaPods on an existing Xcode project will modify the project file, so you may want to make a backup before doing this.
- Create a Podfile in the root directory of your project.
$ pod init
- Add Official CocoaPods PodSpecs repository to your Podfile:
source 'https://github.com/CocoaPods/Specs.git'
- Add bold360ai PodSpecs repository to your Podfile:
source 'https://github.com/genesys/Bold360ai-SDK-Specs'
- Add bold360ai iOS SDK to your Podfile:
pod 'Bold360AI'
- Using terminal, with your project root directory as the working path, run:
pod install
# pod update (use this when you want to get new released version).
This will download all the necessary files which are required to integrate the bold360ai into your project.
! Now you are ready to integrate and create some chats.
Create and start a chat
Follow the next steps to create and start a chat.
Create new Project
Set Up a Project in Xcode
-
Open Xcode and click start new Xcode Project:
-
Next, select Single View Application and click Next:
-
In the dialog screen displayed, enter the relevant details:
Import SDK
Go to the desired file (e.g., ViewController.swift
) and add the line below:
import Bold360AI
Setup Chat Controller
var chatController: ChatController!
var chatControllerDelegate: ChatControllerDelegate!
var chatHandlerProvider: ChatHandlerProvider!
var chatViewController: UIViewController!
Setup Live Chat
// setup Live Chat
extension ViewController {
@IBAction func setupBoldChat(_ sender: Any) {
// 1. create account & set
let account = LiveAccount()
account.apiKey = {API_KEY}
self.chatController = ChatController(account: account)
// 2. set controller delegate
self.chatController.delegate = self
}
}
Make sure to read chat lifecycle doc and register to relevant states (e.g
unavailable
state).
Setup Bot Chat
// Setup Bot Chat
extension ViewController {
@IBAction func setupBotChat(_ sender: Any) {
// 1. create account & set
let account = self.createAccount()
self.chatController = ChatController(account: account)
// 2. set controller delegate
self.chatController.delegate = self
}
func createAccount() -> BotAccount {
let account = BotAccount()
account.account = "ACCOUNT"
account.knowledgeBase = "KNOWLEDGE_BASE"
account.apiKey = "API_KEY"
return account;
}
}
Use Context
Context is a key-value parameter, so when you create the BotAccount
object you can set NSDictionary which contains the related context.
// Using the context:
botAccount.context = ["someKey": "someValue"]
Configure Welcome Message Id
When you create the BotAccount
object you can set welcome message id.
botAccount.welcomeMessageId = "{WELCOME_MESSAGE_ID}"
To Disable Welcome Message
botAccount.welcomeMessageId = WelcomeMsgIdNone
Create Initialization Entities
Entities is a feature of Bold360 that enables querying data from external sources in a conversational format. If a piece of info is missing from a bot query - the bot asks for the missing data to be able to answer. The application can populate the entity input values that are available - not to let the bot ask for input params that are “obviously available.”
// Creating Initialization Entities:
botAccount.initializationEntities = ["someKey1": "someValue1", "someKey1": "someValue2"]
Add Chat View Controller by Implementing Delegate Methods
extension ViewController: ChatControllerDelegate {
func didFailLoadChatWithError(_ error: Error!) {
print(error.localizedDescription)
}
func shouldPresentChatViewController(_ viewController: UINavigationController!) {
// 4. present modally/ as child view controller over your view controller.
<YOUR_VIEW_CONTROLLER>.present(viewController, animated: false, completion: nil)
}
}