I believe some channels may have different requirements. I can update this answer if you're looking for how to do this on a particular channel. For DirecLine/Webchat, I edited Sample 16.proactive-messages. In NotifyController.cs
, I changed the Get()
method to:
public async Task<IActionResult> Get()
{
foreach (var conversationReference in _conversationReferences.Values)
{
// Here, I create my own ConversationReference from a known one for the purpose of testing requirements
// I found that this is the bare minimum for WebChat/DirectLine
var newReference = new ConversationReference()
{
Bot = new ChannelAccount()
{
Id = conversationReference.Bot.Id
},
Conversation = new ConversationAccount()
{
Id = conversationReference.Conversation.Id
},
ServiceUrl = conversationReference.ServiceUrl,
};
// You may need this to ensure the message isn't rejected
MicrosoftAppCredentials.TrustServiceUrl(conversationReference.ServiceUrl);
// Here, I replaced conversationReference with newReference, to ensure it's using the one I created
await ((BotAdapter)_adapter).ContinueConversationAsync(_appId, newReference, BotCallback, default(CancellationToken));
}
// Let the caller know proactive messages have been sent
return new ContentResult()
{
Content = "<html><body><h1>Proactive messages have been sent.</h1></body></html>",
ContentType = "text/html",
StatusCode = (int)HttpStatusCode.OK,
};
}
So, as you can see, the minimum appears to be:
var newReference = new ConversationReference()
{
Bot = new ChannelAccount()
{
Id = conversationReference.Bot.Id
},
Conversation = new ConversationAccount()
{
Id = conversationReference.Conversation.Id
},
ServiceUrl = conversationReference.ServiceUrl,
};
References