SocialHub for Developers

SocialHub for Developers

  • Help

›Inbox APIs

Get Started

  • Overview
  • Integration
  • REST
  • WebHooks

General APIs

  • Manifest
  • Channel

Inbox APIs

  • Ticket

Resources

  • API Changelog
  • Signature Code Examples
Edit

Ticket API

The SocialHub Ticket API allows the creation of Custom Tickets for Custom Channels. By default these Tickets will only have network-agnostic Actions available. Actions that require changes to be made on the network (eg. Replies made to a Ticket), must be configured in the Manifest. If a WebHook is configured, it will receive information about executed Ticket Actions as Events.

Creating Tickets

Tickets are created using the REST API route POST /inbox/tickets.

Also take a look at the Swagger API Reference.

Example

Example Ticket creation request made with the unix tool cURL:

curl -X POST "https://api.socialhub.io/inbox/tickets?accesstoken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2NvdW50SWQiOiI1YzliNmIyYTU4YTg1NTA3NGQxZDI3OGYiLCJjaGFubmVsSWQiOiI1YzljMDE5NTJiZGZkNzE4MzA3YTBhNTMiLCJpYXQiOjE1NTQxMzQ1NDF9.mXomId0-stW1l4QQQkjeBflo74ZIHzd0-Xj_71VyncA" -d '
{
 "interaction": {
   "message": "Hello, can someone help me?",
   "createdTime": "2019-01-28T16:58:12.736Z",
   "networkItemId": "question-q_0000000001",
   "url": "http://example.com/questions/q_0000000001",
   "pictures": [{
     "small": "https://example.com/questions/q_0000000001/images/1/thumbnail.png",
     "large": "https://example.com/questions/q_0000000001/images/1/original.png"
   }],
   "root": {
     "rootId": "conversation-48622799"
   },
   "interactor": {
     "interactorId": "u_5678986543",
     "name": "Jork Schrank",
     "url": "https://example.com/user/u_5678986543",
     "picture": "https://example.com/user/u_5678986543/avatar.png"
   }
 }
}
' -H "Content-Type: application/json"

Request

A Ticket is an entity managed within the SocialHub Inbox. A Ticket contains the Information about the Interaction (eg. a comment on a Facebook post) it represents. The Integration will request the Interaction's information from a data-source and use it to create a Ticket via the SocialHub API.

FieldDescription
interactionContains the Interaction's information as Ticket sub-object.

Note that the followupTo field cannot be specified during Ticket creation. Rather it is automatically set for Tickets that are created for replies after calling the Reply Success Confirmation callback.

interaction

FieldDescription
messageMessage text of an Interaction (eg. the Text of a Facebook comment). May have up to 10.000 characters. Optional*
picturesList of images of an Interaction (eg. a Facebook post with one or multiple images). Optional*
attachmentsList of file attachments of an Interaction (eg. a Direct Message with one or multiple files attached). Optional*
linkLink url shared on the Interaction. This url will be clickable in the SocialHub interface. Optional*
ratingOptional: Stores rating/review information. Optional*
createdTimeOptional: The Interaction's creation time (as ISO 8601). For Facebook this would for example be the date and time when a comment was created. If this field is not specified the current date will be used.
networkItemIdA unique identifier of the Interaction within a Custom Channel. A HTTP 409 Conflict will be returned if you attempt to create a Ticket with an identifier that has already been used for another Ticket within the same Channel. Allowed pattern as regular expression: `^[a-zA-Z0-9/\@&$!?()[]{}+*~,;.:=_-]{6,256}$`
interactorOptional: Information about the person that created the interaction. (eg. a Facebook User)
urlOptional: Link to the Interaction. This link will be used by SocialHub Users to eg. allow them to access the Interaction directly on the networks website.
rootOptional: Stores Root-Ticket information.
typeOptional: Ticket Type, TICKET by default. Can only be set when creating Tickets for Channels of reusable Manifests.

Optional*: A Ticket must have at least one of the following fields set: message, pictures, attachments, link or rating.

interaction.pictures[]

FieldDescription
smallURL of a thumbnail version of the image. URL must support HTTPS protocol.
largeOptional: URL of the original version of the image. If set, URL must support HTTPS protocol.

interaction.attachments[]

