I was looking at the Proactive Notification sample on GitHub, and found out an api controller is used in order to send the notifications.
What I don't like about it is that it opens a browser tab/window which I don't need in my case.
I don't need to call any api either, I would prefer to call a method to acheive the same thing. So I build a similar controller from the samples but without being an api controller:
public class NotifyController
{
private readonly IBotFrameworkHttpAdapter _adapter;
private readonly string _appId;
private readonly ConcurrentDictionary<string, ConversationReference> _conversationReferences;
private readonly GretaDBContext DBContext;
public NotifyController(IBotFrameworkHttpAdapter adapter, ConcurrentDictionary<string,ConversationReference> references,
GretaDBContext dbContext, IConfiguration configuration)
{
_adapter = adapter;
_conversationReferences = references;
DBContext = dbContext;
_appId = configuration["MicrosoftAppId"];
if (string.IsNullOrEmpty(_appId))
{
_appId = Guid.NewGuid().ToString(); //if no AppId, use a random Guid
}
}
public async Task NotifyValidation(int id)
{
foreach(var conversationReference in _conversationReferences.Values)
{
//METHOD LOGIC FOR SENDING PROACTIVE NOTIFICATION
}
}
}
My intention is injecting this to my Dialogs and call one of the public functions in order to notify some users that their profile has been validated.
I have a couple questions:
Would be better to use an api like the samples do and avoid opening the browser in some way? Or is injecting this controller to the Dialogs a good solution too?
In case the answer is injecting the non api controller, do I declare it as a scoped, singleton or transient service?