Chat

Name Description Example
type "account_link" or "bot_postback" bot_postback
text Text for the button OK
payload payload for "bot_postback" button OK_PAYLOAD

Get Binder Conversations

Get the conversations in a binder identified by {binder_id}. A "all_reads" flag indicates the read status for all members in the binder if the user is the owner of the conversation.
The feed result is in reverse chronological order (starting from the latest) and in Activity Stream format, which follows the JSON specification. Schemas can be found at: JSON Schema and Activity Base Schema.

GET /{binder_id}/conversations

URL Parameters
Name Type Description
timestamp Number Optional: Feeds or updated time (if no feeds) before the specified time in milliseconds since 1/1/1970 0:0:0 with UTC.
count Number Optional: Maximum number of feeds. Default number is 100. If both "timestamp" and "until" are specified, the "count" is not used.
until Number Optional: Feeds or updated time (if no feeds) after the specified time in milliseconds since 1/1/1970 0:0:0 with UTC.
users String Optional: Filtering results with actor's (user's) Ids separated by "," for OR operation; for example, "UiaduESWsbzFoK9TOldC6zF,Utkj3YC5BxRHCCaq9widP67"

Sample Request
GET /BRTaH8slmbPAY4odz0RbBIF/conversations
Sample Response
{
    "code": "RESPONSE_SUCCESS",
    "data": {
        "feeds" : [
        {
            "id": 3463,
            "published": "2011-02-10T15:04:55Z",
            "all_reads": true,            
            "generator": {
                "id": "BRTaH8slmbPAY4odz0RbBIF"
            },
            "actor": {
                "objectType" : "person",
                "id": "Utkj3YC5BxRHCCaq9widP67",
                "image": "https://www.moxtra.com/user/234",
                "displayName": "Martin Smith"
            },
            "verb": "post",
            "object" : {
                "objectType": "comment",
                "content": "hello",
                "published": "2011-02-10T15:04:55Z",
                "updated": "2011-02-10T15:04:55Z",
                "id": "CAF829A6-F607-48E2-AA99-D081257CE78E"
            },
            "target" : {
                "url": "https://www.moxtra.com/BRTaH8slmbPAY4odz0RbBIF",
                "objectType": "binder",
                "id": "BRTaH8slmbPAY4odz0RbBIF",
                "displayName": "Martin binder",
            }
        },
        {
            "id": 3458,        
            "published": "2011-02-10T15:04:55Z",
            "all_reads": false,            
            "generator": {
                "id": "BRTaH8slmbPAY4odz0RbBIF"
            },
            "actor": {
                "objectType" : "person",
                "id": "Utkj3YC5BxRHCCaq9widP67",
                "image": "http://www.moxtra.com/user/234",
                "displayName": "Martin Smith"
            },
            "verb": "post",
            "object" : {
                "objectType": "comment",
                "content": "testing page",
                "published": "2011-02-10T15:04:55Z",
                "updated": "2011-02-10T15:04:55Z",
                "id": "CAF829A6-F607-48E2-AA99-D081257CE78E"
            },
            "target" : {
                "url": "https://www.moxtra.com/BRTaH8slmbPAY4odz0RbBIF/25",
                "objectType": "page",
                "id": "25",
                "type": "PAGE_TYPE_IMAGE"
            }
        }
        ]
    }
}

Get a Conversation

Get a particular conversation in a binder identified by {binder_id} and {feed_id}. A "all_reads" flag indicates the read status for all members in the binder if the user is the owner of the conversation. At the same time, it also shows who has read in the "read_users" array and who has not read in the "unread_users" array.

GET /{binder_id}/conversations/{feed_id}

