├── LICENSE ├── ZiaSDK.podspec └── README.md /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /ZiaSDK.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | 3 | s.name = "ZiaSDK" 4 | s.version = "0.2.0" 5 | s.summary = "Zia voice and chat SDK." 6 | s.license = { :type => "MIT", :text => <<-LICENSE 7 | MIT License 8 | 9 | Copyright (c) 2018 Zoho Corporation 10 | 11 | Permission is hereby granted, free of charge, to any person obtaining a copy 12 | of this software and associated documentation files (the "Software"), to deal 13 | in the Software without restriction, including without limitation the rights 14 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | copies of the Software, and to permit persons to whom the Software is 16 | furnished to do so, subject to the following conditions: 17 | 18 | The above copyright notice and this permission notice shall be included in all 19 | copies or substantial portions of the Software. 20 | 21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 27 | SOFTWARE 28 | LICENSE 29 | } 30 | 31 | s.homepage = "http://zoho.com" 32 | s.author = { "Magesh Dharmalingam" => "magesh.d@zohocorp.com" } 33 | s.source = { :http => "https://github.com/zoho/ZiaSDK/releases/download/0.2.0/ZiaSDK.framework.zip"} 34 | 35 | s.platform = :ios 36 | s.ios.deployment_target = '9.0' 37 | s.ios.vendored_frameworks = 'ZiaSDK.framework' 38 | end 39 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | ## ZiaSDK 3 | 4 | Zia is an AI-driven platform written in swift for iOS, which uses NLP to solve business case problems. Zia SDK provides access to Zia platform with sleek and lightweight APIs. With Zia SDK integrated to your application, you can make your users converse with Zia, either Chat or Call. Zia can help them with available skills. 5 | 6 | ## Requirements 7 | 8 | 1. Xcode 8.3+ 9 | 2. Swift 4.0+ 10 | 3. iOS 10+ 11 | 12 | ## Installation 13 | 14 | ### CocoaPods 15 | 16 | ``` 17 | To integrate ZiaSDK into your Xcode project using CocoaPods, specify it in your Podfile: 18 | 19 | platform :ios, ’10.0' 20 | use_frameworks! 21 | 22 | target '' do 23 | pod 'ZiaSDK', '~> 0.0.9’ 24 | end 25 | 26 | Then, run the following command: 27 | 28 | $ pod install 29 | ``` 30 | ### Manually 31 | 32 | If you prefer not to use any dependency managers, you can integrate Zia SDK into your project manually. 33 | Just add the ZiaSDK.framework into your Embedded Binaries. 34 | 35 | #### SDK Usage : 36 | 37 | #### Info Plist Settings : 38 | 39 | ``` 40 | ZiaSDK requires the following keys need to be add into info.plist 41 | 42 | Speech Recognition 43 | 44 | Privacy - Speech Recognition Usage Description 45 | 46 | Microphone Access 47 | 48 | Privacy - Microphone Usage Description 49 | 50 | To Add the Event to Calendar 51 | 52 | Privacy - Calendars Usage Description 53 | ``` 54 | 55 | ### Initialisation 56 | 57 | *Implement the below method on application launch,* 58 | 59 | ``` 60 | Zia.intialize(withAuthHandler: ZiaHandler?,portalID: String?, debugMode: .AutoDebug) 61 | 62 | ``` 63 | 64 | *This function will initialise the Zia with the handler and debugMode.* 65 | 66 | | debugMode | Description | 67 | |--- |--- | 68 | | AutoDebug | Based on macro (DEBUG) debugging will be automatically handled for development and production. | 69 | | Debug | Development Mode | 70 | | Release | Production Mode | 71 | 72 | *Create a class that inherit “ZiaHandler” and implement the methods as given below* 73 | 74 | ``` 75 | class ZiaAuthAdapter: ZiaHandler { 76 | 77 | //This is used to set the connection type for Zia 78 | 79 | override func getConnectionType() -> ConnectionType { 80 | return .OAuth 81 | } 82 | 83 | //This is used to return the OAuth Token from SSOKit 84 | 85 | override func getAuthToken(_ tokenCallBackHandler: @escaping (String?, Error?) -> Void) { 86 | ZSSOKit.getOAuth2Token { (token, error) in 87 | tokenCallBackHandler(token,error) 88 | } 89 | } 90 | 91 | //To hide the Zia call icon in chat window, return true 92 | 93 | override func shouldHideZiaCall() -> Bool { 94 | return true 95 | } 96 | 97 | //To set the client session data 98 | override func getCustomClientSessionData() -> [String : Any]? 99 | { 100 | return nil 101 | } 102 | 103 | //1.To handle the custom data from zia use the below method, return type is UIView(Client can handle the custom data and return view object) 104 | 105 | override func handleZiaResponse(_ actionName: String?, data: [String : AnyObject], customViewWidth: CGFloat, processType: ZiaCustomViewProcessType, completionHandler: @escaping (Bool, UIView?) -> ()) { 106 | completionHandler(false,nil) 107 | } 108 | 109 | 110 | //OBSERVERS 111 | 112 | //Use the below methods for observing the action such as Zia chat closed ,Zia Call ended, Zia Call Invoked from chat window,Zia Initialisation Failed 113 | 114 | override func didEndZiaCall() 115 | { 116 | 117 | } 118 | 119 | override func didCloseZiaChat() 120 | { 121 | 122 | } 123 | 124 | override func didInvokeZiacallFromChatWindow() 125 | { 126 | } 127 | 128 | override func didZiaIntialisedWith(status : ZiaIntializeStatus) 129 | { 130 | if status == .ZiaUnauthenticated{ 131 | } 132 | } 133 | } 134 | ``` 135 | 136 | *Following are the connection type supported by Zia,* 137 | 138 | | ConnectionType | Description | 139 | |--- |--- | 140 | | OAuth | Authenticated with Oauth Token | 141 | | Auth | Authenticated with Auth Token | 142 | | None | Unauthenticated (For public bot) | 143 | 144 | ## ZIA API's 145 | 146 | ### Zia Build Type 147 | 148 | *You set the build type for Zia using the below API,* 149 | 150 | ``` 151 | Zia.setBuild(type: ZiaBuildType) 152 | 153 | ``` 154 | 155 | *Following are the build type you can configure,* 156 | 157 | | ZiaBuildType | Description | 158 | |--- |--- | 159 | | Live | Production | 160 | | Local | Staging | 161 | 162 | *If you want to set the custom domain prefix, base domain, use the below API,* 163 | 164 | ``` 165 | 166 | Zia.setBuildType(type: ZiaBuildType,domainPrefix: String?,baseDomain: String?) 167 | 168 | Example : 169 | 170 | 1.Zia.setBuildType(type: .Local, domainPrefix: “ziatest”, baseDomain: nil) 171 | This will set as -> https://ziatest.localzoho.com 172 | 173 | 2.Zia.setBuildType(type: .Live, domainPrefix: “zia”, baseDomain: nil) 174 | This will set as -> https://zia.zoho.com 175 | 176 | 3.Zia.setBuildType(type: .Live, domainPrefix: nil, baseDomain: “zoho.com") 177 | This will set as -> https://zia.zoho.com 178 | 179 | 180 | ``` 181 | 182 | ### Zia Skill Setup 183 | 184 | *To set the skill for Zia, use the below API* 185 | 186 | ``` 187 | 188 | Zia.setSkill(name : String?) 189 | 190 | Example : 191 | 192 | Zia.setSkill(name : “zohocrm”) 193 | 194 | ``` 195 | 196 | ### Zia Scopes 197 | 198 | *To get the scopes used in Zia SDK, use the below API* 199 | 200 | ``` 201 | Zia.getScopes() 202 | 203 | Return Type - > String 204 | 205 | ``` 206 | 207 | ### Voice 208 | 209 | *To invoke the zia voice use the below API,* 210 | 211 | ``` 212 | Zia-Voice helps the user to interact with Zia through voice. 213 | 214 | Zia.call() 215 | ``` 216 | 217 | ### Chat 218 | 219 | *To invoke the zia chat use the below API,* 220 | 221 | ``` 222 | Zia-Chat helps the user to interact with Zia through chat window. 223 | 224 | Zia.chat() 225 | ``` 226 | 227 | ### Mute Zia Call 228 | 229 | *To stop Zia recognising on call, use the below API,* 230 | 231 | ``` 232 | Zia.muteZia() 233 | ``` 234 | 235 | ### UnMute Zia Call 236 | 237 | *To resume Zia recognising on call, use the below API,* 238 | 239 | ``` 240 | Zia.unmuteZia() 241 | ``` 242 | 243 | ### End Zia Call 244 | 245 | *To close/end Zia call, use the below API,* 246 | 247 | ``` 248 | Zia.endZiacall() 249 | ``` 250 | 251 | ### Close Zia Chat 252 | 253 | *To close Zia chat, use the below API,* 254 | 255 | ``` 256 | Zia.closeZiachat() 257 | 258 | ``` 259 | 260 | ### Zia Clear Data 261 | 262 | * To clear all the user data stored in Zia SDK memory, shared preferences and database.Use the below API,* 263 | 264 | ``` 265 | Zia.clearData() 266 | ``` 267 | 268 | ### Enable Help Option in ZiaChat 269 | 270 | *To enable help option in Zia chat set the below variable to true* 271 | 272 | ``` 273 | Zia.shouldShowHelpButton = true 274 | ``` 275 | 276 | ### Show Help Screen on "Noaction" in Call screen 277 | 278 | *To show help screen on “No action” in Zia Call ,set the below variable to true* 279 | 280 | ``` 281 | Zia.shouldShowHelpMenuForNoAction = true 282 | ``` 283 | 284 | ### Change chat window title 285 | 286 | *To Change the chat window title, use the below API* 287 | 288 | ``` 289 | Zia.setChatWindowTitle(title: "Zia") 290 | ``` 291 | 292 | ## Handling Custom Data 293 | 294 | As mentioned in above Ziahandler method,the below example show how to handle the custom data from Zia, 295 | 296 | ``` 297 | Example: 298 | 299 | class ZiaAdapter: ZiaHandler { 300 | 301 | override func handleZiaResponse(_ actionName: String?, data: [String : AnyObject], customViewWidth: CGFloat, processType: ZiaCustomViewProcessType, completionHandler: @escaping (Bool, UIView?) -> ()) { 302 | 303 | if processType != .ChatHistory{ 304 | print(actionName ?? "No Action Name") 305 | } 306 | 307 | if let action = actionName,action == "callacustomer_3" 308 | { 309 | if let record = data["call_to"] as? [String : AnyObject],let number = record["number"] as? String 310 | { 311 | Zia.muteZia() 312 | completionHandler(false,nil) 313 | 314 | 315 | DispatchQueue.main.async { 316 | 317 | let phoneStr = "telprompt://\(number)" 318 | UIApplication.shared.open(URL(string:phoneStr)!, options: [:], completionHandler: { (status) in 319 | if status{ 320 | }else{ 321 | } 322 | }) 323 | } 324 | 325 | return 326 | } 327 | } 328 | 329 | completionHandler(false,nil) 330 | } 331 | } 332 | 333 | ``` 334 | 335 | ## ZIA THEME CUSTOMISATION 336 | 337 | *To customise the appearance of Zia chat use the below API,* 338 | 339 | ``` 340 | Zia.setChatTheme(object: ZiaChatTheme) 341 | 342 | ``` 343 | > ZiaChatTheme - This is an object class which holds the instance to customise the Navigation bar,Chat window,Chat bubble. 344 | 345 | *Following are the examples, how to change the appearance for each 346 | components* 347 | 348 | ``` 349 | Navigation Bar 350 | 351 | let ziaChatNavigationBar = ZiaChatNavigationBar() 352 | 353 | ziaChatNavigationBar.chatNavigationBarShadowColor = UIColor.black 354 | 355 | ziaChatNavigationBar.chatNavigationBarShadowOpacity = 0.3 356 | 357 | ziaChatNavigationBarchatNavigationBarShadowRadius = 1 358 | 359 | ziaChatNavigationBarchatNavigationBarShadowOffset = CGSize(width: 0, height: 1) 360 | 361 | ziaChatNavigationBar.chatNavigationBarTitleColor = UIColor.black 362 | 363 | ziaChatNavigationBar.chatNavigationBarTitleFont = 364 | UIFont.systemFont(ofSize: 18,weight: .medium) 365 | 366 | ziaChatNavigationBar.chatRightBarButtonTextColor = UIColor.outgoingColor 367 | 368 | ziaChatNavigationBar.chatLeftBarButtonTextColor = UIColor.outgoingColor 369 | 370 | ziaChatNavigationBar.chatLeftBarButtonFont = 371 | UIFont.systemFont(ofSize: 18,weight: .regular) 372 | 373 | Chat Window 374 | 375 | let ziaChatWindow = ZiaChatWindow() 376 | 377 | ziaChatWindow.chatWindowBackgroundColor = UIColor.white 378 | 379 | ziaChatWindow chatWindowInputTextColor = UIColor.black 380 | 381 | ziaChatWindow.chatWindowInputFont = MessageWindowProperties.inputFont 382 | 383 | ziaChatWindow.chatWindowInputBackgroundColor = UIColor.white 384 | 385 | ziaChatWindow.chatWindowInputBorderColor = UIColor.lightGray 386 | 387 | ziaChatWindow.chatWindowInputShadowColor = UIColor.black 388 | 389 | ziaChatWindow.chatWindowInputShadowOpacity = 0.3 390 | 391 | ziaChatWindow.chatWindowInputShadowRadius = 1 392 | 393 | ziaChatWindow.chatWindowInputShadowOffset = 394 | CGSize(width: 0, height: 1) 395 | 396 | ziaChatWindow.chatWindowDateTitleColor = UIColor.messageDateTitleColor 397 | 398 | ziaChatWindow.chatWindowDateTitleFont=MessageWindowProperties.caption2BoldFont 399 | 400 | ziaChatWindow.chatWindowDateSeperatorLineColor = 401 | UIColor(white: 0.95, alpha: 1.0) 402 | 403 | ziaChatWindow.chatWindowNewConversationColor = 404 | UIColor(red: 216/255.0, green:60/255.0, blue: 126/255.0, alpha: 1.0) 405 | 406 | ziaChatWindow.chatWindowInputSendButtonDisableColor = UIColor.lightGray 407 | 408 | ziaChatWindow.chatWindowInputSendButtonEnableColor = UIColor.outgoingColor 409 | 410 | ziaChatWindow.chatWindowPromptSubmitButtonEnableBgColor = UIColor.outgoingColor 411 | 412 | ziaChatWindow.chatWindowPromptSubmitButtonDisableBgColor = 413 | UIColor(red:170.0/255.0, green: 170.0/255.0, blue: 170.0/255.0,alpha:1.0) 414 | 415 | ziaChatWindow.chatWindowPromptSubmitButtonTextColor = UIColor.white 416 | 417 | ziaChatWindow.chatWindowPromptSubmitButtonFont = 418 | UIFont.systemFont(ofSize:18.0, weight:UIFont.Weight.medium) 419 | 420 | ziaChatWindow.chatWindowPromptDiscardButtonBgColor = 421 | UIColor(red: 84.0/255.0,green: 87.0/255.0, blue: 102.0/255.0, alpha: 1.0) 422 | 423 | ziaChatWindow.chatWindowPromptDiscardButtonTextColor = UIColor.white 424 | 425 | ziaChatWindow.chatWindowPromptDiscardButtonFont = 426 | UIFont.systemFont(ofSize:19.3, weight: UIFont.Weight.medium) 427 | 428 | ziaChatWindow.chatWindowHelpButtonButtonDisableColor = UIColor.white 429 | 430 | ziaChatWindow.chatWindowScrollToLastMessageTextColor = UIColor.white 431 | 432 | ziaChatWindow.chatWindowScrollToLastMessageBackgroundColor = UIColor.white 433 | 434 | ziaChatWindow.chatWindowTipViewBackgroundColor = UIColor.white 435 | 436 | ziaChatWindow.chatWindowTipLabelTextColor = UIColor.black 437 | 438 | ziaChatWindow.chatWindowTipLabelTextFont = UIFont.systemFont(ofSize: 15.0, weight: UIFont.Weight.medium) 439 | 440 | Chat Bubble 441 | 442 | let ziaChatBubble = ZiaChatBubble() 443 | 444 | ziaChatBubble.chatbubbleShadowColor = UIColor.black 445 | 446 | ziaChatBubble.chatbubbleShadowOpacity = 0.3 447 | 448 | ziaChatBubble.chatbubbleShadowRadius = 1 449 | 450 | ziaChatBubble.chatbubbleShadowOffset = CGSize(width: 0, height: 1) 451 | 452 | ziaChatBubble.chatbubbleOutgoingBgcolor = UIColor.outgoingColor 453 | 454 | ziaChatBubble.chatbubbleOutgoingTextcolor = UIColor.white 455 | 456 | ziaChatBubble.chatbubbleIncomingBgcolor = UIColor.incommingColor 457 | 458 | ziaChatBubble.chatbubbleIncomingTextcolor = UIColor.black 459 | 460 | ziaChatBubble.chatbubbleTextFont=MessageWindowProperties.subtitleFont 461 | 462 | ziaChatBubble.chatbubbleIncomingImageColor = UIColor.white 463 | 464 | ziaChatBubble.chatbubbleIncomingImageBgColor = UIColor.outgoingColor 465 | 466 | Chat Window Onboarding 467 | 468 | let chatOnboardingWindow = ZiaChatOnBoardingWindow() 469 | 470 | chatOnboardingWindow.titleColor = UIColor.black 471 | 472 | chatOnboardingWindow. titleFont= MessageWindowProperties.subtitleFont 473 | 474 | chatOnboardingWindow.descriptionTextColor = UIColor.black 475 | 476 | chatOnboardingWindow.descriptionTextFont=MessageWindowProperties.subtitleFont 477 | 478 | chatOnboardingWindow.closeButtonColor = UIColor.black 479 | 480 | chatOnboardingWindow.onboardingBackgroundColor = UIColor.black 481 | 482 | Setting Chat Theme 483 | 484 | let ziaCustomTheme = ZiaChatTheme() 485 | 486 | ziaCustomTheme.chatNavigationBar = ziaChatNavigationBar 487 | ziaCustomTheme.chatWindow = ziaChatWindow 488 | ziaCustomTheme.chatBubble = ziaChatBubble 489 | ziaCustomTheme.chatOnboardingWindow = ziaChatOnboardingWindow 490 | 491 | Zia.setChatTheme(object: ziaCustomTheme) 492 | 493 | ``` 494 | 495 | ## License 496 | 497 | This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details 498 | --------------------------------------------------------------------------------