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:

  1. Configure the public and private keys in the IBM RPA Control Center.
  2. Make an API request.
  3. 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.

Important:Configure the public and private keys must before putting the robot into production.

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 the ConversationId property of the Chat 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>
Important:Starting from version 23.0.16, the data contained in the 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 note 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.

  1. Use the Convert Base64 to Text (base64ToText) command, with the OS default encoding option to convert the returned message in Base64 format to text.
  2. 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
  3. Use the Create RSA Cipher (cipherRsa) command, choose the decrypt mode and enter the private key together with the public key registered in the IBM RPA Control Center.
  4. Use Decrypt (decrypt) command in the message. This command generates a new list, but with the message bytes decrypted.
  5. 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.