Sample Request
GET /BRTaH8slmbPAY4odz0RbBIF/conversations/3458
Sample Response
{
    "code": "RESPONSE_SUCCESS",
    "data": {
        "read_users": [
            {
                "id": "Utkj3YC5BxRHCCaq9widP67",
                "name": "Martin Smith",
                "last_access_time": "2018-01-09T01:01:48Z"                
            },
            {
                "id": "CULrwxxTWWQSK8MOjG0PaWrB",
                "name": "Frank Jose",
                "last_access_time": "2018-01-02T09:50:16Z"                
            }
        ],
        "unread_users": [
            {
                "id": "Ua9hIj1Bi33F3bxq5yQ4gCH",
                "name": "James Wang"
            },
            {
                "id": "CUyj5Dl0CoxT1VZdMxpLpqA5",
                "name": "Jessica Lawrance",
            }
        ],        
        "feed": {
            "id": 3458,
            "published": "2011-02-10T15:04:55Z",
            "all_reads": false,
            "generator": {
                "id": "BRTaH8slmbPAY4odz0RbBIF"
            },
            "actor": {
                "objectType" : "person",
                "id": "Utkj3YC5BxRHCCaq9widP67",
                "image": "http://www.moxtra.com/user/234",
                "displayName": "Martin Smith"
            },
            "verb": "post",
            "object" : {
                "objectType": "comment",
                "content": "testing page",
                "published": "2011-02-10T15:04:55Z",
                "updated": "2011-02-10T15:04:55Z",
                "id": "CAF829A6-F607-48E2-AA99-D081257CE78E"
            },
            "target" : {
                "url": "https://www.moxtra.com/BRTaH8slmbPAY4odz0RbBIF/25",
                "objectType": "page",
                "id": "25",
                "type": "PAGE_TYPE_IMAGE"
            }
        }
    }
}

Add Comment to Binder Chat

Add a comment to a binder chat identified by {binder_id}.

POST /{binder_id}/comments

JSON Parameters
Name Type Description
text String Message in binder chat.
richtext String Optional: provide Message in BBCode style. While setting richtext, please also set text message for Feed to use.
Sample Request
POST /B7V4ze37oO08PYO70973lX6/comments
{
    "text": "This is a test message"
}
Sample Response
{
    "code": "RESPONSE_SUCCESS",
    "data": {
        "comment_id": 9
    }            
}

Delete Comment in Binder Chat

Delete a comment in binder chat identified by {binder_id} & {comment_id}.

DELETE /{binder_id}/comments/{comment_id}

Sample Request
DELETE /B7V4ze37oO08PYO70973lX6/comments/24
Sample Response
{
    "code": "RESPONSE_SUCCESS"
}

Upload Audio Comment to Binder Chat

Upload an audio comment to a binder chat identified by {binder_id} via multipart/form-data.

POST /{binder_id}/audiocomments

Multipart/form-data Parameters
Name Type Description
audio audio file (audio/x-m4a, audio/mp3, audio/aac) Actual audio file that is uploaded to the binder.

Sample Request
POST /B9rArkzRe094lPPiMH4UpS8/audiocomments
...
Content-Type: multipart/form-data; boundary=---------------------------9051914041544843365972754266
Content-Length: 554

-----------------------------9051914041544843365972754266
Content-Disposition: form-data; name="audio"; filename="comment.m4a"
Content-Type: audio/m4a

Content of comment.m4a
Sample Response
{
    "code": "RESPONSE_SUCCESS",
    "data": {
        "comment_id": 10
    }            
}

Post Structured Message to Binder

To post a message to a binder. Messages can be a file, an audio file, and various text inputs in application/json or inside a multipart/form-data Content-Type.
It can be posted to "chat", "page", or "todo". Buttons are only available for Bot application.

POST /{binder_id}/messages

The structured message has the following format:

{ 
    "message": {
	"text": "simple text message",
	"richtext": "text message in BBCode style",
	"fields": {  
	    "key1": "value1",
	    "key2": "value2",
	    ...
	},
	"action": "chat", "page", or "todo",
	"buttons": [  	
	    {
	    	"type": "account_link",
	    	"text": "TEXT"
	    },	
	    {
	    	"type": "bot_postback",
	    	"text": "TEXT",
	    	"payload": "PAYLOAD"	    	
	    }
	]
    },
    "fields_template": [    
	{	
	    "template_type": "text", "richtext", or "page",
	    "template": "Template For Fields"
	},
	...
    ] 
  }

JSON Parameters
Name Type Description
text (in message) String Plain text message.
richtext (in message) String Text message in BBCode style.
fields (in message) JSON Key-value pairs in JSON.
action (in message) String Optional: on-demand target action for "chat", "page", or "todo".
buttons (in message) Array Buttons array.
type (in buttons array) String "account_link" or "bot_postback".
text (in buttons array) String Text for the button.
payload (in buttons array) JSON or String Optional: payload for "bot_postback" button.
template_type (in fields_template) String Optional for fields: on-demand template for "text", "richtext", or "page".
template (in fields_template) String Optional for fields: template for rendering key-value pairs.

