In App Messaging REST Service

In App Messaging is a RESTful web service that allows two-way, asynchronous communication (messaging) between third party applications and Agents on the ContactAtOnce! Network. It enables App to App Asynchronous Message Communication. No SMS or Phone Number required on either side.

Consumer perception is that messaging is fully incorporated into Publisher app.

Since the API is based on REST principles, it’s very easy to write and test applications. You can use your browser to access URLs, and you can use pretty much any HTTP client in any programming language to interact with the API. The ContactAtOnce! In App Messaging REST API is served over HTTPS. To ensure data privacy, unencrypted HTTP is not supported.

In App Messaging uses Basic Authentication. ContactAtOnce! can issue you an APIKEY to use. A username and password are not necessary.

In App Messaging Resources

Publisher Endpoints


Base URL (regionally defined):

  • North America : https://api.contactatonce.com/
  • Australia : https://api.contactatonce.com.au/
  • Europe : https://api.contactatonce.co.uk/

System Diagram
MessagingSystemDiagram

Start

Starts a Messaging Conversation with specified ConsumerId

Method: POST 
/api/v1.0/AsyncConversation/Start

Request   
ParameterTypeRequiredDescription
AdvertiserIdStringRequiredUnique ID assigned to Advertiser Account by Publisher at provisioning.
ConsumerIdStringRequiredUnique ID assigned to Consumer by Publisher.
SessionIdStringRequiredUnique Id assigned to the Conversation by the Publisher. If provided, it will be returned in Messages posted by ContactAtOnce! to the inbound message URL.
ExternalMessageIdStringRequiredUnique ID assigned to the Message by Publisher
MessageStringRequiredBody of message to be sent
DeviceStringOptionalMobile Device of the Consumer
OSVersionStringOptionalMobile Operating System of the Consumer's Mobile Device
ConsumerFirstNameStringOptionalFirst Name of Consumer
ConsumerLastNameStringOptionalLast Name of Consumer
ConsumerPhoneNumberStringOptionalMobile Number of Consumer
ListingDetailsStringOptionalFree form contextual information to be associated with the Conversation. Typically name/value pairs with a special (ÿ) separator character.

Response  
ParemeterTypeDescription
VisitIdIntUnique Id assigned to the Conversation by ContactAtOnce!
ConsumerIdStringUnique ID assigned to Consumer by Publisher.
SessionIdStringUnique Id assigned to the Conversation by Publisher
StatusIntResult of the Post. 0 = Success 1 = Failure If 1, a FailureDescription will also be provided.
FailureDescriptionStringDescription of failure used for debugging purposes

Sample Header- JSON

Authorization: Basic {YOUR_API_KEY}
Accept: version=2; 

Sample POST – JSON

{
   "AdvertiserId":"12345",
   "ConsumerId":"12345",
   "SessionId":"abc1234",
   "ExternalMessageId":"5236987",
   "Message":"Do you offer special financing on this vehicle",
   "Device":"iPhone 6+",
   "OSVersion":"1.0",
   "ConsumerFirstName":"Bob",
   "ConsumerLastName":"Johnson",
   "ConsumerPhoneNumber":"14045551212",
   "ListingDetails":"year=2014ÿmake=Fordÿmodel=F150"
}

Sample Response- JSON
If the POST is successful, the value for Status will be 0 and a VisitId will be assigned to the Conversation and returned along with ConsumerId and SessionId if provided. If the POST is not successful, the values for Status will be 1 and a description of the failure will be provided.

{
  "VisitId": 5125890558,
  "ConsumerId": "12345",
  "SessionId": "abc1234",
  "Status": 0,
  "FailureDescription": ""
} 

Back to Top

SendMessage

Sends a message to a specified Consumer.

Method: POST 
/api/v1.0/AsyncConversation/SendMessage

Resource Properties

Request   
ParameterTypeRequiredDescription
VisitIdIntRequiredUnique identifier for the Message Conversation
MessageIdStringRequiredUnique ID assigned to the Message by ContactAtOnce
ExternalMessageIdStringRequiredUnique ID assigned to the Message by Publisher
MessageStringRequiredBody of the message to be sent
SessionIdStringRequiredUnique Id assigned to the Conversation by Publisher. If provided, will be returned in Messages posted by ContactAtOnce! to inbound message URL.

