Skip to main content
Question

How to split 'Retrieve Thread Messages' into individual messages?


Hi all

 

I am building a workflow which creates tickets in Jira from Slack threads. I would like to include in the ticket the full thread, but the ‘Retrieve Thread Messages’ function includes text as a single block with no differentiation between messages.

If I split the messages by comma using formatter, it will split any message where the user has used a comma, so I am looking for an alternative. Ideally, I would also include the username of the person who sent each message. 

 

Does anyone know how I can do this? I.e.

  1. Split thread into individual messages other than by comma?
  2. Include the username of the person who sent each message in the thread?

Thanks in advance!

Did this topic help you find an answer to your question?

3 replies

Sebastian M
Forum|alt.badge.img
  • Zapier Staff
  • 29 replies
  • January 10, 2025

Hi ​@CallumH, welcome to the Zapier Community👋

 

I believe this could be accomplished by using an AI tool such as our AI by Zapier tool.

 

Here is a rough prompt that could be used:

“You are processing a Slack thread retrieved from the "Retrieve Thread Messages" action in Zapier. Your task is to transform the thread into a format that includes each message along with the username of the sender.

 

Input: 
1. Thread messages, where each message includes the sender's username and the message text. Example:
[
  {"username": "Alice", "text": "This is the first message."},
  {"username": "Bob", "text": "This is the second message, with a comma."},
  {"username": "Alice", "text": "Another message from Alice."}
]

Output:
A formatted string that lists each username and their corresponding message on a new line, preserving commas within the message text. The format should be:
[username1]: Message 1
[username2]: Message 2

Example output for the above input:
Alice: This is the first message.
Bob: This is the second message, with a comma.
Alice: Another message from Alice.

Ensure:
- Each message is clearly associated with the correct username.
- Commas within messages are preserved.

Process the provided input and return the formatted output.”

 

This likely will need to be adjusted according to your particular workflow, but our Prompt Builder tool should help move you forward!

 

Hope this helps😊


  • Author
  • New
  • 1 reply
  • January 10, 2025

Thanks ​@Sebastian M That’s really helpful. If possible, we’d prefer not to use AI here due to (i) the cost; and (ii) there may be some sensitive information which we are not willing to share with a third party AI tool.


SamB
Community Manager
Forum|alt.badge.img+11
  • Community Manager
  • 7396 replies
  • January 13, 2025

Hey ​@CallumH 👋

The Retrieve Thread Messages should return each reply and the user’s ID as line items. To combine them you could use a Utilities > Line Itemizer (Formatter by Zapier) action like so:

6986b959945d674c6a334a0a63f670ce.png

Which would group the user and their message together:

13de9897217f4c5ed18d7442ae25d796.png
Then convert them from line items to text using another Formatter action (Utilities > Line-item to text).

However, that approach won’t give you the username of the user so instead you’d likely want to use the Looping by Zapier app to run a Find User by ID Slack action for each of the user IDs to get their username. And use a Digest to combine the usernames and replies within a Digest and then use the digest in the Jira action that creates the ticket—which would only run for the last loop iteration. You can learn more about that sort of approach here: 

 

Hope that helps to get you pointed in the right direction. If you run into any issues on that or have further questions just let us know!