Tickets

This is the developer guide for the Support SDK v1 for Android. For Support SDK v2, see Support SDK v2 Android.

The conversations you have with your users appear in Support as tickets. Using the Support SDK your users can create new tickets, update existing ones, and receive notifications about updates you make. You can also collect information from your users, directly or in the background, to make it easier to give a useful reply the first time.

On this page:

Useful information

The UI that is provided with the Support SDK looks like this:

Screenshot: The Help Center in the Support SDK

The Support SDK has several styling options. See Customize the look to learn how to style the interface.

This page is split into sections:

  • Settings tells you what you can configure.
  • Tickets in the Support SDK UI tells you how to get going with the built-in UI.
  • Additional methods tells you how to get going if you want to build your own UI.


Settings

Support admin

Settings for the Support SDK can be found in the admin section of Zendesk Support: Admin > Channels > Mobile SDK

The ability to create tickets with the Support SDK is enabled by default. If you'd like your users to be able to view their tickets and update them, you must enable this feature. Navigate to your app's settings in Support and enable 'Conversations'.

Important: The Essential plan only allows users to create tickets via the Support SDK. Users will not be able to revisit or reply to their tickets in your app, but will be able to receive emails from you.

In your code
Set the subject, tags, and additional info

You control the subject, tags, and additional info of the ticket using the ZendeskFeedbackConfiguration interface. This configuration can then be passed along when you are starting the components described on this page.

Subject

ZendeskFeedbackConfiguration configuration = new BaseZendeskFeedbackConfiguration() {
    @Override
    public String getRequestSubject() {
        return "App Ticket";
    }
};

Tags

ZendeskFeedbackConfiguration configuration = new BaseZendeskFeedbackConfiguration() {
    @Override
    public String getRequestSubject() {
        return "App Ticket";
    }

    @Override
    public List<String> getTags() {
        return Arrays.asList("tag_one", "tag_two");
    }
};

Additional info

Note: Information added in this way will be appended to the body of the ticket. It will be visible to your user.

ZendeskFeedbackConfiguration configuration = new BaseZendeskFeedbackConfiguration() {
    @Override
    public String getRequestSubject() {
        return "App Ticket";
    }

    @Override
    public String getAdditionalInfo() {
        return "\n\nSome sample extra content.";
    }
};
Add data to a custom ticket field

Custom ticket fields must be end-user visible and editable. You can set this in the For end-users section of a ticket field's settings.

Custom ticket fields do not have to appear on a ticket form to receive data from the SDK.

To add data to a custom ticket field, you must add it to ZendeskConfig before you show the create request screen to your user.

CustomField customFieldOne = new CustomField(1234567L, "3");
CustomField customFieldTwo = new CustomField(2345678L, "Some text");

ZendeskConfig.INSTANCE.setCustomFields(Arrays.asList(customFieldOne, customFieldTwo));
Set the ticket form your agent will see

If you would like to specify which ticket form to show when your agent reads tickets, get its ID from your settings (Admin > Manage > Ticket Forms), and use that with the following setting:

ZendeskConfig.INSTANCE.setTicketFormId(1333L);


Tickets in the Support SDK UI

Create a new ticket

This will present a view to your user, where they can add the details of their request, attachments, or provide their email address if it is required.

// null can be passed to use the default ZendeskFeedbackConfiguration
ContactZendeskActivity.startActivity(this, null);
Show open tickets

This feature is only available on the Team, Professional, and Enterprise plans.

If you are using an anonymous identity, the end-user will only be able to see requests that have been created on that device. If you are using an anonymous identity and you reinstall the app, requests created on the device before that time will not be shown.

// null can be passed to use the default ZendeskFeedbackConfiguration
RequestActivity.startActivity(this, null);
Show a single ticket

This component lets your users see an individual ticket and its comments. EXTRA_SUBJECT and EXTRA_REQUEST_ID are required, and EXTRA_REQUEST_ID must be a valid request ID.

Intent intent = new Intent(this, ViewRequestActivity.class);

