cancel
Showing results for 
Search instead for 
Did you mean: 

MongoDB in Conversational AI

bsdhillon
Explorer
0 Kudos

hi

I have a webchat up and running, I would like to check if all the messages received and sent are stored in Mongo DB like its shown here https://github.com/yemanaung/bot-connector ?

if they are can we access them ?

thanks

Dhillon

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member437448
Discoverer

Hi Dhillon,

if you use the webchat with SAP Conversational AI, we store the messages as well. You can retrieve them as follows:

  1. Authenticate all following API calls by using the developer token of your bot or version and setting the `Authorization` header to `Token {developer_token}`.
    further information: https://cai.tools.sap/docs/api-reference/#authentication
  2. Retrieve a list of conversations by making a GET request to https://api.cai.tools.sap/connect/v1/conversations
    API documentation: https://cai.tools.sap/docs/api-reference/#indexing-conversations
  3. Using the IDs of the conversations retrieved in the previous request, you can fetch the details for the specific conversations, including the messages.
    This can be done with a GET request to https://api.cai.tools.sap/connect/v1/conversations/${CONVERSATION_ID} (replacing ${CONVERSATION_ID} with the actual ID.
    API documentation: https://cai.tools.sap/docs/api-reference/#showing-a-conversation

Accessing the database is not possible.

If you are interested in the users' messages only (without the response of your bot), you can also have a look at the log feed by using the Monitor tab or the Logs API endpoint.

Through the API the logs can be retrieved with a GET request to https://api.cai.tools.sap/train/v2/users/${USER_SLUG}/bots/${BOT_SLUG}/logs (you have to replace ${USER_SLUG} with your actual user slug or the organization slug (if the bot belongs to an organization) and ${BOT_SLUG} with the bot slug). You can find the documentation for that at https://cai.tools.sap/docs/api-reference/#indexing-bot-logs.

Thanks for the detailed answer, Rene. I'd like to add that this applies if you use the bot connector hosted by SAP Conversational AI (which is the default). You also have the possibility to host your own instance of the bot connector (the official repository is here: https://github.com/SAPConversationalAI/bot-connector). In this case, you would connect your own Mongo DB and obviously have access to its data.