rveachkc / pymsteams

Format messages and post to Microsoft Teams.
https://pypi.org/project/pymsteams/
Apache License 2.0
422 stars 78 forks source link

OpenUri does not show up #61

Closed RonZhang724 closed 4 years ago

RonZhang724 commented 4 years ago

I was trying to add a potential action to open an URL. However, after running the following code snippet:

    team_message = pymsteams.connectorcard(URL)
    myTeamsPotentialAction1 = pymsteams.potentialaction(_name="Add a comment")
    myTeamsPotentialAction1.addInput("TextInput", "comment", "Add a comment here", False)
    myTeamsPotentialAction1.addAction("HttpPost", "Add Comment", "https://...")

    myTeamsPotentialAction2 = pymsteams.potentialaction(_name="Set due date")
    myTeamsPotentialAction2.addInput("DateInput", "dueDate", "Enter due date")
    myTeamsPotentialAction2.addAction("HttpPost", "save", "https://...")

    myTeamsPotentialAction3 = pymsteams.potentialaction(_name="Change Status")
    myTeamsPotentialAction3.choices.addChoices("In progress", "0")
    myTeamsPotentialAction3.choices.addChoices("Active", "1")
    myTeamsPotentialAction3.addInput("MultichoiceInput", "list", "Select a status", False)
    myTeamsPotentialAction3.addAction("openUri", "Confirm", "https://...")

    team_message.addPotentialAction(myTeamsPotentialAction1)
    team_message.addPotentialAction(myTeamsPotentialAction2)
    team_message.addPotentialAction(myTeamsPotentialAction3)

    team_message.title('title')
    team_message.text('text')
    team_message.color(card_styles[level])

    team_message.send()

The OpenUri action does not show up (the other two actions showed up fine). What might be the cause?

rveachkc commented 4 years ago

Looking at the OpenUri Action, it looks like you might need to define targets in your code: https://docs.microsoft.com/en-us/outlook/actionable-messages/message-card-reference#openuri-action

It looks like this would be done in your myTeamsPotentialAction3.addAction call. Relevant source: https://github.com/rveachkc/pymsteams/blob/master/pymsteams/__init__.py#L105

oroomans commented 1 year ago

I know this is 3 years late but as this is the first google result : You can use this method to have the button appears with OpenUri working : ` action = pymsteams.potentialaction(_name="Open Webpage")

action.addOpenURI("Open Web page",[{"os": "default", "uri":"https://www.google.be"}]) `