Sample Request
POST /B9rArkzRe094lPPiMH4UpS8/messages
{
    "message": {
    	"text": "@Anu Test LN do you need to schedule a meet?",
    	"buttons": [{
	    "type": "account_link",
	    "text": "Sign In"
	}, {
	    "type": "postback",
	    "text": "Not Sure?",
	    "payload": "MOXTRABOT_NOT SURE?"
	}]    
    }
}

Sample Request with RichText
POST /messages
{
    "message": {
	"richtext": "[table][tr][th][center]BBCode Info[/center][/th][/tr][tr][td][img=50x25]https://www.bbcode.org/images/lubeck_small.jpg[/img][/td][/tr][tr][td]From: [i]Anu Test LN[/i][/td][/tr][tr][td][color=Red]yes[/color][/td][/tr][/table]"
    }
}

  • Upload file and add audio comment with Content-Type: multipart/form-data and set parameters as follows:

    • payload - Optional the JSON message as before-mentioned

    • file - Optional the file that is getting uploaded into the binder, for example

      ...
      Content-Type: multipart/form-data; boundary=---------------------------9051914041544843365972754266
      Content-Length: 3234
      
      -----------------------------9051914041544843365972754266
      Content-Disposition: form-data; name="file"; filename="start.png"
      Content-Type: image/png
      
      Content of start.png
      
    • audio - Optional the audio file (audio/x-m4a, audio/mp3, audio/aac) for audio comment that is getting uploaded into the binder, for example

      ...
      Content-Type: multipart/form-data; boundary=---------------------------9051914041544843365972754266
      Content-Length: 4568
      
      -----------------------------9051914041544843365972754266
      Content-Disposition: form-data; name="audio"; filename="test_comment.m4a"
      Content-Type: audio/m4a
      
      Content of test_comment.m4a
      

Sample Response
{
    "code": "RESPONSE_SUCCESS",
    "data": {
        "comment_id": 9
    }            
}

Post Structured Message to User

To post a message to a user in the same org into the one-on-one binder between the sender and the receiver.

  • If the one-one-one binder does not exist, a new binder gets created and the message is posted there. Messages can be a file, an audio file, and various text inputs in application/json or inside a multipart/form-data Content-Type as payload. However, this payload is a required field.
  • It can be posted to "chat", "page", or "todo". Buttons are only available for Bot application. Sample requests can be found on Post Structured Message to Binder.

POST /{user_id}/messages

The structured message has the following format:

{
    "user": {	
	"user_id": "user ID",
	"email": "user Email",
	"unique_id": "user unique ID"
    },
    "message": {
	"text": "simple text message",
	"richtext": "text message in BBCode style",
	"fields": {  
	    "key1": "value1",
	    "key2": "value2",
	    ...
	},
	"action": "chat", "page", or "todo",
	"buttons": [  	
	    {
	    	"type": "account_link",
	    	"text": "TEXT"
	    },	
	    {
	    	"type": "postback",
	    	"text": "TEXT",
	    	"payload": "PAYLOAD"	    	
	    }
	]
    },
    "fields_template": [    
	{	
	    "template_type": "text", "richtext", or "page",
	    "template": "Template For Fields"
	},
	...
    ] 
  }

JSON Parameters
Name Type Description
user_id (in user) String user's id, one of user_id/email/unique_id required
email (in user) String user's email, one of user_id/email/unique_id required
unique_id (in user) String user's unique_id, one of user_id/email/unique_id required
text (in message) String Plain text message.
richtext (in message) String Text message in BBCode style.
fields (in message) JSON Key-value pairs in JSON.
action (in message) String Optional: on-demand target action for "chat", "page", or "todo".
buttons (in message) Array Buttons array.
type (in buttons array) String "account_link" or "postback".
text (in buttons array) String Text for the button.
payload (in buttons array) JSON or String Optional: payload for "postback" button.
template_type (in fields_template) String Optional for fields: on-demand template for "text", "richtext", or "page".
template (in fields_template) String Optional for fields: template for rendering key-value pairs.
Sample Request
POST /me/messages
{   
    "user": {
        "email": "test_mail@test.com"    
    },
    "message": {
        "text": "this is the message content send to user directly"
    }
}
Sample Response
{
    "code": "RESPONSE_SUCCESS",
    "data": {
        "binder_id": "BRTaH8slmbPAY4odz0RbBIF",
        "result": {
          "comment_id": 2702
        }
    }             
}

