To sync a message with a specific chat session, please use the standard “message“ method with the sessionid
parameter:
{ "method": "message", "params":{ "from": "9003", "to": "234567668", "content": "Hello", "orgid": "17076444409917912922", "sessionid": "1710004869211-d3103a34bd2ce6023a" } }
{ "result": { "messageid": "1710100373597-8b065154afbbddfb96" } }
sessionid
refers to the existing chat session, which you receive as a response from the API server once a chat has been created.
A new “sessionid“ will be returned if a message is sent to a session which is already closed.
In addition, you can implicitly create a chat session for other users (if you need to sync messages with the users who don't have a chat session with an external number yet) by sending a message
method without the content
and sessionid
parameters.
Specify the external contact number in the from
parameter and user’s extension number (for whom a chat session will be created) or an SMS number (DID) added via SMS integration in the to
field:
{ "method": "message", "params":{ "from": "234567668", "to": "9004", "orgid": "17076444409917912922" } }
{ "result": { "sessionid": "1710098613465-02d8b0a8b078cf73e5" } }
Now you can use the provided 'sessionid' in the follow-up API request to sync the message with the user's chat session:
{ "method": "message", "params":{ "from": "9003", "to": "234567668", "content": "Hello", "orgid": "17076444409917912922", "sessionid": "1710098613465-02d8b0a8b078cf73e5" } }
Alternatively, instead of content
you can specify the messageid
parameter, which is particularly useful for syncing files:
{ "method": "message", "params":{ "from": "9003", "to": "234567668", "orgid": "17076444409917912922", "messageid": "1710100665847-a1f4a223ffd202a9ea", "sessionid": "1710098613465-02d8b0a8b078cf73e5" } }