viaSocket provides a wonderful feature of creating your own plug-in. This gives you the flexibility to create any plugin you want. Let's dive deep into the process of creating your own plug-in and actions in your viasocket account.
1. Log into your viasocket account. Choose the option plug-in builder
In this example we are going to build a mailchimp plug-in.
2. Let’s break down this process step by step
Things you add here will be visible in your plugin so add it carefully.
App Name (Required) : The service name that you wish to create a plugin for should be entered. For example : Type Google Sheet into App Name if you wish to create a Google Sheets.
Plugin Description (Required) : Provide the description about the service, what it does, where to use it and more.
Domain (Required) : Here we give the domain of the app that is the website or url of the app .🛑 NOTE : It is necessary to give the domain of the app to show the app in the listed apps
Audience (Required): You can indicate whether the plugin is public or private here. Selecting the public will make it available across different organizations. The plugin will only be accessible within your company if you select private.
Category (Required) : In this step, you select the category of your plugin, indicating its type. Viasocket provides a list of categories for all kinds of applications.
Icon Url : This is for the icon for your plugin. Viasocket will automatically set the icon URL if you entered the right domain in the previous step.
Next step to set authentication for your plugin. In Authentication Configuration viasocket provide two types of authentication methods for your application :
Basic Auth
OAuth 2.0
🛑 NOTE : If any service support base64 conversion then select Basic auth in that case.
Typically, basic authentication requires the service's api-key. The processes to obtain an API key and the necessary fields are covered in detail in the service's documentation.
Version of authentication: Viasocket provides v1 version of authentication automatically.🛑 NOTE : We need to create a new authentication version if we have used authentication version in any action. We can not edit an authentication version which is used by any action.
Field Label : Viasocket provides field auth_key by default for basic auth, but one can add additional fields accordingly.
Configure additional Input Fields (if required) :
Click on Add Field and fill the field details
Key: Uniquely identifies the input field. It is essential for referencing and processing the data associated with this field.Ex: auth_key , domain.
Label: The name of the field. It will be visible on the UI. This is what users will see as the name of the input field.
Help : Provide any instruction to the user such as:documentation link,format etc.
Type: Specifies the data type of the field, such as string for text, number for numeric values, etc. As of now it is set to string.
Required: Indicates whether the field is obligatory. If checked, users must provide a value for this field during authentication.
🛑 NOTE : The fields you created for authentication are required to create actions and triggers. Use this value format : `${context.authData.fieldkey_name}`.
Test Me API:
To complete the process of authentication the final step is to add the Test Me API . It is a simple GET API which is getting user details, profile information.This API is invoked during the authentication process of the plugin.
Sample Request with Response:
Connection Label:
It is a label provided to show authentication by the user when using the plugin in any of the flows. For security purposes, "Mask connection label value" is used to essentially conceal the actual value of the connection label.
Auth2.0 works by delegating user authentication to the service that hosts the user account and authorizing third-party applications to access the user account. To implement OAuth 2.0 in viaSocket for a particular service, you would typically need to register your application with the service to obtain a client ID and client secret, implement redirection endpoints for handling callbacks, and implement the logic to obtain and refresh access tokens using the client credentials.
Scopes : Scopes define and limit the access that a client application has to a user's resources on a resource server. They play a crucial role in determining the extent of the authorization granted during the OAuth flow.
There are two types scopes :
Space Separated : In some OAuth 2.0 implementations, scopes are represented as a space-separated list within the scope parameter. For example: scope=read write profile
Comma Separated : In other OAuth 2.0 implementations, scopes are represented as a comma-separated list within the scope parameter. For example: scope=read,write,profile
🛑In the scope field when you write any scope you have to press ENTER KEY so that the scopes will get saved.
🛑Add fields process is same as Basic auth.
🛑Format to use response of authorization is `${context.authData.code}`. Replace code with key in the response you want to use.
Next step is to add required API’s and authenticate a user, the API’s you need to provide for your service is:
Access Token API :
Once the authorization code is generated, the next step is obtaining an access token. The primary purpose of an access token is to securely grant limited access to specific resources on behalf of a user or an application.
Example :
🛑To use response of this block for is `${context.authData.accesstokencode.______ }`
Refresh Token API :
The refresh token serves to refresh the validity of the access token by generating a new token and extending the access token's duration.
Example :
🛑To use response of this block for is `${context.authData.refreshtokencode.______ }`
Revoke Token API :
If you wish to disable an access or refresh token, simply send a request to the /revoke endpoint of the appropriate authorization server.
Example :
🛑To use response of this block for is `${context.authData.revoketokencode.______}`
Test Me API :
Same as basic auth
Example :
🛑Connection label is same as basic auth.
🛑Using try/catch in the code is a best practice for catching errors and debugging and in return always add response.data
We have successfully completed the authentication process now the next step is to create the desired action for the plugin. To create the action click on create action->then provide all necessary information about the action
Add additionally required scopes
To perform the particular action if any other scopes is required enter it in the action scopes.
Now we have to write Action JSON:
The concept of "action JSON" in a viaSocket plugin refers to the structured JSON format used to define the fields of an action that are selected by the user when he/she uses that plugin. This JSON structure typically includes text fields,dropdowns, input groups etc .
Here is a simplified version of what an action JSON might look like :
🛑To Get value of the field use `${context.inputData.field_key}`
🛑To know more about the JSON and its fields types refer the doc https://viasocket.com/faq/create-plugin
🛑For escape json use https://www.freeformatter.com/json-escape.html#before-output
Final perform API:
The last step to complete the action is to add a final perform API. This API is responsible for performing the action.
Example :
In viaSocket, a trigger is an event that starts your flow. It acts as the initial stimulus to commence an automated workflow whenever a particular event occurs.
Viasocket provide two types of triggers you can choose according to your use case :
Instant Trigger :
These are designed to respond immediately to a specific event or condition. When the criteria for the trigger are met, the associated actions or processes are executed without delay.
For instant triggers webhook are used. 🛑Webhook Url is url you need to provide at the time of webhook creation. Pass its context `${context.inputData.hookurl} so when the trigger is included in the flow it automatically considers webhook of the flow to trigger.
🛑JSON part is same as action JSON.
Next step is to add required API’s for create instant trigger, the API’s you need to provide for your service is:
Add PerformList API
🛑In this API you can add sample webhook payload or a GETapi which return response as webhook get when event performed.
Example :
Add Perform Subscribe API:
Example :
ADD PerformUn-Subscribe API:
🛑Use above created webhook Id to delete that webhook. Format to use that webhook ID is `${context?.inputData?.performSubscribe.id}
Example :
Schedule Trigger :
Unlike instant triggers, scheduled triggers are designed to activate at predetermined times or intervals. In viaSocket, scheduled triggers fetch data from the server every 15 minutes, and developers can use GET APIs to check and process data created or updated within the last 15 minutes, using JavaScript functions to filter and return the relevant data.
For create schedule trigger, the API’s you need to provide for your service is:
Add PerformList API
🛑In this API you can add sample webhook payload or a GETapi which return response as webhook get when event performed.
Example :
Add Perform API
🛑In this API you can add sample webhook payload or a GETapi which return response as webhook get when event performed.
Example :