Best answer

How to get ChatGPT to keep the same memory in a Slack thread?

  • 23 October 2023
  • 5 replies
  • 243 views

Userlevel 1

I successfully created a ChatGPT Slack bot that responds in as a thread reply to the prompt sent in a specific Slack channel. I’d like ChatGPT to store memory of all messages in that Slack thread so a user can reply in the thread to continue the conversation from the original prompt. What do I add in the Memory Key Field of the Zap to allow the same ChatGPT thread to continue in the Slack thread? I tried using Ts. from the original Slack message but that doesn’t seem to work (see screenshot).

icon

Best answer by SamB 1 November 2023, 11:39

View original

5 replies

Userlevel 7
Badge +11

Hey @ClareDM, welcome to the Community! 👋

Hmm, I wonder if it’s not working because the Ts value selected is the timestamp of the new reply, not the original message that started the thread (parent). In that Memory Key field can you try selecting the Thread Ts field instead? For example:

d75155c48658d2625ce80c332979303d.png

I’m thinking that Thread Ts field should contain the timestamp for the original message and not the timestamp for the reply in the thread that’s triggering the Zap. 

Can you give that a try and let us know if that works as hoped?

Userlevel 1

Hi @SamB thanks for jumping in to help! How would I set this so it contains the original message for each new instance? I want the Zap to work in a way such that a new Slack message in the channel would be the start of a new “thread” with the Slackbot so the user could continue the conversation with the bot in the thread and if they want to start a new topic, they’d simply send a new message in the channel (and not reply in the thread). 

 

When I go the Memory Key field the only option is to add the Thread Ts for the message that triggered the Zap. Do I need to structure the entire Zap differently to work as I described above?

 

Pasting a screenshot of the entire Zap here too so you can see bigger picture. Thanks for your help 🙏

Userlevel 7
Badge +11

You’re welcome @ClareDM! 🤗

Ah I see! Ok, well in that case I think you might want to look at using Paths by Zapier to handle the two situations. I say this as I did some checking and it seems that while the sample data will show a Thread Ts field present for messages that a thread would be created from, when the Zap runs that field would not be present. 

So I think you’d want two paths. One that checks if that the Thread Ts field Does not exists (meaning it’s a non-threaded message). And another that checks that the Thread Ts field does Exist (Meaning it’s a reply in an existing thread). For example:
9e80897b791b62dc238be57bca6104f8.png

Then in the ChatGPT action on the first Path (Thread Ts field Does not exists) you’d set the Memory Key to be the Ts field:
37c213a6816cf1ba90706edf4590df7d.png
And in the subsequent Slack action that posts ChatGPT’s response you’d set the Thread field to use the Ts field from the Slack trigger:
6ba70681e96d7e6d9ed8d1f3c1565b7b.png

Next, in the ChatGPT action on the second Path (Thread Ts field Exists) you’d set the Memory Key to be the Thread Ts field:
785e7037b71dd851945f45883b1fc01d.png
And in the Slack action that posts ChatGPT’s response for that path you’d set the Thread field to use the Thread Ts field from the Slack trigger:
03a7f78a0a32de7090c4e7f1dffc8646.png
This should ensure that the Zap will only run the first path for new messages posted in the channel. And the second path will only run for replies in a thread and should allow ChatGPT to reference the past conversation of the thread.

VERY IMPORTANT: Make sure you set the trigger for the Zap to not trigger on new bot messages:
2a8271e8b92d1cad79c13f6032e10f0d.png
Otherwise the messages sent by the Zap will also trigger the Zap and cause an infinite Zap Loop! If the Slack messages aren’t being sent by the Zap as a bot then you’ll need to add a filter after the trigger to ensure the Zap doesn’t run for ChatGPT’s responses.


Hope that helps to get you pointed in the right direction. Let me know if you run into any issues setting that up or have any questions at all. Happy to help further! 🙂

Userlevel 1

Hi Sam,

 

Thanks so much for the detailed support! I was able to set this up successfully with a slightly different version than you suggested. I added a Formatter step to set a default value. I used the thread_ts value for it, and if there is no thread_ts value available for this message, I set it to use the ts value. 


Best,

Clare

Userlevel 7
Badge +11

Glad I could help @ClareDM. Ooh that’s an even better idea, awesome work on that! 🙌 🎉

Seems like you’re all squared away for now, but please do reach out to the Community again if you need any further help at all - always happy to assist! 😁

Reply