this is a post to clarify how call transfer works in tcl.
Background info and rationale: my goal is to create a full replacement of builtin:Session_Service.C in TCL with superset of enhancements (like talking to and notifying external HTTP servers).
I'll start (if that's ok with the community) a few posts to clarify some spots of TCL-IVR programming that, imho, are not well documented.
Hopefully this will be handy for me, in the first place, and other users of the community struggling with some blind spots of the manual.
I think, sometimes, RTFM it's not the right answer.
- The big picture
Call transfers in tcl has to be seen as a multi-step operation.
- First, a call has to be created (or inherited) by a tcl script.
This call will have 2 legs: say leg 1 is incoming and 2 is outgoing.
At a certain moment in time, user on leg A (or B, but let's assume it is A...) will want to transfer the call to another extension.
He presses the "Transfer" button on the phone.
- Here comes the second step: a new call is started from phone A to phone C.
This call is internally assigned a consultation id.
Once user C answers user on A talks to C and tells him he want to transfer B to him.
After talking to C, user on A presses the transfer button once again.
(Actually, A can press the transfer button even before C answers, but this makes no difference for the purpose of this post).
This phase can happen in another tcl script or in the default session.
- Here starts the third step: a notification (event) is sent to the tcl script that is managing the call between A and B (legs 1 and 2).
This notification holds the information about the call leg that has to be transferred, such as who is starting the transfer, who must receive the transfer and the consultation id of the call that was setup at second step.
- Now, tcl script starts the fourth step.
At this point, tcl script must destroy the connection between leg 1 and leg 2 (user A and B) and wait for the confirmation that the conference has really been destroyed.
- Once confirmed, the tcl script starts the fifth step.
A new call has to be setup with some special informations, such as the user (C) to which the leg (2) has to be transferred to and the consultation id that was assigned at step two and received during step three.
This is not quite a regular phone call, it is just a leg handoff to the handler (another tcl script, perhaps) that is taking care of the second call that was started at step two.
- The sixth (and final) step is to wait for the call created at step five to be "connected" (actually, handoff) and send a message to leg 1 (A) in order to disconnect this leg properly.
So, if this was TL;DR ... here's a shorter version:
- TCL SCRIPT receives a call from A and connects it to B
- A presses transfer and enters the digits
- A presses transfer again
- TCL SCRIPT receives an event, disconnects A from B
- TCL SCRIPT calls B with a special crafted leg setup message and waits for B to get the call (the leg)
- TCL SCRIPT disconnects A
- Example code
See attached tcl
Hope you liked my first post