When you dial the number on your softphone, Africa's Talking will notify you of outgoing calls on your callback URL from your sip number and you can respond with a dial action asking Africa’s Talking to forward the call to the number being called.

Here is a sample code to accomplish this:

from flask import Flask, request
app = Flask(__name__)

#Always include the callerId attribute so that the callee see your virtual number an not the default one

@app.route("/", methods=["GET", "POST"])
def call():
#grab the number that you are calling from what AT send your callback.
callerNumber = request.values.get("callerNumber", None)

#send a dial action asking AT to dial the number.
response = '<?xml version="1.0"?>'
response += '<Response>'
response += f'<Dial phoneNumbers="{callerNumber}" callerId="your-virtual-number"/>'
response += '</Response>'
return response

Did this answer your question?