Skip to main content
Solved

Plugin SDK: context.conversation getting updated_at

  • March 5, 2025
  • 3 replies
  • 140 views

NPdevs
Forum|alt.badge.img+2

Is it possible to get a conversation’s updated_at datetime from the Plugin SDK?

Best answer by jason

The context event should only send once on a context change. Is it possible you’re experiencing something like this → sentry.io/answers/react-useeffect-running-twice ?

Something you could do to help cache data is generating an md5 hash of the context.conversation object to use as a cache key; this can allow you to cache your external API result based on a given conversation state.
Depending on what data you send to your API, you may need to include other Front conversation data in that cache key generation step, such as the latest message ( via Front.listMessages() ) etc. 

3 replies

jason
Forum|alt.badge.img+8
  • Fronteer
  • March 5, 2025

No, that’s not currently exposed via the Plugin SDK (Feel free to share a feature suggestion if you would like to see this data added)

What is it you’re trying to learn about the conversation from it’s updated_at timestamp?


NPdevs
Forum|alt.badge.img+2
  • Author
  • Helper
  • March 6, 2025

The aim is to determine if the conversation has changed, since contextUpdates will trigger twice on conversation change. But also in order to be able to cache some elements without having to reacquire them on conversation revisit.

Perhaps there is another way determine if the context.conversation has changed?

Front.contextUpdates.subscribe(async (context) => {
    switch(context.type) {
        case 'singleConversation':
            console.log('singleConversation will trigger twice on conversation change');
            break;
    }
});

 


jason
Forum|alt.badge.img+8
  • Fronteer
  • Answer
  • March 6, 2025

The context event should only send once on a context change. Is it possible you’re experiencing something like this → sentry.io/answers/react-useeffect-running-twice ?

Something you could do to help cache data is generating an md5 hash of the context.conversation object to use as a cache key; this can allow you to cache your external API result based on a given conversation state.
Depending on what data you send to your API, you may need to include other Front conversation data in that cache key generation step, such as the latest message ( via Front.listMessages() ) etc.