Tarjeta POST API de Bash Teams.
Bash is a popular command-line shell used for scripting and automation. Microsoft Teams is a collaboration platform that provides chat, video conferencing, and file sharing capabilities. By using the Equipos de Microsoft API, you can automate the process of posting cards to a Teams channel.
To post a card via API using bash, you can use the Microsoft Teams Connector webhook. The webhook provides a URL that you can use to send a POST request with the card as the payload. You can customize the card as per your requirements by changing the JSON payload.
Here’s an example of a bash command that posts a card to a Teams channel:
curl -H "Content-Type: application/json" -d '
{
"@type": "MessageCard",
"@context": "http://schema.org/extensions",
"themeColor": "0072C6",
"summary": "New task assigned",
"sections": [{
"activityTitle": "Task 123",
"activitySubtitle": "Assigned by John Doe",
"activityImage": "https://example.com/images/task123.png",
"facts": [{
"name": "Priority",
"value": "High"
},
{
"name": "Due date",
"value": "03/10/2023"
}
],
"markdown": true
}]
}' <YOUR_WEBHOOK_URL>
En este ejemplo, we’re creating a simple message card with a summary, an activity title and subtitle, an activity image, and some facts. We’re also setting the markdown
campo a true
para habilitar el formato de descuento en la tarjeta.
Para confirmar que la tarea se ha completado, puede incluir un mensaje en el cuerpo de la tarjeta indicando el estado de la tarea. Aquí hay un ejemplo de cómo puede modificar la carga útil de JSON para incluir un mensaje:
curl -H "Content-Type: application/json" -d '
{
"@type": "MessageCard",
"@context": "http://schema.org/extensions",
"themeColor": "0072C6",
"summary": "Task completed",
"sections": [{
"activityTitle": "Task 123",
"activitySubtitle": "Completed by John Doe",
"activityImage": "https://example.com/images/task123.png",
"facts": [{
"name": "Priority",
"value": "High"
},
{
"name": "Due date",
"value": "03/10/2023"
}
],
"text": "The task has been completed",
"markdown": true
}]
}' <YOUR_WEBHOOK_URL>
En este ejemplo, estamos modificando el resumen y el subtítulo de la actividad para indicar que la tarea se ha completado. También estamos agregando un text
campo para incluir un mensaje que indique que la tarea se ha completado.
En conclusión, usando la API de Microsoft Teams y bash, puede automatizar fácilmente el proceso de publicación de tarjetas en un canal de Teams e incluir mensajes que indiquen el estado de la tarea. Esto puede ahorrarle tiempo y esfuerzo al automatizar tareas rutinarias y mejorar la colaboración en su equipo..
Aquí hay un ejemplo command that posts a Teams card and checks the response code:
#!/bin/bash
response=$(curl -s -o /dev/null -w "%{http_code}" -H "Content-Type: application/json" -d '
{
"@type": "MessageCard",
"@context": "http://schema.org/extensions",
"themeColor": "0076D7",
"summary": "DUMP restored",
"sections": [
{
"facts": [
{
"name": "Where status:",
"value": "Successfully completed"
},
{
"name": "Where:",
"value": "Home"
}
],
"markdown": true,
"wrap": true
}
]
}' https://example.com)
if [ "$response" -eq 200 ]; then
echo "Teams card posted successfully"
else
echo "Error posting Teams card"
exit 1
fi