How to write a SIP attended transfer application using state tables

There are two ways of invoking an attended transfer using SIP: