Answer Bot SDK in a nutshell

This page gives you the basic steps for getting up and running with the Answer Bot SDK.

The SDK is built on top of the Core SDK, which lays the foundation for multi-SDK interoperability.

What you need

  • Your organization has a Zendesk account with Guide and Answer Bot. You can register to start a free trial.

  • A Zendesk admin has registered your iOS app in Zendesk. See Registering the application in Zendesk in Help Center

  • The Zendesk admin has provided you with the initialization code for the app. The code was generated in Zendesk when the admin registered the app.

  • The Zendesk admin has enabled Answer Bot in the admin interface under Settings > Business Rules > Answer Bot.

Getting up and running

  1. Add the SDK to your project.

    For details, see Adding the Answer Bot SDK.

  2. Initialize Zendesk in the AppDelegate file of your project. This is a two-step process. First, initialize the Core SDK, then initialize the Support SDK.

    Swift

        Zendesk.initialize(appId: "appID", clientId: "clientId", zendeskUrl: "zendeskURL")
        Support.initialize(withZendesk: Zendesk.instance)
    

    Objective-C

        [ZDKZendesk initializeWithAppId:"appId" clientId:"clientId" zendeskUrl:"url"];
        [ZDKSupport initializeWithZendesk:[ZDKZendesk instance]];
    

    Note: If you're using multiple brands, you can use a brand subdomain rather than the primary subdomain in the zendeskUrl in the code above.

  3. Create an identity so the app can authenticate as a Zendesk Support user, then set it on the Zendesk singleton:

    Swift

        let identity = Identity.createAnonymous()
        Zendesk.instance?.setIdentity(identity)
    

    Objective-C

        id<ZDKObjCIdentity> userIdentity = [[ZDKObjCAnonymous alloc] initWithName:nil email:nil];
        [[ZDKZendesk instance] setIdentity:userIdentity];
    

    There are two types of identity: anonymous and JWT. For details, see Setting an identity.

  4. Initialize the Answer Bot SDK using the Zendesk and Support singletons you just initialized:

    Swift

        AnswerBot.initialize(withZendesk: Zendesk.instance, support: support)
    

    Objective-C

        [ZDKAnswerBot initializeWithZendesk:[ZDKZendesk instance] support:[ZDKSupport instance]];
    

The Answer Bot SDK is now initialized and ready to be used.

Launching the Answer Bot SDK

The Answer Bot SDK provides the AnswerBotUI class that has a static buildAnswerBotUI() method you can use to create the conversation viewController. Example:

Swift

        guard let answerBotViewController = AnswerBotUI.buildAnswerBotUI() else { return }
        self.navigationController?.pushViewController(answerBotViewController, animated: true)

Objective-C

        UIViewController *answerBotViewController = [ZDKAnswerBotUI buildAnswerBotUIWith:@[]];
        [self.navigationController pushViewController:answerBotViewController animated:YES];

You can configure them using RequestUiConfiguration and AnswerBotUIConfiguration (currently no configurations available).

Swift

        //Create a configuration object
        let config = RequestUiConfiguration()
        config.subject = "Testing the SDK"
        config.tags = ["iOS", "testing"]

        //Present the SDK
        let answerBotViewController = AnswerBotUI.buildAnswerBotUI(with: [config])
        self.navigationController?.pushViewController(answerBotViewController, animated: true)

Objective-C

        //Create a configuration object
        ZDKRequestUiConfiguration *config = [[ZDKRequestUiConfiguration alloc] init];
        config.subject = @"Test the SDK";
        config.tags = @[@"iOS", @"testing"];

        //Present the SDK
        UIViewController *answerBotViewController = [ZDKAnswerBotUI buildAnswerBotUIWith:@[config]];
        [self.navigationController pushViewController:answerBotViewController animated:YES];

You can even pass one view controller's UiConfig to another view controller, to be applied if one of them starts the other. For details, see Configuring the SDK screens.

To see some samples of different ways to use the Zendesk mobile SDKs, have a look at our sample apps repo on Github.