How to Create a Task in Zoho Connect Using Function API

How to Create a Task in Zoho Connect Using Function API

This example walks you through setting up a Function API that automatically creates a task in Zoho Connect whenever a ticket is created in Zoho Desk. Function API acts as a bridge between the two applications, transforming the data sent by Zoho Desk into a format that Zoho Connect can process.

Create a Function API configuration

  1. Click the gear icon [] from the right menu, then select Settings.

  1. Under Developer Space, click Function API.



  2. On the Function API page, click Configure.



  3. On the Configuration Details page, enter the required details.

  4. Click Save & edit code.

Create connections to Zoho Desk and Zoho Connect

Notes
Before writing the custom function, you need to create connections to both Zoho Desk and Zoho Connect.

  1. Click the gear icon [] from the right menu, select Settings.



  2. Under Developer Space, click Connections.

  3. Click New Connection.



  4. Select Zoho Connect as the service.



  5. Select the required scopes and authorize the connection.



  6. Click Create And Connect.

  7. Repeat the same steps to create a connection for Zoho Desk.

NotesThe connection name you enter must match the connection name used in the custom function code. In this example, the connection name is zconnect.

Write the custom function in the handlers

  1. Click Expand next to Handlers.

  1. Click Write function under Get Request Handler.



  2. In the function editor, enter the following code:

  1. returnMap = Map();
  2. return returnMap;
  



  1. Click Save.
  2. Click Write function under Post Request Handler.



  3. In the function editor, enter the following code:

  1. payloadArray = list(body);
  2. ticket = payloadArray.get(0);
  3. ticketPayload = ticket.get("payload");
  4. desc = ticketPayload.get("description");
  5. subject = ticketPayload.get("subject");
  6. response = invokeurl
  7. [
  8. url :"https://connect.zoho.in/pulse/api/addTask"
  9. type :POST
  10. parameters:{"scopeID":22***740*******028,"boardId":228174000000075004,"title":subject,"desc":desc,"sectionId":228174000000075009,"position":1}
  11. connection:"zconnect"
  12. ];
  13. info response;
  14. return {"statusCode":"201","response":"Task Created Successfully"};


  1. Click Save.

Notes
 Replace the scopeID, boardId, sectionId, and connection values in the code with the corresponding values from your Zoho Connect network.

Generate the API endpoint URL

  1. Click Expand next to API endpoint.



  2. Click Generate URL.



  3. Copy the generated URL.


Configure the outgoing webhook in Zoho Desk

  1. Log in to Zoho Desk, then click the gear icon.



  2. Under Developer Space, click Webhooks.



  3. Click New Webhook.

  4. Enter the required details:

    • Name - Enter a name for the webhook.

    • URL to notify - Paste the API endpoint URL copied from Zoho Connect.

    • Event - Select Tickets and choose Add as the trigger.

  1. Click Save

The Function API setup is now ready. Whenever a ticket is created in Zoho Desk, a new task will be created in Zoho Connect.

If you have any questions related to function API, write to us at support@zohoconnect.com. We're happy to help!