Response  
ParemeterTypeDescription
VisitIdIntUnique Id assigned to the Conversation by ContactAtOnce!
ConsumerIdStringUnique ID assigned to Consumer by Publisher.
SessionIdStringUnique Id assigned to the Conversation by Publisher
StatusIntResult of the Post. 0 = Success 1 = Failure If 1, a FailureDescription will also be provided.
FailureDescriptionStringDescription of failure used for debugging purposes

Sample Header- JSON

Authorization: Basic {YOUR_API_KEY}
Accept: version=2; 

Sample POST – JSON

{
    "VisitId":5125890558,
    "MessageId":"52369887",
    "ExternalMessageId":"5236987",
    "Message":"Do you any 3 bedroom apartments on the first floor in Bldg 3?", 
    "SessionId":"abc1234"
 }  

Sample Response- JSON
If the POST is successful, the value for Status will be 0 and the VisitId, ConsumerId & SessionId will be returned. If the POST is not successful, the values for Status will be 1 and a description of the failure will be provided.

{
  "VisitId": 54150558,
  "ConsumerId": "12345",
  "SessionId": null,
  "Status": 0,
  "FailureDescription": ""
}

Back to Top

GetConversations

Returns a list of Message Conversations with the specified Consumer.

Method: GET
/api/v1.0/AsyncConversation/GetConversations/{ConsumerID}

Request   
ParameterTypeRequiredDescription
ConsumerIdStringRequiredUnique identifier for the Consumer

Response  
ParemeterTypeDescription
ConversationsArray of AsyncConversationItemAll messages exchanged between consumer and business
ConsumerIdStringUnique ID assigned to Consumer by Publisher.
StatusIntResult of the Post. 0 = Success 1 = Failure If 1, a FailureDescription will also be provided.
FailureDescriptionStringDescription of failure used for debugging purposes

Sample Header- JSON

Authorization: Basic {YOUR_API_KEY}
Accept: version=2; 

Sample Response – JSON

{
    "Conversations": [
        {
            "AdvertiserId": "Marc",
            "AdvertiserName": "Nalley Lexus",
            "AgentName": "Jesse James",
            "SessionId": "abc123",
            "VisitId": "12272283",
            "LastMessageDateTime": "6/15/2015 4:13 PM",
            "LastMessage": "see you at 4:00",
            "Status": "0"
        }
    ],
    "Status": 0,
    "FailureDescription": null
}

Back to Top

GetTranscript

Returns the complete transcript of a specified Message Conversation.

Method: GET
/api/v1.0/AsyncConversation/GetTranscript/{VisitId)

Request   
ParameterTypeRequiredDescription
VisitIdIntRequiredUnique Id for the Conversation assigned by ContactAtOnce! at the time of original POST to AsyncMessageConversation

Response  
ParemeterTypeDescription
MessageArray of AsynConversationMessageAll messages during the conversation
NumMessagesIntTotal number of messages exchanged during conversation
TotalUnreadConsumerMessagesIntTotal number of messages that have not been read by an agent
VisitIdIntUnique Id assigned to the Conversation by ContactAtOnce!
ConsumerIdStringUnique ID assigned to Consumer by Publisher.
SessionIdStringUnique Id assigned to the Conversation by Publisher
StatusIntResult of the Post. 0 = Success 1 = Failure If 1, a FailureDescription will also be provided.
FailureDescriptionStringDescription of failure used for debugging purposes

Authorization: Basic {YOUR_API_KEY}
Accept: version=2;

Sample Response- JSON

{
    "Messages": [
        {
            "TimeStamp": "6/12/2015 10:58 PM",
            "SpeakerName": "Joe Lewis",
            "SpeakerRole": "Agent",
            "Message": "Do you like ice cream?",
            "MediaURL": ""
        },
        {
            "TimeStamp": "6/12/2015 10:59 PM",
            "SpeakerName": "Customer",
            "SpeakerRole": "Customer",
            "Message": "Yes",
            "MediaURL": ""
        },
        {
            "TimeStamp": "6/15/2015 4:13 PM",
            "SpeakerName": "Joe Lewis",
            "SpeakerRole": "Agent",
            "Message": "What is your favorite flavor?",
            "MediaURL": ""
        }
    ],
    "VisitId": 12272283,
    "ConsumerId": "1234",
    "SessionId": "abc123",
    "Status": 0,
    "FailureDescription": null
}

