> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dodopayments.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Microsoft Teams

> Dodo Payments-Ereignisse als Adaptive Cards an einen Microsoft Teams-Kanal senden, damit Ihr Team Zahlungen, Abonnementänderungen und Disputes sieht.

## Einführung

Die Microsoft Teams-Integration veröffentlicht Dodo Payments-Ereignisse als Adaptive Cards in einem Teams-Kanal, damit Ihr Team Zahlungen, Abonnementänderungen und Disputes unmittelbar sieht. Verwenden Sie sie, wenn Ihr Geschäftsteam in Teams arbeitet.

> [!NOTE]
>
> Diese Anleitung setzt voraus, dass Sie Administratorrechte haben, um Webhooks in Ihrem Microsoft Teams-Arbeitsbereich zu erstellen.

## Erste Schritte

**1. Open the Webhook Section**

Gehe im Dodo Payments-Dashboard zu **Developer → Webhooks** und klicke auf **Add endpoint**.

![Add endpoint dialog with Teams selected in the Integration dropdown](https://mintcdn.com/dodopayments/DL_ADtkdH7ph5YST/images/integrations/teams.png?fit=max\&auto=format\&n=DL_ADtkdH7ph5YST\&q=85\&s=372cfda27dd7faea77761d4d6034f21d)

**2. Select Microsoft Teams**

Wählen Sie in der Liste **Integration** die Option **Teams** aus.

**3. Create Teams Webhook**

Microsoft hat die **Incoming Webhook**-Konnektoren von Office 365 in Teams eingestellt. Erstellen Sie den Webhook daher mit der Workflows-App:

1. Öffnen Sie in Teams den Kanal, der Benachrichtigungen empfangen soll.
2. Klicken Sie neben dem Kanalnamen auf **⋯** und wählen Sie **Workflows** aus.
3. Wählen Sie die Vorlage **Post to a channel when a webhook request is received** aus.
4. Bestätigen Sie Team und Kanal und klicken Sie anschließend auf **Add workflow**.
5. Kopieren Sie die von Teams angezeigte Webhook-URL.

**4. Paste Webhook URL**

Fügen Sie die Teams-Webhook-URL in das Feld **Endpoint URL** ein.

**5. Customize Transformation**

Bearbeiten Sie den Code unter **Transformation code**, um jedes Ereignis als Adaptive Card zu formatieren. Verwenden Sie die folgenden Beispiele als Ausgangspunkt.

**6. Test & Create**

Führen Sie unter **Test this code** die Transformation mit einer Beispiel-Payload aus und klicken Sie anschließend auf **Create endpoint**.

**7. Done**

Ihr Teams-Kanal empfängt nun Dodo Payments-Ereignisse als Adaptive Cards.

## Beispiele für Transformationscode

Jedes Beispiel ersetzt die Ereignis-Payload durch eine Teams-Nachricht mit einem Adaptive-Card-Anhang.

### Basiskarte für Zahlungen

Dieses Beispiel veröffentlicht den Betrag, die E-Mail-Adresse des Kunden und die Zahlungs-ID, wenn eine Zahlung erfolgreich ist.

```javascript payment_card.js icon="js" expandable theme={null}
function handler(webhook) {
  if (webhook.eventType === "payment.succeeded") {
    const p = webhook.payload.data;
    webhook.payload = {
      type: "message",
      attachments: [{
        contentType: "application/vnd.microsoft.card.adaptive",
        content: {
          type: "AdaptiveCard",
          body: [
            {
              type: "TextBlock",
              text: "✅ Payment Successful",
              weight: "Bolder",
              size: "Medium"
            },
            {
              type: "FactSet",
              facts: [
                { title: "Amount", value: `$${(p.total_amount / 100).toFixed(2)}` },
                { title: "Customer", value: p.customer.email },
                { title: "Payment ID", value: p.payment_id }
              ]
            }
          ]
        }
      }]
    };
  }
  return webhook;
}
```

### Abonnementverwaltung

Dieses Beispiel veröffentlicht eine Karte, wenn ein Abonnement aktiv wird, und eine weitere, wenn es gekündigt wird.

```javascript subscription_card.js icon="js" expandable theme={null}
function handler(webhook) {
  const s = webhook.payload.data;
  switch (webhook.eventType) {
    case "subscription.active":
      webhook.payload = {
        type: "message",
        attachments: [{
          contentType: "application/vnd.microsoft.card.adaptive",
          content: {
            type: "AdaptiveCard",
            body: [
              {
                type: "TextBlock",
                text: "📄 Subscription Activated",
                weight: "Bolder",
                color: "Good"
              },
              {
                type: "FactSet",
                facts: [
                  { title: "Customer", value: s.customer.email },
                  { title: "Product", value: s.product_id },
                  { title: "Amount", value: `$${(s.recurring_pre_tax_amount / 100).toFixed(2)}/${s.payment_frequency_interval}` },
                  { title: "Next Billing", value: new Date(s.next_billing_date).toLocaleDateString() }
                ]
              }
            ]
          }
        }]
      };
      break;
    case "subscription.cancelled":
      webhook.payload = {
        type: "message",
        attachments: [{
          contentType: "application/vnd.microsoft.card.adaptive",
          content: {
            type: "AdaptiveCard",
            body: [
              {
                type: "TextBlock",
                text: "⚠️ Subscription Cancelled",
                weight: "Bolder",
                color: "Warning"
              },
              {
                type: "FactSet",
                facts: [
                  { title: "Customer", value: s.customer.email },
                  { title: "Product", value: s.product_id },
                  { title: "Cancelled At", value: new Date(s.cancelled_at).toLocaleDateString() }
                ]
              }
            ]
          }
        }]
      };
      break;
  }
  return webhook;
}
```

### Dispute-Benachrichtigungen

Dieses Beispiel veröffentlicht für jedes `dispute.*`-Ereignis eine Karte. Titel und Farbe ändern sich, wenn ein Dispute gewonnen oder verloren wird.

```javascript dispute_card.js icon="js" expandable theme={null}
function handler(webhook) {
  if (webhook.eventType.startsWith("dispute.")) {
    const d = webhook.payload.data;
    const color = d.dispute_status === "dispute_won" ? "Good" : d.dispute_status === "dispute_lost" ? "Attention" : "Warning";
    const title = d.dispute_status === "dispute_won" ? "🏆 Dispute Won" : d.dispute_status === "dispute_lost" ? "❌ Dispute Lost" : "🚨 Dispute Update";
    
    webhook.payload = {
      type: "message",
      attachments: [{
        contentType: "application/vnd.microsoft.card.adaptive",
        content: {
          type: "AdaptiveCard",
          body: [
            {
              type: "TextBlock",
              text: title,
              weight: "Bolder",
              color: color
            },
            {
              type: "FactSet",
              facts: [
                { title: "Payment ID", value: d.payment_id },
                { title: "Amount", value: `$${(d.amount / 100).toFixed(2)}` },
                { title: "Status", value: d.dispute_status },
                { title: "Stage", value: d.dispute_stage }
              ]
            }
          ]
        }
      }]
    };
  }
  return webhook;
}
```

## Tipps

* Verwenden Sie Adaptive Cards für eine ansprechende, interaktive Formatierung.
* Wählen Sie Farben nach ihrer Bedeutung: `Good` (grün), `Warning` (gelb) und `Attention` (rot).
* Halten Sie Faktensammlungen kurz und übersichtlich.
* Öffnen Sie vor der Verwendung des Endpunkts dessen Registerkarte **Testing** und klicken Sie auf **Send example**, um eine Beispielkarte in Ihrem Kanal zu veröffentlichen.

## Fehlerbehebung

> [accordion] No Messages in Teams
>
> * Überprüfen Sie, ob die Webhook-URL korrekt ist und der Workflow aktiviert wurde.
> * Überprüfen Sie, ob die Transformation gültiges Adaptive-Card-JSON zurückgibt.
> * Überprüfen Sie, ob der Workflow die Berechtigung hat, im Kanal zu veröffentlichen.

> [accordion] Card Formatting Issues
>
> * Führen Sie die Transformation unter **Test this code** aus und überprüfen Sie das Ergebnis anhand des Adaptive-Card-Schemas.
> * Überprüfen Sie, ob alle erforderlichen Felder vorhanden sind.
> * Überprüfen Sie, ob die Farbwerte gültig sind, z. B. `Default`, `Good`, `Warning` oder `Attention`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.