Code tested on Elastix / Issabel asterisk 11
Had to modify it a little bit
[macro-survey]
exten => s,1,answer()
;asks question1 (based on your recording file named as "question1")
exten => s,n(question1),Read(answer1,/var/lib/asterisk/sounds/en/atlantic,1,,1,2)
exten => s,n,GotoIf($["${answer1}" !=""]?question2:question1)
;asks question2 (based on your recording named 'question2")
exten => s,n(question2),Read(answer2,/var/lib/asterisk/sounds/en/pacific,1,,1,2)
exten => s,n,GotoIf($["${answer2}" !=""]?finish:question2)
;this line puts the two answers together and separates them with a , symbol.
exten => s,n(finish),set(answer=${answer1},${answer2})
;this saves the answers into the CDR field of "accountcode"
exten => s,n,Set(CDR(accountcode)=${answer})
;This line will send an email with the subject saying "Survey John Smith 555-123-4455 3|2"
exten => s,n,system(mail -s "Survey ${CALLERID(name)} ${CALLERID(number)} ${answer}" EMAIL@ADDRESS.COM < /dev/null)
;play a thankyou message.
exten => s,n,playback(/var/lib/asterisk/sounds/en/custom/thankyouforyourtime)
exten => s,n,hangup()
I'm using "atlantic" and "pacific" as the test voice playback. You can substitute that value for your own.