Sorry @Vignesh-AK , I did not complete my answer.
So what I gave you executes a simple python script and is basic. There are a number Asterisk documents that you should read and there are quite a few posts about running scripts in the dial plan that you can follow, for example:
https://community.asterisk.org/t/system-command-to-execute-script
https://community.asterisk.org/t/outbound-caller-id-lookup-http-query
Also I found reading the Chapter called “Asterisk Gateway Interface (AGI)” from the book Asterisk Definitive Guide helped with some of the basics.
Another good resource is Asterisk cmd AGI - VoIP-Info
It contains links for uses of AGI
In my Example I am not using a Bash script however, it does show sending variables that will get used with the script.
Did you already try running a script?
I find that even making a simple script that writes your variables to a file will give you some experience and you can see what happens without breaking anything, of course on a test system