This library is deprecated. Please use API.AI's Apple Client library
The API.AI iOS SDK makes it easy to integrate natural language processing API on Apple devices. API.AI allows using voice commands and integration with dialog scenarios defined for a particular agent in API.AI.
- Create an API.AI account
- Install CocoaPods or Carthage
-
Run
pod update
in the AIDemo project folder. -
Open AIDemo.xworkspace in Xcode.
-
In AppDelegate insert API key.
AI.configure("YOUR_CLIENT_ACCESS_TOKEN")
Note: an agent in api.ai should exist. Keys could be obtained on the agent's settings page.
-
Define sample intents in the agent.
-
Run the app in Xcode. Inputs are possible with text and voice (experimental).
CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects. Installing:
$ [sudo] gem install cocoapods
List "AI" in a text file named Podfile
in your Xcode project directory:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!
target '<Your Target Name>' do
pod 'AI', '~> 0.7'
end
Now you can install the dependencies in your project:
$ pod install
Carthage is intended to be the simplest way to add frameworks to your Cocoa application.
You can use Homebrew and install the carthage
tool on your system simply by running brew update
and brew install carthage
.
Create a Cartfile
with following text:
github "api-ai/AI"
Run carthage update
.
Drag the built AI.framework
into your Xcode project.
In the AppDelegate.swift
, add AI import:
import AI
In the AppDelegate.swift, add
// Define API.AI configuration here.
AI.configure("YOUR_CLIENT_ACCESS_TOKEN")
...
// Request using text (assumes that speech recognition / ASR
// is done using a third-party library, e.g. AT&T)
AI.sharedService.TextRequest("Hello").success { (response) -> Void in
// Handle success ...
}.failure { (error) -> Void in
// Handle error ...
}