Accessing chat history on the server
Lean how you can access the chat history on the server.
About this task
Choose the Server mode to store the chat history, all messages are encrypted according to the public key that was registered in Tenant.
To get the message chat history that you need:
- Configure the public and private keys in the IBM RPA Control Center.
- Make an API request.
- Decrypt the messages.
Before you begin
You need configure the public and private keys in the IBM RPA Control Center to be able to decode the messages stored on the server. For details on creating and configuring keys in the IBM RPA Control Center, see Generating keys.
Procedure
Make the request in the API
Chat is available for IBM RPA on premises and IBM RPA SaaS versions, see how you can get chat message history in both offerings.
For the SaaS version, use the URL:
https://${region}api.rpa.ibm.com/v1.0/{language}/bot-history/${conversationID}?apiKey=${apiKey}
For IBM RPA on premises, use the URL:
https://${API_URL}/v1.0/{language}/bot-history/${conversationID}?apiKey=${apiKey}
Where:
-
${region}
Tenant region where the history was stored. -
{language}
Message language. -
{conversationID}
Variable containing the ID of the bot conversation with the user. Use theConversationId
property of theChat Data
variable, returned in the Chat (=chat
) output parameter of the Connect to Chatbot (botConnect
). -
${apiKey}
The key corresponds to the tenant ID.
If the API request is successful, you have the response in the following XML structure:
<ArrayOfBotMessageModel xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://automation.wdg.com/services/2016/07/01">
<BotMessageModel>
<Date>2021-02-22T23:19:09.8</Date>
<Message>gcNZi4HtMnob1hAfrBnF7ycDrcust0Vv1bxoYlYCkhOg1nM3WVIFOoBQ8j7kfj8071bv4hVFRKlY75ckhYo4VIrKt08x6wqlhky1UkCR8HKK5R1lI1VY4zI6jOGUe9aug8iKlcHg0X4pSHdG05nzFK4XzcryGKkr4hY5388vLdCBJ=</Message>
<Role>bot</Role>
<Sender>BOT</Sender>
</BotMessageModel>
<BotMessageModel>
<Date>2021-02-22T23:19:10.177</Date>
<Message>gcNZi4HtMnob1hAfrBnF7ycDrcust0Vv1bxoYlYCkhOg1nM3WVIFOoBQ8j7kfj8071bv4hVFRKlY75ckhYo4VIrKt08x6wqlhky1UkCR8HKK5R1lI1VY4zI6jOGUe9aug8iKlcHg0X4pSHdG05nzFK4XzcryGKkr4hY5388vLdCB=</Message>
<Role>user</Role>
<Sender>GCIo8rGhXwhFCAPmaobtVw==</Sender>
</BotMessageModel>
</ArrayOfBotMessageModel>
Sender
tag is now encrypted.If the API request is not successful, you have the response in the following XML structure:
<WdgErrorModel xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/WDG.Automation.Api">
<ErrorMessage>Could not find a history for ${conversationID} using apiKey ${apiKey}</ErrorMessage>
<ModelState xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" i:nil="true"/>
</WdgErrorModel>
Important:
-
The error message language is the same as the chat message history language
-
Running the bot in debug mode does not store the chat message history on the server. Only those in production can use this feature. Details about the chat history in "Local" mode in Chat History.
Decrypt messages from chat history
The chat history messages are stored on the server is obtained in Base64
format, see how to get messages in text format-allowing reading.
- Use the Convert Base64 to Text (
base64ToText
) command, with the OS default encoding option to convert the returned message inBase64
format to text. - Use the Convert Bytes to Text (
textToBytes
) command, with the default OS encoding option to convert message text to bytes. This operation is necessary as the decryption of the message requires that it be in a list of bytes - Use the Create RSA Cipher (
cipherRsa
) command, choose thedecrypt
mode and enter theprivate key
together with thepublic key
registered in the IBM RPA Control Center. - Use Decrypt (
decrypt
) command in the message. This command generates a new list, but with the message bytes decrypted. - Use the Convert Bytes to Text (
bytesToText
) to convert the list of bytes to text to get the original message from the interaction between robot and user.
After decrypting the messages, you can access the chat history messages.