1-to-1 Proactive messaging using Bot Framework 4

六月ゝ 毕业季﹏ 提交于 2019-12-23 04:48:33

问题


I am using C# (.NET Core) with Bot Framework v4 to develop a bot service. I am a beginner to Bot Framework.

The problem statement goes as follows :

  • I want to be able to Store some questions on o365 SharePoint subscription in a list. The data structure of the list will have a column containing users who are the intended audience for the question.
  • When a question is added to the list, I want my bot to send out the questions to intended users on Microsoft Teams.
  • Even if the user is not online to teams, I would want to send out a notification to the user on Teams chat, something like "Missed conversation".

Now, I understand, on a very beginner level, that the key here is Proactive messaging using the Bot. What I can't figure out or find on any forum articles is that how do I write my bot to go to SharePoint (could be using polling or event driven) and fetch information and then send out the fetched data to Users on personal 1-to-1 team chat?

What I have done so far is :

  • I have written my SharePoint business logic to fetch information.
  • The bot calls this business logic when it receives an activity from User. i.e. say, a user says "Hi" and the bot goes and fetches information from SharePoint and returns it to the user in the chat window.

Any help would be greatly appreciated.

Cheers,

Yogesh


回答1:


My guess is that you should be able to accomplish the goals, but make sure to break this up into smaller problems when looking for assistance. You might need some other layers between the two to accomplish as well.

As you have found, proactive messages will be what you want to use from the bot side to message users without them engaging the bot first. You won't find any success (especially in Teams) if the users have never interacted with the bot before as there will need to be some sort of way for the bot to be able to know how to contact them (former conversation, etc). Please find more information here and here.

What I can't figure out or find on any forum articles is that how do I write my bot to go to SharePoint (could be using polling or event driven) and fetch information and then send out the fetched data to Users on personal 1-to-1 team chat?

I have written my SharePoint business logic to fetch information. The bot calls this business logic when it receives an activity from User. i.e. say, a user says "Hi" and the bot goes and fetches information from SharePoint and returns it to the user in the chat window.

So; it seems like the part you are missing is an intermediate layer that does polling or such. The proactive sample, is just using turn events to then 'proactively' message the user back. You might have to get creative. Have some sort of other service/timerjob/serverless function that might be able to assist.

This is an article for v3, but the general idea about proactive messages is good and helps understand how to best approach proactive message paradigm and ensure a good user experience: https://docs.microsoft.com/en-us/azure/bot-service/dotnet/bot-builder-dotnet-proactive-messages?view=azure-bot-service-3.0#send-a-dialog-based-proactive-message




回答2:


I was able to achieve the above mentioned tasks. For starters I was thinking too much and the solution was simple.

I wrote an infinite loop with asynchronous call to SharePoint at regular intervals using simple Task.Delay(milliseconds) and push the questions proactively when found.

As for 1-to-1 messaging, I am using Teams extension for Bot Framework to store individual channel information and send messages on private chat to users as and when there is something to send based on polling functionality above.

Hope that clears the air for someone, who might be looking to achieve anything similar.

Cheers, Y



来源:https://stackoverflow.com/questions/53646156/1-to-1-proactive-messaging-using-bot-framework-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!