Webジョブからボットとユーザーの会話を再開しようとしていますが、権限のない例外が表示されています。 私は成功した私のMessagesControllerクラスでの会話に返信することができますが、私は私のウェブ仕事に次のコードを実行しようとすると、私は次の例外を取得:ボットフレームワーク会話を作成するときに権限がありません
private static async Task SendAlertToUser(ChannelAccount botAccount, LipSenseUser user, AlertFlags alert, string extra)
{
Console.WriteLine($"Sending alert to user: {user.Name}");
var sb = new StringBuilder(GetTextFromAlert(alert));
if (!string.IsNullOrEmpty(extra))
{
sb.AppendLine();
sb.Append(extra);
}
var userAccount = new ChannelAccount(user.ChannelId, user.Name);
var connector = new ConnectorClient(new Uri(user.ChannelUri));
var message = Activity.CreateMessageActivity();
message.From = botAccount;
message.Recipient = userAccount;
var conversation = await connector.Conversations.CreateDirectConversationAsync(botAccount, userAccount);
message.Conversation = new ConversationAccount(id: conversation.Id);
message.Locale = "en-Us";
message.Text = sb.ToString();
await connector.Conversations.SendToConversationAsync((Activity)message);
}
を、例外がある:
Exception:System.UnauthorizedAccessException
Authorization for Microsoft App ID 58c04dd1-1234-5678-9123-456789failed with status code Unauthorized and reason phrase 'Unauthorized'
コネクタの資格情報を調べると、すべて正しいことがわかります。私はMessagesControllerにブレークポイントを設定し、そこからコネクタのCredentialsを検査しました。すべてが同じです。
はまた、私はIntelliTraceのを見たとき、私は次のメッセージを参照してください。
マイuser.ChannelUriは、彼らが会話を初期化したときに、私は、ユーザーのオフに引っ張られ「https://facebook.botframework.com」、です。それは正しいウリじゃない?
メッセージを送信するために他に必要なことはありますか?私のApp.configファイルのappSettingsは、次のようになります。
<appSettings>
<add key="BotId" value="MyBotName" />
<add key="MicrosoftAppId" value="58c04dd1-1234-5678-9123-456789" />
<add key="MicrosoftAppPassword" value="5xyadfasdfaweraeFAKEasdfad" />
<add key="AzureWebJobsStorage" value="DefaultEndpointsProtocol=https;AccountName=BLAH;AccountKey=THIS IS A KEY" />
</appSettings>
クロスチャネルポストに感謝します。私は一般的に、マルチチャネル通信が最良の結果をもたらすことを発見しました! –