Chatbot Passthrough Message Callback
Feature Overview
The app backend can use this callback to receive custom message callbacks from the chatbot. It can then respond to these callbacks by sending customized message content back to the chatbot.
Notes
To activate this callback feature, it's essential to set up the callback URL and enable the specific switch for this callback. Detailed instructions on this setup can be found in the 'Third-Party Callback Configuration.
The callback operates in a manner where the Instant Messaging (IM) backend initiates an HTTPS POST request towards the App backend.
Upon receiving a callback request, the app backend is obligated to validate that the SDKAppID parameter in the request URL matches its own SDKAppID.
For additional information on security-related issues, please consult the 'Introduction to Third-Party Callbacks: Security Considerations' document.
Callback Trigger Scenarios
When App sends a "Customized Pass-Through Content" to chatbot.
Callback Trigger Time
When App sends a "Customized Pass-Through Content" to chatbot.
API Description
Sample Request URL
In the subsequent example, the callback URL configured within the app is
https://www.example.com
.
Example:https://www.example.com?SdkAppid=$SDKAppID&CallbackCommand=$CallbackCommand&contenttype=json&ClientIP=$ClientIP&OptPlatform=$OptPlatform
Request Parameters
Parameter | Description |
https | The request protocol is HTTPS, and the request method is POST |
www.example.com | Callback URL |
SdkAppid | SDKAppID allocated by the Instant Messaging console at the time of Application creation |
CallbackCommand | Fixed to Chatbot.OnC2CSignalMessage |
contenttype | Fixed value: JSON |
ClientIP | Client IP, such as 127.0.0.1 |
OptPlatform | Client platform, for values refer to Third-party callback introduction: Callback protocol with regards to the parameter meanings of OptPlatform |
Sample Request
{"CallbackCommand": "Chatbot.OnC2CSignalMessage","From_Account": "user01","To_Account": "@RBT#chatbot","MsgSeq": 5678,"MsgRandom": 8765,"MsgKey": "8765_5678_4321","EventTime": 1670574414123,"Data": "{\"msg\":\"This is a user-defined passthrough content\"}"}
Request Fields
Field | Type | Description |
CallbackCommand | String | Callback command |
From_Account | String | Message Sender UserID |
To_Account | String | Recipient's UserID |
MsgSeq | Integer | Message serial number, utilized for marking the respective message (32-bit unsigned integer) |
MsgRandom | Integer | Random message number, used to mark this message (32-bit unsigned integer) |
MsgKey | String | Unique identifier of this message, allowing for Recalling of One-to-One Messages via REST API based on this identifier |
EventTime | Integer | Event trigger timestamp in milliseconds |
Data | String | "SelfDefinition pass-through content" from data field in the protocol |
Sample Response
Following data synchronization, the app backend dispatches a callback response packet.
{"ActionStatus": "OK","ErrorInfo": "","ErrorCode": 0,"RspData": "{\"msg\":\"This is the self-definition pass-through content reply to the robot\"}"}
Response Fields
Field | Type | Attribute | Description |
ActionStatus | String | Mandatory | Processed Request Result: OK Signifies Successful Handling FAILURE signifies unsuccessful execution |
ErrorCode | Integer | Mandatory | Error Identifier: A `0` indicates processing was successful, and the `RspData` is returned to the intelligent robot A `1` indicates processing failure, and `RspData` is ignored |
ErrorInfo | String | Mandatory | Error message |
RspData | String | Mandatory | Response to the AI robot with custom pass-through content |
Reference
REST API:Sending One-to-One Messages Individually