I would like to run a background task as part of a Bot Framework action, such as running an Azure Automation job or sending an approval request to a human. The goal is that the bot should only reply to the user once the background task has fully completed, in this case when the Azure Automation job finished successfully or the human has approved the request.
My bot is using a custom DirectLine channel in which it is not a problem if the communication with the user is async, the user will not expect the bot to reply back instantaneously. How can I have Bot Framework wait for a background task to complete, before sending a response back to the user?
The approach you are looking for is called proactive messaging. First you save the conversation reference and when your background task is complete, you can utilize this reference to send your message.
Microsoft Docs: Send proactive notifications to users