Automated testing through Asterisk


Has anyone used Asterisk manager (AMI) to do automated testing ? I have been trying to run several AMI actions for one test case in a real-time mode and having some issues to get the active channel IDs. Here is an example.

Originate a call from 2002 to 1001, then redirect 2002 to 1002

originate(channel=‘SIP/2002’, exten = ‘1001’, context=‘internal’,priority=‘1’, …’)
redirect(channel=“SIP/2002-channelD”, exten = ‘1002’, context=…)

Could anyone let me know if this is a good approach and how to get the channel IDs properly?

Thank you,