4
votes

I've read lots of docs on the Microsoft Web Site and here, but I couldn't find a solution for my case yet. Basically what I need is to consume a Microsoft Rest API (Graph?) to send a message notification(To a specific user) from an external app, using preferably NodeJS, Java or Python.

The closest I think I got was here: - https://docs.microsoft.com/en-us/graph/api/resources/chat?view=graph-rest-beta - https://docs.microsoft.com/en-us/graph/api/resources/chatmessage?view=graph-rest-beta

I couldn't find the method send though. Also those docs are under beta version which there is a warning to not use it on production apps.

On the link below (Which is under 1.0 version), I can see the resource chatMessage(Preview) and the Method send, but when I click on it I get 404: https://docs.microsoft.com/en-us/graph/api/resources/teams-api-overview?view=graph-rest-1.0

My need is to send a one way communication (Not back and forth, no need of Bots), just a simple notification and that's it.

Is it possible to implement such a solution? Any reference that could help?

Thanks

2

2 Answers

0
votes

Currently, only Bots can send 1:1 message to users.

Create chatMessage does not support application context so it has be an user sending the message. Also, you cannot create an new chat, you must use the list chats method to retrieve the Id of an existing chat before creating a chat message.

0
votes

There are some code snippets at https://docs.microsoft.com/en-us/microsoftteams/platform/bots/how-to/conversations/conversation-basics?tabs=python

Send a message [Python]

To send a text message, specify the string you want to send as the activity. In the bot's activity handlers, use the turn context object's SendActivityAsync method to send a single message response. You can also use the object's SendActivitiesAsync method to send multiple responses at once. The code below shows an example of sending a message when someone is added to a conversation

async def on_members_added_activity(
    self, members_added: [ChannelAccount], turn_context: TurnContext
):
    for member in teams_members_added:
        await turn_context.send_activity(f"Welcome your new team member {member.id}")
    return