intent.putExtra(ViewRequestActivity.EXTRA_SUBJECT, "My printer is on fire!");
intent.putExtra(ViewRequestActivity.EXTRA_REQUEST_ID, "123");

startActivity(intent);
Check for updates on your requests

The RequestProvider has a method called getUpdatesForDevice which can be used to check if there are any request updates to a user's tickets. This can be used to create a visual indicator for your users when there has been activity on their requests.:

final RequestProvider requestProvider = ZendeskConfig.INSTANCE.provider().requestProvider();

requestProvider.getUpdatesForDevice(new ZendeskCallback<RequestUpdates>() {
    @Override
    public void onSuccess(RequestUpdates requestUpdates) {

        if (requestUpdates.hasUpdates()) {
            Set<String> updatedRequestIDs = requestUpdates.getRequestsWithUpdates().keySet();

            for (String id : updatedRequestIDs) {
                Logger.d(LOG_TAG, "Request %s has %d updates",
                        id, requestUpdates.getRequestsWithUpdates().get(id));
            }
        }
    }

    @Override
    public void onError(ErrorResponse errorResponse) {
        // handle error
    }
});

This method caches requestUpdates for up to an hour. Any subsequent calls within that timeframe will return the same cached object without querying the network. Viewing a request will remove it from the cached requestUpdates.getRequestsWithUpdates() object, since the updates have now been seen. This is done when the request's comments load in ViewRequestActivity. If you have implemented any custom UI, you can mark a request as seen by calling the following method:

ZendeskConfig.INSTANCE.storage().requestStorage().markRequestAsRead("123");

Note: If you have implemented push notifications for tickets, this feature is not available.


Additional methods (API providers)

Create a RequestProvider
RequestProvider requestProvider = ZendeskConfig.INSTANCE.provider().requestProvider();
createRequest

Calls a request service to create a request on behalf of the end user.

Name Type Comment
request CreateRequest Request model object.
callback ZendeskCallback Callback invoked in response to remote API invocation.

Usage:

After creating a RequestProvider provider, you can use the provider's createRequest method to create a request.

CreateRequest request = new CreateRequest();

request.setSubject("My printer is on fire!");
request.setDescription("The smoke is very colorful.");
request.setTags(Arrays.asList("printer", "fire"));

requestProvider.createRequest(request, new ZendeskCallback<CreateRequest>() {
    @Override
    public void onSuccess(CreateRequest createRequest) {
        // Handle success
    }

    @Override
    public void onError(ErrorResponse errorResponse) {
        // Handle error
    }
});
getRequest

Gets the request specified by the ID.

Name Type Comment
requestId String The ID of a request in Zendesk Support.
callback ZendeskCallback The callback to invoke which will return a Request object.
getAllRequests

Gets all requests that user has opened. It will also get an access token if one has not been previously stored. If you are using anonymous identities we will check to see if you have any stored request IDs.

Name Type Comment
callback ZendeskCallback The callback to invoke which will return a list of Request objects
getRequests

Filters requests that user has opened by a status. It will also get an access token if one has not been previously stored.

Name Type Comment
status String A comma-separated list of status to filter the results by
callback ZendeskCallback The callback to invoke which will return a list of Request objects
getComments

Gets all comments for a request. It will also get an access token if one has not been previously stored.

Note: Only available on the Team, Professional, and Enterprise plans.

Name Type Comment
requestId String requestId Id of a request
callback ZendeskCallback Callback that will deliver a CommentsResponse model
addComment

Add a comment message to a request. It will also get an access token if one has not been previously stored.

Name Type Comment
requestId String Id of a request to add this comment to
endUserComment EndUserComment The comment to create, including text and attachments
callback ZendeskCallback Callback that will deliver a Comment object
getTicketFormsById

Gets the contents of ticket forms you specify. Only the first 5 ticket form Ids will be fetched.

Name Type Comment
ticketFormIds List of Long An list of ticket form IDs
callback ZendeskCallback The callback that is invoked when a request is either successful or has an error.