Need help connect ivr to asterisk to python

I want to receive call from IVR to asterisk, pass it to python who processors it and response it back to ivr. Can anyone guide me how to set it up
This is what I have done
My os is CentOs 8
I am using python 3.6
I am using asterisk vs 17

I have created sip.config
[general]
context=internal
allowguest=no
allowoverlap=no
bindport=5060
bindaddr=0.0.0.0
srvlookup=no
disallow=all
allow=ulaw
alwaysauthreject=yes
canreinvite=no
nat=yes
session-timers=refuse
localnet=192.168.1.0/255.255.255.0
[7001]
type=friend
host=dynamic
secret=123
context=internal
[7002]
type=friend
host=dynamic
secret=456
context=internal
My extention.config
[internal]
exten => 7001,1,Answer()
exten => 7001,2,Dial(SIP/7001,60)
exten => 7001,3,Playback(vm-nobodyavail)
exten => 7001,4,VoiceMail(7001@main)
exten => 7001,5,Hangup()
exten => 7002,1,Answer()
exten => 7002,2,Dial(SIP/7002,60)
exten => 7002,3,Playback(vm-nobodyavail)
exten=> 7002,4,VoiceMail(7002@main)
exten => 7002,5,Hangup()
exten => 8001,1,VoicemailMain(7001@main)
exten => 8001,2,Hangup()
exten => 8002,1,VoicemailMain(7002@main)
exten => 8002,2,Hangup()

at modules.config
i have added
require = chan_sip.so

asterisk is running . Now how will i connect python such that when a call hits asterisk python receives it and also return response as audio In multiple places i am reading about AGR but i am not getting any proper setup file for the same.
Please help

I think you mean AGI. Although this is a bit dated, I think the basics are still true:

http://asteriskdocs.org/en/3rd_Edition/asterisk-book-html-chunk/AGI.html

Also, chan_sip is effectively deprecated (due for removal in a couple of years), canreinvite is an obsolete name for directmedia. Using type=friend is undesirable unless the devices have the same IP address.

You will find it much easier to modify dialplans if you use “same =>” and you use n for continuation priorities.