Forum Discussion
Dynamic API Triggered Canvas
I want to trigger a Canvas using an API but also have that Canvas fire a Webhook message at the end of processing.
I would like to pass in some information in the API trigger payload that would dynamically switch the Canvas between two webhook messages. Since I cant use an api_triggered_property in a webhook message URL, I need another way to dynamically set a callback URL for the inbound API call.
Is there any way to use an api_triggered_property in an API Triggered Canvas to make a decision within that Canvas?
Any workarounds that anyone can share?
Thanks
Darren
- AllanHeoStrategist
Hey Darren,
Looks like you can use API Trigger Properties in the Webhook URL field. And interestingly, since the URL field is a long text input, you can do all sorts of things using Liquid (fun!). How does the second screenshot look as a potential solution?
If reporting is important and you need to use two separate message steps, then you should be able to apply the exact same process/logic that I wrote in this blog below. We use the User Update step to log the necessary data as a custom attribute, which you can then use to set up the Audience Path to differentiate the Webhook URLs.
Lmk if you have any questions!
Allan
- db-originActive Member II
Unfortunately I get this error when I try using the above in Webhook URL
Warning: Error saving your Canvas due to error on step Send Webhook: Invalid URL {% if {{canvas_entry_properties.${active_instance}}} == "proda" %} https://webhook.site/12135b8b-c085-4019-979c-x {% elsif {{canvas_entry_properties.${active_instance}}} == "prodb" %} https://webhook.site/12135b8b-c085-4019-979c-x {% endif %}
- AllanHeoStrategist
Hey Darren,
I'm just seeing your response! I just re-tested it from my own dashboard and got it to work successfully. We may have to look into other areas that might be causing this issue. Please feel free to schedule a call!
https://calendly.com/d/364-k6g-kxv/30-minute-meeting
Btw... Is this Darren T.? Or a different Darren?
- db-originActive Member II
Hi AllanHeo - Its not Darren T sorry - its Darren B 🙂 I've chatted to you on the old Slack groups previously
I did some more testing what what I was after and rather than fixing the result to two static URLs, I decided to pass in the URL via the API call as a callback URL parameter: canvas_entry_properties.${callback_url}
However, I found that there is some restriction on what you can put in the Webhook URL field. It seems to always want a HTTP scheme as a minimum e.g.
https://{{canvas_entry_properties.${callback_url}}} (Saves OK)
{{canvas_entry_properties.${callback_url}}} (Throws error on Save)
Cheers
Darren
- AllanHeoStrategist
Haha ahh, thanks for clarifying!
And super helpful. Thanks for sharing! Best of luck with the cool use case!
- AllanHeoStrategist
Related Content
- 8 months ago
- 9 months ago
- 11 months ago