Troubleshooting
Troubleshooting
Common Issues and Solutions
App Installation Fails
- Check manifest.json: Ensure
assets/manifest.jsonexists and contains valid JSON - Verify manifest fields: Must include
app.name,app.version, andapp.description - Check ZIP structure: Main file must be named
{app_name}.lua - Verify version format: Use semantic versioning in manifest (e.g.,
1.0.0,2.1.3-beta) - Remove test files: Don't include
spec/,turn.lua, or.rockspecfiles
Common error messages:
:manifest_not_found- Missingassets/manifest.jsonfile:invalid_manifest_json- Malformed JSON in manifest file:invalid_manifest_format- Missing required fields in manifest
Contact Subscriptions Not Working
- Ensure
set_contact_subscriptions()is called in theinstallevent - Verify field names match exactly (case-sensitive)
- Check the return value for error messages:
local success, reason = turn.app.set_contact_subscriptions(fields)
if not success then
turn.logger.error("Subscription failed: " .. reason)
end
Journey Events Not Triggering
- Verify the function name matches between Journey and app
- Check return format: must be
"continue"or"wait", or"error" - For async flows, store and use
chat_uuidcorrectly:-- Store chat_uuid when initiating async operation
store_webhook_data(webhook_id, data.chat_uuid)
-- Later, in webhook handler
local chat_uuid = retrieve_webhook_data(webhook_id)
turn.leases.send_input(chat_uuid, result)
HTTP Requests Failing
- Check URL format and ensure it's complete (including
https://) - Verify headers are properly formatted:
local body, status = turn.http.request({
url = "https://api.example.com/endpoint",
method = "POST",
headers = {
["Content-Type"] = "application/json",
["Authorization"] = "Bearer " .. token
},
body = turn.json.encode(data)
})
Module Loading Issues
- Ensure module paths are relative to ZIP root
- Use forward slashes in require statements:
local utils = require("my_app.utils") -- Correct
-- NOT: require("my_app\\utils") -- Wrong
-- -- NOT: require("my_app/utils") -- Wrong
Debugging Tips
-
Use Logging Extensively:
turn.logger.debug("Starting process with data: " .. turn.json.encode(data))
turn.logger.info("Process completed successfully")
turn.logger.error("Failed to process: " .. error_message) -
Check App Logs: View logs in Turn UI → Settings → Apps → Your App → Logs
-
Test Locally First: Use the mock
turn.luaAPI for unit testing -
Handle Nil Values: Always check for nil before using values:
local value = data and data.field or "default" -
Validate Event Data: Different events have different data structures:
if event == "journey_event" then
if not data.function_name then
turn.logger.error("Missing function_name in journey_event")
return "error", "Invalid journey event data"
end
end
Getting Help
If you're still experiencing issues:
- Check the app logs for detailed error messages
- Review the example apps for working patterns
- Contact Turn.io support with:
- Your app's UUID
- The specific error messages
- Steps to reproduce the issue