You can add potentialaction objects to allow users to interact with the card in MS Teams.
Workflow:
- Create a
potentialaction object with a _name. - Use
.addInput(type, id, label, is_required) to add input fields (e.g., TextInput, DateInput, MultichoiceInput). - Use
.addAction(method, label, url, [payload]) to define the action (e.g., HttpPost). - For
HttpPost actions using inputs, use the syntax {{id.value}} in the payload to pass the input value to your backend. - Add the action to the card using
.addPotentialAction(action).
Example with Input:
myTeamsPotentialAction1 = pymsteams.potentialaction(_name = "Add a comment")
# 'comment' is the ID used in the payload
myTeamsPotentialAction1.addInput("TextInput", "comment", "Add a comment here", False)
# The payload {{comment.value}} maps to the input ID
myTeamsPotentialAction1.addAction("HttpPost", "Add Comment", "https://...", "{{comment.value}}")
myTeamsMessage.addPotentialAction(myTeamsPotentialAction1)
myTeamsPotentialAction1 = pymsteams.potentialaction(_name = "Add a comment")
myTeamsPotentialAction1.addInput("TextInput","comment","Add a comment here",False)
myTeamsPotentialAction1.addAction("HttpPost","Add Comment","https://...", "{{comment.value}}")
myTeamsMessage.addPotentialAction(myTeamsPotentialAction1)