Creating and configuring custom service connections in Bigin Toppings

Creating and configuring custom service connections in Bigin Toppings

Hello Biginners,

Integrating Bigin with external applications extends its capabilities and enables customized functionalities. In our last post, we saw how to create a default service connection. Today, we'll see how to create a custom service connection when the application you need to integrate with isn't listed in the default services.

Consider a scenario where a team uses Bigin to manage its tasks and handles project tracking and collaboration in Trello. Keeping both the applications synchronized can be a challenging task and often requires manual data entry, which increases the risk of errors. To solve this challenge, we can create a Bigin topping with a custom service connection established with the Trello application. Using this custom service connection, we can automate the process by creating a new card inside Trello each time a new task is created in Bigin.

Let's learn how to do this.

Setting up the topping

A topping needs to be created using the Bigin Developer Center; for detailed instructions on creating a topping, refer to this post.

Once you've created the topping and accessed the Bigin Developer Console, the next steps are creating the custom service connection and configuring the topping's functionality.
  1. Navigate to the Connections section in the left panel and click the Get Started button.
  1. Under the Services section, select Custom Services, then click Create Service.
  1. Fill in the required details for the custom service in the configuration screen.
  1. Enter a name for the custom service connection under Service Name; this will automatically generate the service link name.
  2. Select the appropriate authentication type supported by the third-party application from the available options: API key, Basic Authentication, OAuth 1, OAuth 2, or AWS signature.
Notes
Note:

Refer to the official API documentation of the third-party application to determine the authentication type.
  1. Each authentication type has its own set of parameters to ensure secure integration with the third-party app. For detailed instructions on configuring each authentication type and field, refer to this guide.
  2. For integrating with Trello, we'll choose API Key, which is the authentication type supported by the Trello app. For more information on getting your API key and token, refer to the Trello API documentation. Trello requires an API key and token to authenticate with another app. They have to be configured as query parameters, so set the parameter type to Query String.
  3. In the Parameter Key fields, enter the key and token, and set their corresponding Parameter Display Names to Trello API Key and Trello Token respectively.
Notes
Note:

Providing both the key and token is essential because Trello requires these two credentials for secure API access.
The key is the unique identifier for your application, and the token is a user-specific credential that authorizes our application to access and modify Trello data.
  1. Once all the required parameters are configured, click Create Service.

After successfully creating the custom service, the next step is to establish the connection with the Trello service by clicking the Create Connection button.

  1. On the following screen, provide a connection name for your Trello integration; this name will automatically generate the Connection Link Name.
  2. Once you've entered the necessary details, click the Create And Connect button to start the connection process.
  1. You'll be prompted to authenticate your Trello account using the API key and token you got from the Trello API documentation.
  2. After entering these credentials, click Connect to authenticate and integrate your Trello account with the custom service you have created.
  1. Once the connection is established, you'll be redirected back to the Bigin Developer Console. Here, you can view the details of your custom service connection, including the connection link name, confirming that the integration with Trello is active and ready for use.

This connection link name serves as a unique identifier for your integration and will be referenced in the Deluge code.

You'll also need to create a default service connection with Bigin with the scope ZohoBigin.modules.tasks.ALL to access Task details from your Bigin account.



The next step is to set up a workflow rule to automate the card creation process. This workflow will trigger whenever a new task is created in Bigin to create a corresponding card in Trello. To do this, a custom function needs to be associated with the workflow.

To configure the workflow, navigate to the Automate section in the left panel of the Bigin Developer Console and select Workflow. Create a new workflow rule within the Tasks module, setting the trigger to activate whenever a new task is created in Bigin. For the trigger condition, choose to apply the workflow to All tasks to ensure every new task initiates the automation.

Next, associate the workflow rule with a function by selecting the Function option from the Instant Actions menu.


After providing the required function details, you'll be redirected to the Deluge editor, where you can implement the logic for creating a new Trello Card.



In the Deluge code:
  1. Retrieve the details of the newly created task from Bigin using its Task ID.
  2. Extract relevant task data such as the subject (used as the task name) and description.
  3. Identify the target Trello board and the specific list where the card should be created.
  4. Fetch all lists from the Trello board and locate the list ID that matches the desired list name. For our use case, we'll be creating the task as a card in the Trello list named "Today" so that the task created on that specific day will fall under the Today list. Later, it can be moved across other lists in Trello as its status updates.
  5. Prepare the card details using the extracted task information and the identified list ID.
  6. Create a new card in Trello using the prepared details.
The code below implements the logic for automatically creating a Trello card whenever a new task is created in Bigin.
  1. // Step 1: Get task details from Bigin
  2. taskDetails = zoho.bigin.getRecordById("Tasks",task.get("Tasks.ID"),Map(),"biginandtrello__biginconnection");
  3. // Step 2: Extract task data
  4. taskData = taskDetails.get("data").get(0);
  5. taskName = taskData.get("Subject");
  6. taskDescription = taskData.get("Description");
  7. // Step 3: Trello board and target list name
  8. boardId = "KQMtdnPX";
  9. targetListName = "Today";
  10. // Step 4: Get all lists on Trello board
  11. listsResponse = invokeurl
  12. [
  13. url :"https://api.trello.com/1/boards/" + boardId + "/lists"
  14. type :GET
  15. connection:"biginandtrello__trello"
  16. ];
  17. // Step 5: Find the list ID by name
  18. listId = "";
  19. for each listItem in listsResponse
  20. {
  21. if(listItem.get("name") == targetListName)
  22. {
  23. listId = listItem.get("id");
  24. break;
  25. }
  26. }
  27. // Step 6: Check if list exists
  28. if(listId == "")
  29. {
  30. info "List with name '" + targetListName + "' not found.";
  31. return;
  32. }
  33. // Step 7: Prepare Trello card details
  34. cardDetails = Map();
  35. cardDetails.put("name",taskName + " - From Bigin");
  36. cardDetails.put("desc",taskDescription);
  37. cardDetails.put("idList",listId);
  38. // Step 8: Create Trello card
  39. createCardResponse = invokeurl
  40. [
  41. url :"https://api.trello.com/1/cards"
  42. type :POST
  43. parameters:cardDetails
  44. connection:"biginandtrello__trello"
  45. ];
  46. // Step 9: Log Trello response
  47. info "Trello card creation response: " + createCardResponse;

For details about the API endpoints and request formats used in this code, refer to the Bigin Deluge reference library and Trello API documentation.
Now, let's test whether the topping is functioning as expected. To test the topping, click Test your Topping on the top right of the Bigin Developer Console.


You can test the topping by creating a new Task in your Bigin Sandbox account and then checking your Trello account to see if a new card is created in the specified list.



In this post, We've successfully created a custom service connection between Bigin and Trello!

By using custom service connections, you can securely integrate third-party applications with Bigin and achieve your business's use cases.

Stay tuned for more posts where we'll dive deeper into additional features and best practices for developing powerful toppings in Bigin.

    Nederlandse Hulpbronnen