FieldDescription
urlURL to download the attached file. URL must support HTTPS protocol.
nameOptional: Attachment filename.
sizeOptional: Numerical filesize in bytes.
mimeTypeOptional: Attachment filetype as mime-type (eg. "application/pdf")

interaction.interactor

FieldDescription
interactorIdA network specific unique identifier of the person that caused this interaction. If multiple Tickets share an interactor with the same id they will be linked automatically (eg. for the right sidebar user history). If the ID matches the Channel's networkId, the Ticket will not appear as an unread Ticket in the Inbox because it was most likely caused by an external action by the Customer owning the Channel.
nameName of the person that caused this interaction.
urlOptional: URL of the person's profile.
pictureOptional: HTTPS URL of the person's avatar picture.

interaction.root

FieldDescription
rooIdnetworkItemId of the Root-Ticket of this Ticket. Used for right sidebar Tree-Building. If referenced Root-Ticket does not exist a new empty hidden Ticket will be automatically created.

interaction.rating

FieldDescription
valueRating value. This would be 7 in a 7/10 rating.
scaleRating scale. This would be 10 in a 7/10 rating.

Responses

The following responses of the SocialHub Ticket API should the handled by the Integration's client:

HTTP 201 Created

Represents the successful creation of the Ticket. The newly created ticket object will be returned.

Example:

{
  "channelId": "5eb47954a545b82b5b522cce",
  "accountId": "5e73f5245a45da10b6e614d8",
  "_id": "5eb493dcac52392e08513417",
  "createdTime": "2020-05-07T23:03:56.384Z",
  "interaction": {
    "createdTime": "2019-01-28T16:58:12.736Z",
    "message": "Hello, can someone help me?",
    "networkItemId": "question-q_0000000001",
    "url": "http://example.com/questions/q_0000000001",
    "root": {
      "url": null,
      "rootId": "conversation-48622799",
      "createdTime": "2020-05-07T23:03:56.336Z"
    },
    "interactor": {
      "url": "https://example.com/user/u_5678986543",
      "name": "Jork Schrank",
      "picture": "https://example.com/user/u_5678986543/avatar.png",
      "interactorId": "5eb493dcac52392e08513416"
    },
    "attachments": [],
    "pictures": [
      {
        "small": "https://example.com/questions/q_0000000001/images/1/thumbnail.png",
        "large": "https://example.com/questions/q_0000000001/images/1/original.png"
      }
    ]
  }
}

The _id value is a unique identifier of a Ticket within the SocialHub Inbox. You might want to store it in reference to the Interactions within your Integration.

Note that SocialHub will store the interactor.interactorId that you sent separately. The interactorId returned in the response will be the interactor identifier of SocialHub. SocialHub will automatically link the network specific interactorId that you sent to the SocialHub specific ID if we have already received it once.

HTTP 409 Conflict

{
 "code": "ConflictError",
 "message": "Error: Ticket with such network item id already exists"
}

Means that you already created a Ticket using the same unique Interaction identifier within the Channel. If your Integration is functioning properly you can probably refrain from further attempts.

Updating Tickets

Tickets can also be updated using the REST API route PATCH /inbox/tickets/:ticketId which is very similar to the creation route.

Example

Example Ticket update request made with the unix tool cURL:

curl -X PATCH "https://api.socialhub.io/inbox/tickets/5eb493dcac52392e08513417?reset=true&accesstoken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2NvdW50SWQiOiI1YzliNmIyYTU4YTg1NTA3NGQxZDI3OGYiLCJjaGFubmVsSWQiOiI1YzljMDE5NTJiZGZkNzE4MzA3YTBhNTMiLCJpYXQiOjE1NTQxMzQ1NDF9.mXomId0-stW1l4QQQkjeBflo74ZIHzd0-Xj_71VyncA" -d '
{
 "interaction": {
   "message": "Edit: I removed that photo..",
   "updatedTime": "2020-01-28T16:58:12.736Z",
   "url": "http://example.com/questions/q_0000000001",
   "pictures": [],
   "interactor": {
     "name": "Jörk Schrank",
     "url": "https://example.com/user/u_5678986543",
     "picture": "https://example.com/user/u_5678986543/avatar.png"
   }
 }
}
' -H "Content-Type: application/json"

Request

You can partially update the Ticket by only specifying those fields that you want to change in the request body. The list of fields is pretty much the same as during creation with a few differences:

