Latest 2.0.1
License MIT
Platforms ios 10.0

QnA Bot Maker

iOS Library for working with the Microsoft QnA Maker Bot Service

Convenience library for working with Microsoft’s QnA Maker Service. Microsoft QnA Maker Service lets you create FAQ Bots quickly. The QnABotMaker library enables you to use the QnA Maker Service directly from within your iOS app. Before getting started pleaes check out Microsoft QnA Maker.

Getting Started

Before you get started using this library you will need to create a QnA "Service" using Microsoft’s QnA Maker.

Once you have published your QnA Service you will see a Sample HTTP request similar to the one shown below.

POST /knowledgebases/581bd885-5588403d-9935fe3cd325c503/generateAnswer
Authorization: EndpointKey aa000344-9998-4d3b-9df3-52bf7c4f7ffd
Content-Type: application/json

The QnABotMaker library needs a few of these parameters in order to connect to the QnA Maker service.

1) First we need to know your host value. This is the url provided with the host key. An example of this is the highlighted shown below.


2) Next we need your knowledgebase identifier or knowledgebaseID, this is the highlighted shown below.

POST /knowledgebases/581bd885-5588403d-9935fe3cd325c503/generateAnswer

3) The last configuration element we need is your endpoint key value, this is the highlighted shown below.

Authorization: EndpointKey aa000344-9998-4d3b-9df3-52bf7c4f7ffd

4) Finally, you will use these parameters when creating an new instance of the QnAService struct as shown in the below example

let bot = QnAService(host: "", knowledgebaseID: "5581bd885-5588403d-9935fe3cd325c503", endpointKey: "aa000344-9998-4d3b-9df3-52bf7c4f7ffd")


  • Xcode 9.1 or newer
  • Swift 4.1
  • iOS 10 or greater



QnABotMaker is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "QnABotMaker"


github "benbahrenburg/QnABotMaker"


Copy all *.swift files contained in QnABotMaker/Classes/ directory into your project.

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler. It is in early development, but Alamofire does support its use on supported platforms.

Once you have your Swift package set up, adding Alamofire as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .Package(url: "", majorVersion: 1)


Using QnABotMaker couldn’t be easier. You simply create a new instance of the library and provide the askQuestion function with a question. The completion hander, completionHandler, will provide the QnA answers or an error if necessary.

The following shows the library inaction.

let bot = QnAService(host: "YOUR-HOST-URL", knowledgebaseID: "YOUR-KB-ID", endpointKey: "YOUR-ENDPOINT-KEY")

bot.askQuestion("hello", completionHandler: {(answers, error) in
    if let error = error {
        return print("error: (error)")
    if let answers = answers {


Ben Bahrenburg, @bencoding


QnABotMaker is available under the MIT license. See the LICENSE file for more info.

Latest podspec

    "name": "QnABotMaker",
    "version": "2.0.1",
    "summary": "Simplifies working with Microsoft QnA Maker on iOS.",
    "description": "Convenience library for working with Microsoft QnA Maker Service",
    "homepage": "",
    "license": "MIT",
    "authors": {
        "Ben Bahrenburg": "[email protected]"
    "source": {
        "git": "",
        "tag": "2.0.1"
    "social_media_url": "",
    "platforms": {
        "ios": "10.0"
    "source_files": "QnABotMaker/Classes/**/*"

Pin It on Pinterest

Share This