I need to create a notification for internal users to alert them when a new KB article has been published.
I’ve been using graphql to query KB articles, but it is unclear to me how I should go about creating a custom solution to:
1) Query KB Articles
2) Determine new articles (if any)
3) Send an email to internal users when there is a new article.
My research has led me to believe this may be possible using a custom code workflow:
I think I can query the api for KB articles, check time stamps, and return the articles that are published.
I’m unsure about emailing internal stakeholders with the links that are returned from the custom code. I can add a step in the workflow to send an internal email notification, but how can I include the Query results from the custom code in the previous step?
Is this the best way to go about this? If anyone can outline a process to get this started, that would be greatly appreciated!
Please see below a couple of screenshots that should help you get started. Note that the custom code action is written in Python. At a top level, you would need to return the KB article link(s) within the custom code action’s “outputFields” (“link_1” and “link_2” in the first screenshot). Then include this link(s) in your internal email notification by selecting “Insert data” > “Action outputs” > “Custom code” > “link_1” / “link_2”.
Thank you for your insight! I have a few follow up questions:
1. It says you can use inputs to get data from any action in your workflow and use it in your code instead of having to use the HubSpot API. I looked, but I don’t see a way to add KB articles
Is it possible to input the data? If not, I think I’ll need to query for kb articles using the api. Any sources for hooking that up in the custom code? I see I can add secrets, so I think I might need to add an api key.
2. How can I set up logic so it only sends an email if there is new articles? I see I can set up a boolean output property. I assume I can make it so if this is is true, go to next step in workflow. Could you detail this a bit more for me.
Yes, what you’ve described is pretty much the approach I’d take. If you’d like to pick this up with me personally, please feel free to reach out via HubSpot Community direct message, where I’d be happy to continue our conversation.