Skip to main content
Question

How do I create a Zap to pull a structured Slack message and put it in an Excel document in tabular format

  • 26 December 2023
  • 8 replies
  • 60 views

Hi,

 

I want to build a zap which can transform the following format of Slack message (multiple sets of data in a single message)

 

to an excel file in a tabular format (headers in the message and excel are corresponding)

Can someone please suggest if it is possible and how?

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

8 replies

Userlevel 7
Badge +6

Hi there @RahulN,

Welcome to the Community! 🎉

If the message format is consistent, you can use Formatter by Zapier - Split Text to achieve your workflow. Here’s how:

7abe863a4285e5546cad1fdba5b72fe9.png
(view larger)

Hopefully, this helps.

Userlevel 1

Hi @ken.a ,

Thanks for getting back.

I tried the suggestion, however, there is a problem that each output item then has the header + Text from previous header (see below).

We will somehow need to split by “:” as well as new line (that’s my understanding). What do you suggest here?

 

Userlevel 1
Badge +1

Hey @RahulN , this is a great usecase. 

I would agree with @ken.a if you’re able to use the zapier formatter, you should be able to parse and split the message and use it to populate in a spreadsheet. 

If you’re good with little bit of coding, you may use such a code to split it in an array and potentially use it in the next step to simply populate that in the sheet. Check this out 

Userlevel 1

Hi @zaki_readylogic, thanks much for your revert. This is helpful and seems to be going the right direction.

I am not a coder but know a bit of it. Hence a very simple and silly question, where does this script go in my zap?

Userlevel 1

Hi @zaki_readylogic, Please ignore the above. 

 

I have been able to figure out how to run python code in a Zap.

 

This is the code I am running at the moment.

# Get the message from the input data
message = input_data["Message"]

# Split the message into lines
lines = message.split("\n")

# Initialize an empty dictionary to store the data
data = {}

# Loop through each line in the lines list
for line in lines:
# Ignore blank lines
if line.strip() == "":
continue

# Split the line into key and value at the first occurrence of ":"
key, value = line.split(":", 1)
# Strip any leading or trailing spaces from the key and value
key = key.strip()
value = value.strip()

# Check if the key is "Description"
if key == "Description":
# If the key is "Description", check if there is already a value
if "Description" in data:
# If there is already a value, append the current line to the existing value
data["Description"] += "\n" + value
else:
# If there is no existing value, set the current line as the value
data["Description"] = value
else:
# Add the key-value pair to the data dictionary
data[key] = value

# Initialize an empty list to store the output
output = []

# Append the data dictionary to the output list
output.append(data)

However, the issue now I am facing is that the output still gets 1 row instead multiple. If you can help point me in the right direction again.

Userlevel 7
Badge +6

Hi there @RahulN,

To be fully transparent, our team is able to provide limited support with the Code action step. It's an advanced feature that can involve lots of custom code, and can quickly land outside of our scope of knowledge. 

For any questions that I may not be able to answer, I tend to recommend checking these out:

Additionally, we have a directory of Zapier Experts who might be able to help with your code. You can reach our Zapier Experts here: https://zapier.com/experts

Hopefully, this helps.

 

Userlevel 1

Thanks for your support till now@ken.a ! I will take a look at the options you suggested.

Userlevel 7
Badge +6

You are most welcome @RahulN! I’m glad I was able to help you out in some way.

If you have any other questions, please don’t hesitate to reach out to the Community. We’re always happy to help! 🤗