Copy of Snippet "Single use Calendly link generator"

Generate a single use Calendly event invite using a Text Blaze snippet

Summary: This snippet generates a single use Calendly link, which you can then send via email.

Check event slug
You are generating a single-use link for event slug {=required_event_slug}. Please make sure the spelling and capitalization in this slug are correct.

Getting your Calendly API token
Follow the steps described on this link to generate an API token.
You can use the same token each time you schedule a call.
[Instead of using the formfield below, you can also store the token into the snippet but its not recommended]
{formtext: name=apikey}

{if: apikey <> ""}
Scheduling the meet
We follow the API documentation on this link.
{urlload:; method=GET; done=(res) -> ["response"=catch(fromJSON(res), "???")]; headers=Authorization=Bearer {=apikey}}
{urlload:{=user_uri}; method=GET; done=(res) -> ["response2"=catch(fromJSON(res), "???")]; headers=Authorization=Bearer {=apikey}}

{required_event=filter(response2["collection"], (x) -> x["slug"]==required_event_slug)[1]}
Your user URI is {=user_uri}
Your event URI is {=event_uri}
We made two API calls to extract this. You can store this value directly in the snippet so that we don't have to make the two API calls each time.

{urlload:{=event_uri}&owner_type="EventType"&max_event_count=1; method=POST; done=(res) -> ["response3"=catch(fromJSON(res), "???")]; headers=Authorization=Bearer {=apikey}}
Booking URL is generated after you enter the API key.
Congratulations, your booking URL is {=booking_url}