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.

On this article you have information on:

 

 

Function

The following functions are available:

 

 

Sending Messages

To send a message, send a POST request to https://messagehub.nubitalk.com/api/connectors/directline (Direct Line URL) with the following content:

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

Replace {type} with Text or Info:

  • If {type} = Info, fill the {text} field with either "close" or "typing":
    • "close" - Informs that the user left the chat.
      Payload example:
      "{
         "type":"info",
         "text":"close",
         "contactId":"teste@collab.com",
         "channelId":"0281df6f-5629-4e81-bbe3-d7eca699e2f9",
      }"
    • "typing" - Informs that the user is typing.
      Payload example:
      "{
         "type":"info",
         "text":"typing",
         "contactId":"teste@collab.com",
         "channelId":"0281df6f-5629-4e81-bbe3-d7eca699e2f9",
      }"
  • 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:

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


  • With {type} = Info, the {text} field is filled with "open", "close", "typing" or  "queue":
    • "open" - Informs that the user entered the chat.
      Payload example:
      "{
         "type":"info",
         "text":"open",
         "contactId":"teste@collab.com",
         "channelId":"0281df6f-5629-4e81-bbe3-d7eca699e2f9",
      }"
    • "close" - Informs that the user left the chat.
      Payload example:
      "{
         "type":"info",
         "text":"close",
         "contactId":"teste@collab.com",
         "channelId":"0281df6f-5629-4e81-bbe3-d7eca699e2f9",
      }"
    • "typing" - Informs that the user is typing.
      Payload example:
      "{
         "type":"info",
         "text":"typing",
         "contactId":"teste@collab.com",
         "channelId":"0281df6f-5629-4e81-bbe3-d7eca699e2f9",
      }"
    • "queue" - Informs about the queue information where the user is at.
      Payload example:

      "{
         "type":"info",
         "text":"
         {
            "queuePosition":0,
            "queueSize": 0,
            "expectedTimeInQueue": 0,
            "agentsReady": 1,
            "type": "queue"
         }",
         "contactId":"teste@collab.com",
         "channelId":"0281df6f-5629-4e81-bbe3-d7eca699e2f9",
      }"

       

Example

  • Download the Sample file:
    archive_icon.png 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)