Updated on 2025-03-31 GMT+08:00

API Invocation Process

This section describes the process of invoking APIs for a text chat between a customer and an agent. Detailed procedure and API description help developers understand how to use the AICC APIs to implement seamless text chat between customers and agents. The following is the entire process of multimedia chat.

Figure 1 Multimedia chat
Figure 2 Multimedia chat ended

1. Invoke the third-party request authentication API applyToken to generate token information for client access. The token corresponds to the ccmessaging-token field in the request headers of other APIs.

2. After obtaining the API request authentication token, you can choose whether to display the historical messages of the customer. If you want to display the messages, invoke the queryHistoryChatMessage API to query historical messages.

3. To have a multimedia chat with an agent in the AICC, a connection to the agent needs to be established first. Invoke the send or sendAsync API to send a CONNECT message (that is, the value of the controlType field in the request body is CONNECT) to request to connect to an agent or a robot.

The send API is a synchronous API, and the sendAsync API is an asynchronous API. The functions of the two APIs are the same. Asynchronous message processing can reduce the request duration.

4. If the connection fails to be set up, the customer can leave a message to the agent. The doLeaveMessage API is invoked to send the message to the AICC for processing. After the message is sent, the session ends.

5. If the connection is successfully set up, the poll API needs to be actively polled to obtain messages sent by the agent. During a session, if the poll API is not invoked in the default session duration configured on the CCUCS, the session is automatically released.

6. The poll API is invoked to obtain messages sent by the agent. If the messages are multimedia messages (pictures, voices, and videos), the downloadFileStream API needs to be invoked to obtain multimedia resources.

7. After the connection to the agent is successfully set up, the queryQueueInfo API needs to be invoked to check whether the current customer is in the queuing status. If yes, the customer needs to wait. The queryQueueInfo API is continuously invoked to check whether the customer is in the queuing status.

8. If the customer is not in the queuing status, the customer can chat with the agent or robot.

9. During the session, the queryPhraseByKeyword API can be invoked to query associated common phrases based on the content entered by the customer. This step is optional.

10. If the message sent by the customer is a multimedia message, the uploadFileStream API needs to be invoked to upload the corresponding multimedia file to the file server.

11. The send or sendAsync API needs to be invoked to send both multimedia and text messages to the agent.

12. After the conversation between the customer and agent ends, the getSatisfactionSurveyMode API is invoked to query the satisfaction survey configuration item.

13. If the satisfaction survey function is not configured for the current channel, the send or sendAsync API is invoked to send a disconnection message (the value of the controlType field in the request body is IDSCONNECT). Then, the session ends.

14. If the satisfaction survey function is configured for the channel and the customer is connected to an agent, the saveSatisfaction API is invoked to submit the satisfaction evaluation on the agent and send a disconnection message.

15. If the satisfaction survey function is configured for the channel and the customer is connected to the robot, the feedbacksatisfaction API is invoked to submit the satisfaction evaluation on the robot and send a disconnection message.