Serverless - error while substituting templates

Hi, I’m creating this app for FreshCaller to find ticket created after call to be tagged with assigned call queue. But I keep getting ‘error while substituting templates’ error.

{
  "tagTickets": {
    "schema": {
      "protocol": "https",
      "method": "PUT",
      "host": "travelbuggy.freshdesk.com",
      "path": "/api/v2/tickets/<%= server.TicketID %>",
      "headers": {
        "Authorization": "Bearer <%= iparam.freshdesk_api_key %>",
        "Content-Type": "application/json"
      },
      "query": {
      }
    },
    "options": {
      "retryDelay": 1000
    }
  }
}
{
  "platform-version": "2.3",
  "product": {
    "freshcaller": {
      "events": {
        "onCallCreate": {
          "handler": "onCallCreateCallback"
        },
		"onCallUpdate": {
          "handler": "onCallUpdateCallback"
        }
		 },
        "requests": {
          "tagTickets": {},
		"getTickets":{}
        }
      
    }
  },
  "engines": {
    "node": "18.17.1",
    "fdk": "9.0.4"
  }
}

if (CallDirection == "incoming") {
      if (TicketID) {
          $request.invokeTemplate("tagTickets", {
              body: JSON.stringify(contents),
            })
            .then(function (data) {
                console.log(data);
              },
              function (error) {
                console.log(error);
              });
      }
    }

Hey @Sharjeel_Mukhtar,

Welcome to the Freshworks developer community! :tada:

Correct me if I’m wrong, you are trying to invoke tagTickets request template which substitutes ticket id during runtime?

This has to be changed to

"path": "/api/v2/tickets/<%= context.TicketID %>",`

And while invoking the template in server.js,

has to be updated to

$request.invokeTemplate("tagTickets", {
              context: { 
                     "TicketID": TicketID 
              },
              body: JSON.stringify(contents),
            })

You can also refer to - GitHub - freshworks-developers/request-method-samples at main
Let me know if this helps.