The createdTime, networkItemId, root and interactor.interactorId fields cannot be updated after a Ticket was created. But you can specify a new field called updatedTime that works the same way as createdTime did and should contain the date-time of when the interaction was updated on the network it was created on.

Resetting Tickets

After you updated a Ticket you might want to make sure that it is moved back into the Inbox where new Tickets are. To move it back from the Done folder, simply set the query parameter like this: ?reset=true.

Receiving Ticket Action Events

We differentiate between two types of Ticket Actions:

  1. Network Agnostic Actions are always available for all Tickets in the Inbox. An Integration does not have control over them and will not receive events of their execution. Example Actions are: Assigning a Ticket to a User, Archiving a Ticket ("Done" Button) or creating an internal Note Followup on the Ticket.
  2. Network Specific Actions need to be configured by an Integration in the Channel's Manifest. They are specific to the Network and their execution will be communicated with the Integration as Events delivered to a configured WebHook.

Registration in Manifest

The WebHook and Network Specific Ticket Action options can be set using the Manifest API.

Ticket Action Events

The WebHook request body will look like this when delivering Ticket Action events:

{
  "manifestId": "5cc1afd1d62ec72e8388cb45",
  "accountId": "5cb9003af1bb6808381d184d",
  "channelId": "5cc1afd1d62ec72e8388cb46",
  "events": {
    "ticket_action": [
      {
        "ticketId": "5cc1b08ad62ec72e8388cb47",
        "networkItemId": "question-q_0000000001",
        "type": "",
        "actionId": "",
        "payload": {},
        "time": 1556201893268,
        "uuid": "4616f2f0-5069-4ee8-ad95-4c106c277eb3"
      }
    ]
  }
}

events.ticket_action[]

FieldDescription
ticketIdUnique identifier of the Ticket that was replied. Same identifier as returned when the Ticket was created.
networkItemIdUnique identifier of the Interaction of the Ticket that was replied. Same identifier as used when the Ticket was created.
typeType of the Ticket Action (can be reply, template_reply or button)
actionIdIdentifier of the Ticket Action as configured in the Manifest (inbox.ticketActions[].id).
payloadOptional Ticket Action payload. Contains Ticket Action specific data.
timeUnix timestamp in ms of when this event was created (intended for debugging purposes).
uuidUnique identifier of the event (intended for debugging purposes).

Ticket Action Type: reply

{
  "ticketId": "5cc1b08ad62ec72e8388cb47",
  "networkItemId": "question-q_0000000001",
  "type": "reply",
  "actionId": "reply-as-comment",
  "payload": {
    "text": "Hello! Sure, how can we assist you?",
    "followupId": "f5f75b50-6764-11e9-9ce6-3507264c7519",
    "attachments": [{
      "size": 100,
      "name": "doc.pdf",
      "extension": ".pdf",
      "url": "https://aws.com/files/doc.pdf",
      "mimetype": "application/pdf"
    }]
  },
}
payload
FieldDescription
textThe Text that was specified by the SocialHub User to publicly reply to the Interaction with.
followupIdUnique identifier of the Reply-Folloup that was created on the Ticket.
attachmentsArray of file attachments provided by the SocialHub User to be used in the reply. At the moment reply can have only 1 attachment.
optionId of the reply option selected by the user (for ticket actions that have options defined in the manifest)

followupId is a mandatory field. text and attachments fields are optional, but at least one of them must present in the payload (payload can have both too unless the manifest option inbox.ticketActions[].attachments.noText was set to true. Then there is no text allowed when attachments field is provided).

payload.attachments
FieldDescription
sizeFile size of the attachment in bytes.
nameOriginal file name of the attachment.
extensionFile extension of the attachment
urlUrl which can be used to download the attachment
mimetypeMIME type of the attachment

Ticket Action Type: template_reply

{
  "ticketId": "5cc1b08ad62ec72e8388cb47",
  "networkItemId": "question-q_0000000001",
  "type": "template_reply",
  "actionId": "reply-with-template",
  "payload": {
    "followupId": "f5f75b50-6764-11e9-9ce6-3507264c7519",
    "name": "Test Greeting",
    "networkId": "test_greeting",
    "variables": {
      "firstName": "Jork"
    },
    "language": "de",
  },
}
payload
FieldDescription
followupIdUnique identifier of the Reply-Folloup that was created on the Ticket.
nameHuman readable name of the selected template
networkIdNetwork ID of the selected template
variablesKey-value map of variable names and their values
languageSelected language value
Reply Success Confirmation

