Data Store Troubleshooting: How to add but NOT update multiple records

I’m working on a team support chatbot, which will reside in Slack. My objective is to have it store historical chats for recall and context in its later replies.

When I use the ‘add or update multiple records’ Data Store, the most recent data gets added, but the data that came before that gets updated or erased.

How can I store all historical data in the Data Store for future interactions?

Hi @creatiq, the Add or Update Multiple Records depends on the object keys to determine if the record is

The records will be updated if their keys are existing. I would suggest to add a postfix like timestamp to your keys for it to always add new record

Hi @vunguyenhung, thank you very much. I know what you mean, however, I’m unclear on how to format the postfix. I’ve attached an image of my poor attempt. Would you be able to provide some clarity on how it should be formatted?

I’m using the timestamp variable (I believe): {{steps.response.$return_value.choices[0].text}}

And I’d like to keep the message ID reference: {{steps.trigger.event.client_msg_id}}
And of course the original message: {{steps.trigger.event.text}}
And response: {{steps.response.$return_value.choices[0].text}}

I deeply appreciate your assistance.

Hey @creatiq, I think we can add a new record with the key is the timestamp. For example:

1672749495348: {message: "Hello there"}
1672749495400: {message: "Hi"}

Here’s how

I added an expression in the Data prop containing the Node.js code to construct an object with the single key is the timestamp, the value is another object with the single message field that referenced from the trigger.

{{ { [Date.now()]: { message: steps.trigger.event.text } } }}

I hope this helps. If you’d like to hire a Pipedream expert for your usecase, feel free to use this link: Connect with a Pipedream Partner

Thank you very much, this was a great help! I appreciate your assistance.