Saving of data in BigFix AEX’s Database

As the user chats with BigFix AEX, a record/JSON document of the chat is maintained in IBM Cloudant database. For some use cases, it is a requirement to save use case specific data in this database in the corresponding chat record/JSON document. For example, there may be a need to store the category of the use case (HR, Legal, Finance, etc.) or the ticket number of the ticket created in the ITSM software by the use case. In most cases, this need arises for the purpose of creating custom reports.

During a prolonged conversation session with BigFix AEX where the user asks multiple questions one after the other, it is important to understand the boundaries of chat. Typically, a conversation session will be made up of multiple chats. Each time the conversation hits the _RES_CONFIRM_RESOLUTION_ Node in Watson Assistant, and the user selects Yes/No/Maybe (using Mouse Click only), BigFix AEX stops writing that chat record/JSON document for the user and all the later chat goes into the next chat record/JSON document.

Before this end point of a chat, if user wants to save any data to the database (for reports/ or any other purpose), he can use message_save variable. This is an application parameter that can be used from both Watson and OpenWhisk.

Sample Code for Watson:

For example, we need to save a use case's category for reports. This is to be saved as a context variable named one_time_options as soon as the relevant use case hits (In order to save the category of the use case).

"context": {
"one_time_options": {"message_save":{"category":"HR"}}
}
In the Cloudant DatabaseDatabase, category will be the name of the field in which the value "HR" is saved.
Same can be used as profile variable from OpenWhiskOpenWhisk or Rule.
If you need to store a variable in the chat record/JSON document even past the chat end point (_RES_CONFIRM_RESOLUTION_ node), you can do that using the “question_update” parameterparameter.
Sample:
(In openwhisk function, add this to the resolve object)
rule_app_params: {
"question_update": {
"ticket_number": response_body.ticket_number
}
}