Reply Message

Post reply message to a component in the binder.

  • The reply_to is to target the message to a component, which can be "comment", "file", "page", "page position_comment", "signature file", "transaction", or "meet".
  • Only one component in reply_to can be set at one time. If no reply_to is specified, a new binder message is generated.

POST /{binder_id}/messages

The structured message has the following formats:

  • Target to a binder comment

    {
        "reply_to": {
          "binder": {
            "comment_id": 2702
          }
        },
        "message": {
          "text": "new message replied by rest api"
        }
      }
  • Target to a page

    {
        "reply_to": {
          "page": {
            "id": 1574
          }
        },
        "message": {
          "text": "new message replied by rest api"
        }
      }
  • Target to a page position_comment

    {
        "reply_to": {
          "page": {
            "id": 1574,
            "position_comment_id": 1614
          }
        },
        "message": {
          "text": "new message replied by rest api"
        }
      }
  • Target to a file

    {
        "reply_to": {
          "file": {
            "id": "4ca6d8f5-923f-4e89-80b3-10575f6652d6"
          }
        },
        "message": {
          "text": "new message replied by rest api"
        }
      }
  • Target to a signature file

    {
        "reply_to": {
          "signature": {
            "id": 31
          }
        },
        "message": {
          "text": "new message replied by rest api"
        }
      }
  • Target to a transaction

    {
        "reply_to": {
          "transaction": {
            "id": 55
          }
        },
        "message": {
          "text": "new message replied by rest api"
        }
      }
  • Target to a meet

    {
        "reply_to": {
          "meet": {
            "session_key": 863276237
          }
        },
        "message": {
          "text": "new message replied by rest api"
        }
      }

JSON Parameters
Name Type Description
reply_to Object Target component: "comment", "file", "page", "page position_comment", "signature file", "transaction", or "meet"
comment_id (in binder) Number Binder comment id
id (in page) Number Page id
position_comment_id (in page) Number Page position_comment id
id (in file) String File id
id (in signature) Number Signature id
id (in transaction) Number Transaction id
session_key (in meet) String Session key of meet
text (in message) String Text for the reply content
richtext (in message) String Text message in BBCode style.
fields (in message) JSON Key-value pairs in JSON.
buttons (in message) Array Buttons array.
type (in buttons array) String "account_link" or "postback".
text (in buttons array) String Text for the button.
payload (in buttons array) JSON or String Optional: payload for "postback" button.
template_type (in fields_template) String Optional for fields: on-demand template for "text", "richtext", or "page".
template (in fields_template) String Optional for fields: template for rendering key-value pairs.
Sample Request
POST /CBqXD6E6oLFCKd8fZjTNstGC/messages
{
    "reply_to": {
        "page": {
            "id": 1574
        }
    },
    "message": {
        "text": "new comment add by rest api"
    }
}
Sample Response
{
    "code": "RESPONSE_SUCCESS",
    "data": {
        "page_comment_id": 2107
    }
}
  • Reply with upload file and add audio with Content-Type: multipart/form-data and set parameters as follows:

    • payload - JSON message as before-mentioned, base objects "meet" and "page comment" are not supported.

    • file - Optional the file that is getting uploaded into the binder, for example

      ...
      Content-Type: multipart/form-data; boundary=---------------------------9051914041544843365972754266
      Content-Length: 3234
      
      -----------------------------9051914041544843365972754266
      Content-Disposition: form-data; name="file"; filename="start.png"
      Content-Type: image/png
      
      Content of start.png
      
    • audio - Optional the audio file (audio/x-m4a, audio/mp3, audio/aac) for audio comment that is getting uploaded into the binder, for example

      ...
      Content-Type: multipart/form-data; boundary=---------------------------9051914041544843365972754266
      Content-Length: 4568
      
      -----------------------------9051914041544843365972754266
      Content-Disposition: form-data; name="audio"; filename="test_comment.m4a"
      Content-Type: audio/m4a
      
      Content of test_comment.m4a