Server side integration

This endpoint allows you to create a way where your clients communicate with your services through a chat on your website. Your agents receive the messages as an interaction on OneAgentWeb and your clients can reach you effortlessly without leaving your webpage, for example.

Function

Sending Messages

  • POST rest call
  • To: https://messagehub.nubitalk.com/api/connectors/directline (Direct Line URL)

Header: "Content-Type": "application/json"
Body:
   {
      "CallbackURL": "{callbackURL}",
      "Message":
         {
            "Text": "{text}",
            "ChannelId": "a Guid representing the ChannelId" (must ask us for this code),
            "ContactId": "the name of the sender user",
            "Type": "{type}"
         }
   }

  • Replace {type} with Text or Info.
  • With {type} = Info, fill the {text} field with:
    • "open" - Informs that the user entered the chat.
      Payload example:
      "{
         "id":"e5559f38-8e14-4630-b117-2a9abdcd8ecb",
         "text":"open",
         "type":"info",
         "createdOn":"2020-03-28T13:28:23.1063205Z",
         "contactId":"teste@collab.com",
         "contactName":null,
         "direction":"outgoing",
         "channelId":"0281df6f-5629-4e81-bbe3-d7eca699e2f9",
         "url":null,
         "extension":null,
         "longitude":null,
         "latitude":null
      }"
    • "close" - Informs that the user left the chat.
      Payload example:
      "{
         "id":"e5559f38-8e14-4630-b117-2a9abdcd8ecb",
         "text":"close",
         "type":"info",
         "createdOn":"2020-03-28T13:28:23.1063205Z",
         "contactId":"teste@collab.com",
         "contactName":null,
         "direction":"outgoing",
         "channelId":"0281df6f-5629-4e81-bbe3-d7eca699e2f9",
         "url":null,
         "extension":null,
         "longitude":null,
         "latitude":null
      }"
    • "typing" - Informs that the user is typing.
      Payload example:
      "{
         "id":"e5559f38-8e14-4630-b117-2a9abdcd8ecb",
         "text":"typing",
         "type":"info",
         "createdOn":"2020-03-28T13:28:23.1063205Z",
         "contactId":"teste@collab.com",
         "contactName":null,
         "direction":"outgoing",
         "channelId":"0281df6f-5629-4e81-bbe3-d7eca699e2f9",
         "url":null,
         "extension":null,
         "longitude":null,
         "latitude":null
      }"
    • "queue" - Informs about the queue information where the user is at.
      Payload example:

      "{
         "id":"e5559f38-8e14-4630-b117-2a9abdcd8ecb",
         "text":"
         {
            "queuePosition":0,
            "queueSize": 0,
            "expectedTimeInQueue": 0,
            "agentsReady": 1,
            "type": "queue"
         }",
         "type":"info",
         "createdOn":"2020-03-28T13:28:23.1063205Z",
         "contactId":"teste@collab.com",
         "contactName":null,
         "direction":"outgoing",
         "channelId":"0281df6f-5629-4e81-bbe3-d7eca699e2f9",
         "url":null,
         "extension":null,
         "longitude":null,
         "latitude":null
      }"

       

  • Replace {callBackURL} with the end point to which the messages from the Agent will be sent.


Receiving Messages

  • The messages will be sent to {callbackURL} with the same format:

   {
      "Text": "{text}",
      "ChannelId": "a Guid representing the ChannelId" (must ask us for this code),
      "ContactId": "the name of the sender user",
      "Type": "{type}"
   }

 

Example

  • Download the Sample file (Sample.zip).
  • Change the appsettings:
    • "DirectLineURL" = Direct Line URL
    • "ChannelId" = Channel ID (You should ask for a new Channel ID)
    • "CallbackURL" = The end point to which the messages from the Agent will be sent.
  • Run the project at Visual Studio.
  • Create an account (this is just a Sample's freature).
  • Log in in the account you just created.
  • Try your chat:
    • Send messages (to try this, ask for your own Channel ID and some Agent have to be logged in, at the respective channel)