Skip to content

Conversation

@NFhook
Copy link

@NFhook NFhook commented Nov 17, 2025

Currently the module uses:

switch_event_add_body(event, "%s", json);

This adds the JSON payload into the event body, which makes it difficult for ESL clients and event routers to parse, because the body is not key-value structured and cannot be retrieved via event.get("key").
This PR replaces the body with a dedicated event header:

switch_event_add_header(event, SWITCH_STACK_BOTTOM, "AudioStream-ASR", json);

Reasons for the change

  1. Headers are key-value pairs
    They can be retrieved directly using ESL’s event.get("AudioStream-ASR"), which is much easier and more reliable.

  2. Body parsing is inconsistent
    The body is appended after all headers and may contain arbitrary content and delimiters, making JSON extraction fragile.

  3. Consistent with FreeSWITCH best practices
    Most modules that deliver structured data (e.g., mod_json_cdr, mod_verto) use event headers instead of bodies.

  4. Backward compatibility
    Existing functionality is preserved; only the method of delivering the JSON payload is improved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant