botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

Please make teams Conversation Reference API available

Open jonathanhotono opened this issue 4 years ago • 5 comments

Issue

Can we please have an api endpoint/function that could grab the conversation reference/id from a particular user so the bot doesn't need to be interacted by the users beforehand and simply send a proactive message when needed. I have a scenario where a notification using teams chat needs to be sent to certain user based on certain condition/rule (e.g compliance).

It is not ideal having user to chat the bot first.

Proposed change

On this sample proactive message bot the bot only capable to send proactive message to engaged users. We also need an api/function to send proactive message/notification into user who never engaged the bot before..

There is a flow bot capability to post a message to a user: image

Component Impact

Describe which components need to be updated

const conversationReference = await getTeamsConversationReference(aadUserId) //conversationReference API Here
await adapter.continueConversation(conversationReference, async turnContext => {
            await turnContext.sendActivity('proactive hello');
});

Tracking Status

Dotnet SDK TODO

  • [ ] PR
  • [ ] Merged

Javascript SDK TODO

  • [ ] PR
  • [ ] Merged

Python SDK TODO

  • [ ] PR
  • [ ] Merged

Java SDK TODO

  • [ ] PR
  • [ ] Merged

Samples TODO

  • [ ] PR
  • [ ] Merged

Docs TODO

  • [ ] PR
  • [ ] Merged

Tools TODO

  • [ ] PR
  • [ ] Merged

jonathanhotono avatar Mar 30 '21 00:03 jonathanhotono

Hi guys.. any update or explanation over this functionality? I have an organisation with over than 40K employee that needs notification system that doesn't need the employee to handshake first. I think it should be ok as long the app permission added is fully trusted and approved by the admin.

jonathanhotono avatar May 10 '21 02:05 jonathanhotono

@jonathanhotono I use MS Graph to imperatively install the app to users. Once you install the app, then the bot will receive the conversationUpdate event with the user's conversation context, save it, and reuse when you need to send a notification.

w01fgang avatar May 28 '21 09:05 w01fgang

Hi @w01fgang that is exactly the problem I am addressing. We don't want user to interact with the bot first to get conversationUpdate and save the user details on storage. We want to use graph to start conversation directly with a user id.

jonathanhotono avatar May 29 '21 06:05 jonathanhotono

@jonathanhotono this will trigger conversationUpdate without user interaction, then just save the context for the user id

like this:

this.onConversationUpdate(async (context, next) => {
    const conversationReference = TurnContext.getConversationReference(context.activity);
    await this.storage.write({
        id: conversationReference.user.aadObjectId,
        type: "conversation",
        data: conversationReference,
    });
    await this.dialog.run(context, this.dialogState);
    await next();
});

this.storage just saves the context to a DB

w01fgang avatar May 31 '21 11:05 w01fgang

Thanks @w01fgang , I understand and I had this used on the bot. The problem that I would like to highlight is, we don't want each user in our organisation to access/go to notification bot beforehand (we got 40,000 users). It would be troublesome for comms to get users to access the bot rails to perform this kind of handshake before we can start publishing notifications. We want to essentially use graph api to get the targetted user aadObjectId then perform/send notification/chat against that user without having to write that user details into storage first.

P.S onConversationUpdate would still require user to access the chat bot first for this to trigger.

jonathanhotono avatar Jun 01 '21 01:06 jonathanhotono