Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export vars #68

Closed
wants to merge 1 commit into from
Closed

Export vars #68

wants to merge 1 commit into from

Conversation

gozdal
Copy link
Contributor

@gozdal gozdal commented Apr 13, 2012

Previous commit only retrieved the exported variables values from IVR leg.
This exports those variables to agent leg.
A few notes (should probably be split into different commits):

  • added some DEBUG calls, which probably can be deleted
  • corrected a typo with "itext" (everywhere else there is "itxt" used)
  • had a problem with double-encoding of data passed in headers. We are using SIP headers to encode some JSON data. After pushing this encoded data to Erlang it got double-encoded. I'm not exactly sure where it gets encoded in OpenACD, but FS passes it single-encoded and it comes from OpenACD double-encoded (looked at Erlang event tcpdumps). Added uri.erl and uri:decode_uri_component as a crude fix.

@lordnull
Copy link
Member

Would you be able to apply the exported vars to the client record instead of the call record? The client record already has support for a list of arbitrary key/values, and is passed around with the call.

@gozdal
Copy link
Contributor Author

gozdal commented Apr 16, 2012

Yep, I can try. You think about adding extra field export_vars or adding those variables to field options?

@gozdal
Copy link
Contributor Author

gozdal commented Apr 16, 2012

Also do you hae any idea why I need to uri_decode headers?

@lordnull
Copy link
Member

SIP headers are very much like HTTP headers, so I suspect FreeSWITCH is encoding the data to be complient. This is just a hypothesis, I'd have to research to find out what's up. Also, mochiweb has urlencode and unquote in the mochi_util module.

@gozdal
Copy link
Contributor Author

gozdal commented Apr 16, 2012

Nope, it's not an issue of FreeSWITCH - if the call is passed directly (without OpenACD) it is encoded properly (once). When it gets into OpenACD it gets re-encoded (so I have to decode in OpenACD what I receive in FS or decode twice in SIP client).

@lordnull
Copy link
Member

This has be implemented in v2, putting the exported vars in the ring channel as well as the client options passed to the agent UI. The URI decoding is not yet implemented as I've yet to find a case the seems to break. Can you supply a dialplan the shows the need for double-decode?

@gozdal
Copy link
Contributor Author

gozdal commented Apr 24, 2012

I see you already implemented passing exported variables from FS to agent leg in ba47ac0

The example of double-encoding is:

    <extension name="direct-openacd">
        <condition field="destination_number" expression="^224774498$">
            <action application="answer"/>
            <action application="set" data="domain_name=$${domain}"/>
            <action application="set" data="brand=1"/>
            <action application="set" data="queue=sprzedaz"/>
            <action application="set" data="allow_voicemail=true"/>
            <action application="export" data="sip_h_P-Attach-Data=%7B%22a%22%3A%22b%22%2C%22c%22%3A%7B%22d%22%3A%22e%22%2C%22f%22%3A%22g%22%7D%7D"/>
            <action application="erlang" data="freeswitch_media_manager:! openacd@lab-app-1"/>
        </condition>
    </extension>

(P-Attach is encodeURIComponent(JSON.serialize(some_var)), where some_var={a:"b",c:{d:"e",f:"g"}})

In freeswitch_media.erl I have:

get_exported_variables(Proplist) ->
    ExportVars = string:tokens(proplists:get_value("variable_export_vars", Proplist, ""), ","),
    VarNames = ["variable_" ++ V || V <- ExportVars],
    VarValues = [proplists:get_value(N, Proplist, "") || N <- VarNames],
    VarValuesDecoded = [uri:decode_uri_component(V) || V <- VarValues],
    ?DEBUG("exported_variables: raw ~p decoded ~p", [VarValues, VarValuesDecoded]),
    lists:zipwith(fun (K,V) -> K ++ "=" ++ V end, ExportVars, VarValuesDecoded).

and in full.log I have:

16:20:28.219915 [DEBUG] <0.275.0>@freeswitch_media:1313 exported_variables: raw ["%257B%2522a%2522%253A%2522b%2522%252C%2522c%2522%253A%257B%2522d%2522%253A%2522e%2522%252C%2522f%2522%253A%2522g%2522%257D%257D"] decoded ["%7B%22a%22%3A%22b%22%2C%22c%22%3A%7B%22d%22%3A%22e%22%2C%22f%22%3A%22g%22%7D%7D"]

@gozdal gozdal closed this Sep 21, 2015
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.

None yet

2 participants