Most Workato connectors work by creating a plain-English interface with an app’s HTTP API. This allows the recipe builder to stay focused on the business process they want to automate, rather than the technical details of using an API. However, some apps have vast APIs supporting dozens or even hundreds of request types. To keep the building experience simple, connectors often focus on enabling the most common and valuable automation use cases, rather than supporting every single possible request.
But what if you want to use an API request that isn’t supported by the connector? The easiest way forward is to use a custom action. Custom actions are supported by most connectors based on an HTTP API. The advantage of a custom action is that the work of connecting and authenticating to the API is done for you. All you have to do is specify the request and response.
To show you how easy it is, I’ll walk you through a simple example. At Workato, we use GoToWebinar to run our Product Hour sessions and other webinars. After each session, we update Salesforce with new leads generated. Workato has a GoToWebinar connector that can get details of attendees. However, it’s common for webinar attendees to ask questions about the subject matter.
We want to capture these questions, so our sales team can craft a helpful and relevant outreach message to the attendee.
The GoToWebinar connector doesn’t include an option to get questions for the session, but a glance at GoToWebinar’s API docs shows that this type of request is supported. So we’re going to build a custom action to get the information we need.
Create the action
If custom actions are supported for a given connector, the option will be listed in the actions menu:
It helps to give the action a human-readable name so that anyone else looking at our recipe will be able to understand what it does. We’ll call ours “Get questions from session”.
The rest of the details of the custom action come directly from the API documentation. We’re making a GET request, and the request URL requires a few path parameters. Fortunately, we have all the information we need from the Get webinar details action, so we can slot those datapills directly into the path.
We also need to describe the schema of the response we expect from the GoToWebinar API. Getting this schema correct will allow us to use the output of the custom action in other steps of the recipe. If you’re not sure what schema to use, just save your recipe and run a test. Check the output of the custom action and click Copy JSON
Back in edit mode, scroll to the Response Schema section and click Use JSON.
Paste the sample into the wizard and Workato will generate the schema for us!
Transform the data
We now have a custom action that returns a list of all the questions asked in the webinar. We can add this information to a custom field in Salesforce.
To do this we first need to match questions with the right attendee, then transform the list of questions and answers into a single document we can map to our Salesforce custom field.
This part of the recipe looks like:
For each attendee at the webinar we:
Create an empty list to hold questions
Add to the list any questions asked by the current attendee
Use the Message Template feature to turn the list of questions into a single html-formatted document
Create or update a lead in Salesforce for the current attendee. Map the document created by our message template to the Webinar Questions field.
Clear the list of questions, before we move on to the next attendee.
The result
When we check the leads from the webinar in Salesforce, the Webinar Questions custom field shows a complete list of questions and answers from the latest webinar.
With this information, our sales team can reach out with useful, relevant information instead of a pro forma email.
What next?
Workato offers a variety of ways to build out custom connectivity, depending on your needs:
Custom actions work best when you want to make an occasional request to a particular API endpoint.
If you need to support a lot of custom requests, think about creating a full custom connector, using the Connector SDK.
If you need to use an API that Workato doesn’t have a connector for at all, try the universal HTTP connector. This works a lot like custom actions, except that you need to provide authentication details. You can read an example use case here.
Pro tip: If you need to use a custom action a few times, but not often enough to justify making a dedicated custom connector, you can save setup time by copying and pasting the custom action between recipes.
The post Expand your horizons with custom actions appeared first on Workato Product Hub.
Read MoreWorkato Product Hub