After receiving the Reply event the Integration should asynchronously attempt to create the Reply on the Network. For example if the Integration is for Facebook and the Ticket Interaction was a Post created on a Facebook Page by a Fan, then the Reply created on the Ticket should be created as a Comment on the Facebook Post.

If the Reply was processed successfully by the Integration, the success callback located at POST /inbox/tickets/:ticketId/replies/:followupId/success should be called like this:

curl -X POST "https://api.socialhub.io/inbox/tickets/5cc1b08ad62ec72e8388cb47/replies/f5f75b50-6764-11e9-9ce6-3507264c7519/success?accesstoken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2NvdW50SWQiOiI1YzliNmIyYTU4YTg1NTA3NGQxZDI3OGYiLCJjaGFubmVsSWQiOiI1YzljMDE5NTJiZGZkNzE4MzA3YTBhNTMiLCJpYXQiOjE1NTQxMzQ1NDF9.mXomId0-stW1l4QQQkjeBflo74ZIHzd0-Xj_71VyncA" -d '
{
 "interaction": {
   "createdTime": "2019-01-28T17:02:03.153Z",
   "networkItemId": "answer-a_0000000052",
   "url": "http://example.com/questions/q_0000000001/a_0000000052"
 }
}
' -H "Content-Type: application/json"

interaction

FieldDescription
createdTimeOptional: The Reply's creation time (as ISO 8601) on the Network. If this field is not specified the current date will be used.
networkItemIdA unique identifier of the Reply within a Custom Channel. A HTTP 409 Conflict will be returned if the identifier has already been used for another Ticket within the same Channel. Allowed pattern as regular expression: `^[a-zA-Z0-9/@&$!?()[]{}+*~,;.:=_-]{6,256}$`
typeOptional and only available for reusable manifests: The Ticket type, TICKET by default.
urlOptional: Link to the Interaction.

Ticket Action Type: button

{
  "ticketId": "5cc1b08ad62ec72e8388cb47",
  "networkItemId": "question-q_0000000001",
  "type": "button",
  "actionId": "like-button",
  "payload": {},
}

This action type does not need success confirmation, so if the corresponding Action succeeded on the Network, the Integration does not need to send any further requests to the SocialHub API.

However, if the Ticket Action has failed, this should be communicated (see Error Handling).

Error Handling

Ticket Actions are processed asynchronously by the Integration. To handle cases where the Action has failed, for example because the Integration was unable to apply it on the Network, there is a callback route that informs the Community Managers of the failure: POST /inbox/tickets/:ticketId/reset/:actionId.

curl -X POST "https://api.socialhub.io/inbox/tickets/5cc1b08ad62ec72e8388cb47/reset/reply-as-comment?accesstoken=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2NvdW50SWQiOiI1YzliNmIyYTU4YTg1NTA3NGQxZDI3OGYiLCJjaGFubmVsSWQiOiI1YzljMDE5NTJiZGZkNzE4MzA3YTBhNTMiLCJpYXQiOjE1NTQxMzQ1NDF9.mXomId0-stW1l4QQQkjeBflo74ZIHzd0-Xj_71VyncA" -d '
{
  "followupId": "f5f75b50-6764-11e9-9ce6-3507264c7519",
  "reason": "Failed to create the Reply because the Interaction has been deleted on the Network."
}
' -H "Content-Type: application/json"
FieldDescription
followupIdThe identifier of the Reply Followup that has failed to be processed. Only required for reply and template_reply actions.
reasonOptional human readable reason why the Ticket Action has failed.
← ChannelAPI Changelog →
  • Creating Tickets
    • Example
    • Request
    • Responses
  • Updating Tickets
    • Example
    • Request
  • Receiving Ticket Action Events
    • Registration in Manifest
    • Ticket Action Events
    • Error Handling
SocialHub for Developers
Resources
GitHubZendesk User ManualYouTube Channel
Community
Stack OverflowFacebook UsergroupFeature Community
SocialHub
WebsiteImprint (int)Impressum (de)
SocialHub
Copyright © 2023 SocialHub