LoginSignup
1
0

Azure Bot Service で Azure Communication Services のチャネルを利用する際の注意点

Last updated at Posted at 2023-12-13

はじめに

Azure では、Azure 上で Bot を作成から公開まで管理できる Azure Bot Servicesがあります。

そのチャネルの一つに、Azure Communication Servicesがあります。要は Azure Communication Services でスレッドを作成し、チャットを送信した際に Azure Bot Services から応答が返ってくるようなイメージです。

今回はその下記のチュートリアルを実施した際に注意点をメモ程度に記載します。
クイック スタート: ボットをチャット アプリに追加する

チュートリアルやってみた

まずはチュートリアルをそのままやってみると、なぜか Bot Services から応答が返ってこない。。。(EchoBot なので、”:Echo: Hello World” と返却されるはず)
image.png

Azure Bot Services の方も正常性が問題となり、スレッドがないと出る。
image.png

スレッドを早く閉じすぎたからかなと思い、下記のコードを一度消して見たところ、Azure Bot Services の正常性は治ったもののやはり Azure Bot Services から応答がない。。。

program.cs
chatClient.DeleteChatThread(threadId);

image.png
image.png

原因

原因としては、chatThreadClient では定期的に GetMeesages メソッドでスレッド内のメッセージをポーリングして取得するのですが、Azure Bot Services からの応答が返ってくる前にアプリの処理が終わっていたことが原因でした。

なので、じょうきしょりのまえにスリーブ処理を入れてあげると、正常に Azure Bot Services から応答が返却されました。

program.cs
 Console.WriteLine("====Interval Sleep====");
 Thread.Sleep(5000);

image.png

まとめ

当初はサーバー側のログを色々見ていても気付かず、ドキュメントにも明確に記載がなかったので意外と躓き記事にしました。chatThreadClient が GetMeesages メソッドを行うポーリング間隔を変更できるかどうかについては、分かり次第こちらの記事に追記します。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0