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)
{
var newReference = new ConversationReference()
{
Bot = new ChannelAccount()
{
Id = conversationReference.Bot.Id
},
Conversation = new ConversationAccount()
{
Id = conversationReference.Conversation.Id
},
ServiceUrl = conversationReference.ServiceUrl,
};
MicrosoftAppCredentials.TrustServiceUrl(conversationReference.ServiceUrl);
await ((BotAdapter)_adapter).ContinueConversationAsync(_appId, newReference, BotCallback, default(CancellationToken));
}
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
TrustServiceUrl
part in there? You're using the correct appId and password? If you edit sample 16 like I did, do you still receive the error? If you're not using that sample, I've seen some permission errors pop up if you instantiate theConnectorClient
incorrectly; if you include some code I might be able to help. – mdrichardson