Back to Top

MessageStatus

The Publisher, optionally, may host a secure REST resource to receive read and delivered receipts from CAO. Message from CAO will be Application/JSON encoded HTTPS POST to
the Publisher Specified Endpoint.

Method: POST
The Publishers Specified Endpoint

Request   
ParameterTypeRequiredDescription
VisitIdIntRequiredUnique identifier for the Message Conversation
MessageIdStringRequiredUnique ID assigned to the Message by ContactAtOnce
ExternalMessageIdStringRequiredUnique ID assigned to the Message by Publisher
MessageStatusStringRequiredStatus of the message
  • 0 - Unknown
  • 1 - Delivered
  • 2 - Read
SessionIdStringRequiredUnique Id assigned to the Conversation by Publisher. If provided, will be returned in Messages posted by ContactAtOnce! to inbound message URL.

Response  
ParemeterTypeDescription
StatusIntResult of the Post. 0 = Success 1 = Failure If 1, a FailureDescription will also be provided.
FailureDescriptionStringDescription of failure used for debugging purposes

Sample Header- JSON

Authorization: Basic {YOUR_API_KEY}
Accept: version=2;

Sample POST – JSON

{
 "VisitId":"12272283",
 "ExternalMessageId":"293938293",
 "MessageId":"292020303",
 "MessageStatus":"2",
 "SessionId":"abc123"
}

Sample Response- JSON

{
 "Status": 0,
 "FailureDescription": null
}

Back to Top


Publisher Endpoints

ReceiveMessage

The Publisher is required to host a secure REST resource to receive messages from CAO. Message from CAO will be Application/JSON encoded HTTPS POST to the Publisher
Specified Endpoint.

Method: POST
The Publishers Specified Endpoint

Request   
ParameterTypeRequiredDescription
VisitIdIntRequiredUnique identifier for the Message Conversation
SessionIdIntRequiredUnique ID assigned to the Session
ConsumerIdIntRequiredUnique ID assigned to the consumer
DateTimeDateTimeRequiredDate and Time of the message in the Conversation
MessageIdIntRequiredUnique ID assigned to the Message by ContactAtOnce
MessageStringRequiredBody of the message
MediaURLStringOptionalURL to any media that may have been included in the conversation
AgentNameStringRequiredName of the Agent who answered the conversation
AgentImageUrlStringRequiredThe URL to the agent's image

Sample Header- JSON

Authorization: Basic {YOUR_API_KEY}
Accept: version=2;

Sample Message POST to Publisher Endpoint – JSON

{
"VisitId":"12617187",
"SessionId":"abc123456",
"ConsumerId":"128740954930930",
"DateTime":"2015-01-01T00:00:00 ",
"MessageId":"12345678",
"Message":"that was a long message",
"MediaURL":"https://media.cao.com/images/sbc.png"
"AgentName":"Sally Salesperson"
"AgentImageURL":"https://media.cao.com/images/sally.png"
}

Back to Top

Receive Read/Delivery Receipt

The Publisher, optionally, may host a secure REST resource to receive read and delivered receipts from CAO. Message from CAO will be Application/JSON encoded HTTPS POST to
the Publisher Specified Endpoint.

Method: POST
The Publishers Specified Endpoint

Request   
ParameterTypeRequiredDescription
VisitIdIntRequiredUnique Id assigned to the Conversation by ContactAtOnce!
ExternalMessageIdStringRequiredUnique ID assigned to the Message by Publisher
SessionIdIntRequiredUnique ID assigned to the Session by the Publisher
ConsumerIdIntRequiredUnique ID assigned to the Consumer by the Publisher
MessageIdIntRequiredUnique ID assigned to the Message by ContactAtOnce
MessageStatusStringRequiredStatus of the message
  • 0 - Unknown
  • 1 - Delivered
  • 2 - Read

Sample Header- JSON

Authorization: Basic {YOUR_API_KEY}
Accept: version=2;

Sample POST – JSON

{
"VisitId":"12617187",
"SessionId":"abc123456"
"ConsumerId":"128740954930930",
"ExternalMessageId":"29393892",
"MessageId":"987654322",
"MessageStatus":"2"
}

Back to Top