Solved

Update a card from Slack


Userlevel 3
Badge

Is it possible to update an existing card from Slack? 

 

For ex, if there’s a card with weekly updates and we want to append another update. 
Existing card has: 

Updates for week of July 1
July 2 Bananas in the break room 

July 3 Stop using reply-all about the bananas in the break room 

And then on Slack on July 4 there’s a message that we want to be added at the end: 

“We’re getting apples tomorrow!”

 

How can we send that message so that the card would then look like this, with the new update at the end? Would this be a Zap? 

 

Updates for week of July 1
July 2 Bananas in the break room 

July 3 Stop using reply-all about the bananas in the break room 

July 4 We’re getting apples tomorrow!

 

 

 

icon

Best answer by Joe Duffy 9 June 2022, 22:21

View original

7 replies

Hi Siobhan!

First off, thank you for the outreach and for sharing this question and use case. Unfortunately we do not have an “Update Card” action in Zapier today, just a “Create Card” action, so this would not be possible through a Zap. Although, you might be able to leverage our API for this use case. I am tagging in @Joe Duffy to see if he has any insights on how this might be accomplished. Thank you again for sharing this and I have noted this as a possible enhancement to our Zapier integration. 

Userlevel 2

Thanks @Lauren Musso!

Hi @Siobhan Hyser 👋

Lauren is correct that we don’t have a native action in Zapier to update a card. However, you could still  accomplish this through Zapier using our SDK if you are comfortable using Python!

If you are using a specific Slack channel to capture these messages, you could use the trigger and action below (you could also use a different trigger based on your use case): 

The Python code that you’d want to execute is here: 

import guru

g = guru.Guru("[user@email.com]","[api_token]")

card = g.find_cards(title="[card_title]")

SLACK_MESSAGE = """[slack_message_variable_from_zapier]"""

update = False

if SLACK_MESSAGE not in card.content:
card.content = card.content + SLACK_MESSAGE
update = True

if update:
card.patch()

Let me know if this if helpful!

Userlevel 3
Badge

Thanks! I shared this with a support engineer. Cheers!

Thanks for asking this, Sio!

Hey @Joe Duffy thanks for the tip and snippet. I was wondering how you get the Guru SDK imported into Zapier. From what I read in their docs, only the Python standard library is available in their Code steps, and the error I get when trying to import guru indicates as much:

 

I’m wondering if perhaps there’s a way I can expose the Guru SDK to Zapier’s Code action. Do you know?

Otherwise, what environments can we run this code from that would be allowed by Guru? I get a 403 when I try to do it locally, so I’m interested in knowing where we could run this. Or is it that I need a specific user role in our Guru instance?

Here’s part of the stack I get back:

```
[Live] making a get call: https://api.getguru.com/api/v1/cards/[:CARDID]/extended
[Live] response status: 200
<p class="ghq-card-content__paragraph" data-ghq-card-content-type="paragraph">placeholder</p>
[Live] making a patch call: https://api.getguru.com/api/v1/cards/[:CARDID]?keepVerificationState=true {'preferredPhrase': 'test guru api update', 'content': '<p class="ghq-card-content__paragraph" data-ghq-card-content-type="paragraph">placeholder</p><p>test from VS Code</p>', 'verificationInterval': 90}
[Live] response status: 403 body: b''
```

The rest of it is like irrelevant as they’re exceptions related to parsing the JSON object in the response which seems to come in as what simplejson considers invalid probably due to the b’’ literal.

 

For context, we want to update Guru cards based on Slack messages relevant to specific product areas, so we really just need the content to go from Slack and into a Guru card, ideally with little to no intervention from ICs, but at most, a reaction emoji would trigger the update.

 

I also wanted to point out a few gotchas with this code in case someone else wants to try it:

 

  • g.find_cards() returns a list, you must select an element from it, which hopefully is the only card that matches your query so g.find_cards()[0] for instance.
  • For our use case, we know the card id, so g.get_card("[id]") works better.
  • There’s an SDK reference in Github that’s useful.

Hoping to hear from you, and open to suggestions as well. Thanks!

Userlevel 3
Badge

Hey @Joe Duffy ! My colleague @Joshua Ordehi  made a reply to this post some time ago and it’s not been approved yet. is that something you can do on your end? Thanks!

Userlevel 2

Thanks for flagging, @Siobhan Hyser!

@Joshua Ordehi - you are totally right in that Zapier can’t execute python against external packages - sorry for leading you down that path!

You may need to run this outside of Zapier in that case then. You should be able to install the Guru SDK on your local machine (or on the server that the code will be running) by following this documentation. Have you tried this and are still getting errors?

Also - thank you for providing those additional tips!

Joe

Hey @Joe Duffy thanks for the update!

Silly me, I didn’t realize I had to update the call to card.patch() you shared. It takes one argument keep_verification which expects a boolean.

The details are on the reference: https://github.com/guruhq/py-sdk/wiki/Data-Objects#patch

It’s working after I pass in what seems to be a required argument, so card.patch(keep_verification=False)

Thanks!

Reply