SUPPORT.TWILIO.COM END OF LIFE NOTICE: This site, support.twilio.com, is scheduled to go End of Life on February 27, 2024. All Twilio Support content has been migrated to help.twilio.com, where you can continue to find helpful Support articles, API docs, and Twilio blog content, and escalate your issues to our Support team. We encourage you to update your bookmarks and begin using the new site today for all your Twilio Support needs.

Resolve Public API No Handler Function Found Error

Issue

When using the Segment Public API, Create Function endpoint to create a Destination, Insert, or Transformation Function, you may encounter the error message: validation: no handler function found.

 

Product

Twilio Segment

 

Environment

Segment Console

 

Cause

This error occurs because the JavaScript code provided in the code parameter is missing a required Segment-defined event handler. 

For Destination, Insert, and Transformation Functions, Segment requires at least one asynchronous handler function (such as onIdentify, onTrack, onPage, onScreen, onGroup, or onAlias) to process incoming Segment events. Source Functions do not require these handlers at creation, which is why this error does not occur for them.

 

Resolution

To resolve this error and successfully create your function, follow these steps:

1. Ensure your function code includes at least one valid asynchronous handler function. For example: 

async function onTrack(event, settings) {
  // Your destination logic here
  console.log('Track event received', event);
}

2. Include this handler in the code parameter of your API request when creating Destination, Insert, or Transformation Functions.

3. Resubmit your API request.

 

Additional Information 

  • The displayName field now accepts underscores and matches the UI validation pattern: /^[a-zA-Z0-9 _-]*$/.
  • Source Functions act as webhook endpoints and do not require event handler functions at creation.
  • For more details on handler functions, refer to Segment’s Public API documentation.

 

Have more questions? Submit a request
Powered by Zendesk