← Stripe + Trengo integrations

Send A Message with Trengo API on New Custom Webhook Events from Stripe API

Pipedream makes it easy to connect APIs for Trengo, Stripe and 1000+ other apps remarkably fast.

Trigger workflow on
New Custom Webhook Events from the Stripe API
Next, do this
Send A Message with the Trengo API
No credit card required
Into to Pipedream
Watch us build a workflow
Watch us build a workflow
7 min
Watch now ➜

Trusted by 500,000+ developers from startups to Fortune 500 companies

Adyen logo
Brex logo
Carta logo
Checkr logo
Chameleon logo
DevRev logo
LinkedIn logo
Netflix logo
New Relic logo
OnDeck logo
Replicated logo
Scale AI logo
Teamwork logo
Warner Bros. logo
Xendit logo

Developers Pipedream

Getting Started

This integration creates a workflow with a Stripe trigger and Trengo action. When you configure and deploy the workflow, it will run on Pipedream's servers 24x7 for free.

  1. Select this integration
  2. Configure the New Custom Webhook Events trigger
    1. Connect your Stripe account
    2. Select one or more Events
  3. Configure the Send A Message action
    1. Connect your Trengo account
    2. Select a Channel ID
    3. Configure Identifier
    4. Configure Name
    5. Configure Message
    6. Optional- Configure Email Subject
  4. Deploy the workflow
  5. Send a test event to validate your setup
  6. Turn on the trigger

Details

This integration uses pre-built, source-available components from Pipedream's GitHub repo. These components are developed by Pipedream and the community, and verified and maintained by Pipedream.

To contribute an update to an existing component or create a new component, create a PR on GitHub. If you're new to Pipedream component development, you can start with quickstarts for trigger span and action development, and then review the component API reference.

Trigger

Description:Emit new event on each webhook event
Version:0.0.5
Key:stripe-custom-webhook-events

Stripe Overview

With Stripe, you can easily accept payments online. Stripe provides a simple
and powerful way to accept payments over the internet. With Stripe, you can
easily

  • Accept payments from major credit and debit cards
  • Process payments in over 130 currencies
  • Set up recurring billing
  • Accept Apple Pay, Google Pay, and other alternative payment methods
  • And much more!

Trigger Code

import stripe from "../../stripe.app.mjs";
import constants from "../common/constants.mjs";

export default {
  key: "stripe-custom-webhook-events",
  name: "New Custom Webhook Events",
  type: "source",
  version: "0.0.5",
  description: "Emit new event on each webhook event",
  props: {
    stripe,
    enabledEvents: {
      type: "string[]",
      label: "Events",
      description: "Events to listen for. Select `*` for all events",
      options: constants.WEBHOOK_EVENTS,
      default: [
        "*",
      ],
    },
    /* eslint-disable pipedream/props-label */
    /* eslint-disable pipedream/props-description */
    http: {
      type: "$.interface.http",
      customResponse: true,
    },
    /* eslint-enable pipedream/props-description */
    /* eslint-enable pipedream/props-label */
    db: "$.service.db",
  },
  hooks: {
    async activate() {
      let enabledEvents = this.enabledEvents;
      if (enabledEvents.includes("*")) enabledEvents = [
        "*",
      ];
      const endpoint = await this.stripe.sdk().webhookEndpoints.create({
        url: this.http.endpoint,
        enabled_events: enabledEvents,
      });
      this.db.set("endpoint", JSON.stringify(endpoint));

      for (const eventType of this.enabledEvents) {
        const events = await this.stripe.getEvents({
          eventType,
        });

        for (const event of events) {
          this.emit(event);
        }
      }
    },
    async deactivate() {
      const endpoint = this.getEndpoint();
      this.db.set("endpoint", null);
      if (!endpoint) return;
      const confirmation = await this.stripe.sdk().webhookEndpoints.del(endpoint.id);
      if ("deleted" in confirmation && !confirmation.deleted) {
        throw new Error("endpoint not deleted");
      }
    },
  },
  run(event) {
    const endpoint = this.getEndpoint();
    if (!endpoint) {
      this.http.respond({
        status: 500,
      });
      throw new Error("endpoint config missing from db");
    }
    const sig = event.headers["stripe-signature"];
    try {
      event = this.stripe.sdk().webhooks.constructEvent(event.bodyRaw, sig, endpoint.secret);
    } catch (err) {
      this.http.respond({
        status: 400,
        body: err.message,
      });
      console.log(err.message);
      return;
    }
    this.http.respond({
      status: 200,
    });

    this.emit(event);
  },
  methods: {
    emit(event) {
      this.$emit(event, {
        id: event.id,
        summary: `New event ${event.type} with id ${event.data.id}`,
        ts: Date.parse(event.created),
      });
    },
    getEndpoint() {
      let endpoint;
      const endpointJson = this.db.get("endpoint");
      try {
        endpoint = JSON.parse(endpointJson);
      } catch (err) {
        console.error(err);
      }
      return endpoint;
    },
  },
};

Trigger Configuration

This component may be configured based on the props defined in the component code. Pipedream automatically prompts for input values in the UI and CLI.
LabelPropTypeDescription
StripestripeappThis component uses the Stripe app.
EventsenabledEventsstring[]Select a value from the drop down menu:*account.application.authorizedaccount.application.deauthorizedaccount.external_account.createdaccount.external_account.deletedaccount.external_account.updatedaccount.updatedapplication_fee.createdapplication_fee.refund.updatedapplication_fee.refundedbalance.availablecapability.updatedcharge.capturedcharge.dispute.closedcharge.dispute.createdcharge.dispute.funds_reinstatedcharge.dispute.funds_withdrawncharge.dispute.updatedcharge.expiredcharge.failedcharge.pendingcharge.refund.updatedcharge.refundedcharge.succeededcharge.updatedcheckout.session.async_payment_failedcheckout.session.async_payment_succeededcheckout.session.completedcoupon.createdcoupon.deletedcoupon.updatedcredit_note.createdcredit_note.updatedcredit_note.voidedcustomer.createdcustomer.deletedcustomer.discount.createdcustomer.discount.deletedcustomer.discount.updatedcustomer.source.createdcustomer.source.deletedcustomer.source.expiringcustomer.source.updatedcustomer.subscription.createdcustomer.subscription.deletedcustomer.subscription.pending_update_appliedcustomer.subscription.pending_update_expiredcustomer.subscription.trial_will_endcustomer.subscription.updatedcustomer.tax_id.createdcustomer.tax_id.deletedcustomer.tax_id.updatedcustomer.updatedfile.createdinvoice.createdinvoice.deletedinvoice.finalizedinvoice.marked_uncollectibleinvoice.paidinvoice.payment_action_requiredinvoice.payment_failedinvoice.payment_succeededinvoice.sentinvoice.upcominginvoice.updatedinvoice.voidedinvoiceitem.createdinvoiceitem.deletedinvoiceitem.updatedissuing_authorization.createdissuing_authorization.requestissuing_authorization.updatedissuing_card.createdissuing_card.updatedissuing_cardholder.createdissuing_cardholder.updatedissuing_dispute.createdissuing_dispute.funds_reinstatedissuing_dispute.updatedissuing_transaction.createdissuing_transaction.updatedmandate.updatedorder.createdorder.payment_failedorder.payment_succeededorder.updatedorder_return.createdpayment_intent.amount_capturable_updatedpayment_intent.canceledpayment_intent.createdpayment_intent.payment_failedpayment_intent.processingpayment_intent.succeededpayment_method.attachedpayment_method.card_automatically_updatedpayment_method.detachedpayment_method.updatedpayout.canceledpayout.createdpayout.failedpayout.paidpayout.updatedperson.createdperson.deletedperson.updatedplan.createdplan.deletedplan.updatedprice.createdprice.deletedprice.updatedproduct.createdproduct.deletedproduct.updatedradar.early_fraud_warning.createdradar.early_fraud_warning.updatedrecipient.createdrecipient.deletedrecipient.updatedreporting.report_run.failedreporting.report_run.succeededreporting.report_type.updatedreview.closedreview.openedsetup_intent.canceledsetup_intent.createdsetup_intent.setup_failedsetup_intent.succeededsigma.scheduled_query_run.createdsku.createdsku.deletedsku.updatedsource.canceledsource.chargeablesource.failedsource.mandate_notificationsource.refund_attributes_requiredsource.transaction.createdsource.transaction.updatedsubscription_schedule.abortedsubscription_schedule.canceledsubscription_schedule.completedsubscription_schedule.createdsubscription_schedule.expiringsubscription_schedule.releasedsubscription_schedule.updatedtax_rate.createdtax_rate.updatedtopup.canceledtopup.createdtopup.failedtopup.reversedtopup.succeededtransfer.createdtransfer.failedtransfer.paidtransfer.reversedtransfer.updated
N/Ahttp$.interface.httpThis component uses $.interface.http to generate a unique URL when the component is first instantiated. Each request to the URL will trigger the run() method of the component.
N/Adb$.service.dbThis component uses $.service.db to maintain state between executions.

Trigger Authentication

Stripe uses API keys for authentication. When you connect your Stripe account, Pipedream securely stores the keys so you can easily authenticate to Stripe APIs in both code and no-code steps.

Stripe uses API keys to authenticate requests (more info in their docs here).

To connect Pipedream to your Stripe account,

  1. Create a Stripe API key
  2. Make sure to create either a Secret or Restricted key
  3. Enter the API key below

To help ensure proper security, we recommend you create a Restricted key, and only allow access to operations you need require in Pipedream.

About Stripe

Payment Platform

Action

Description:This action can be used to easily send a message or an email without having to think about contacts or tickets, [See the docs](https://developers.trengo.com/reference/send-a-message-1)
Version:0.0.1
Key:trengo-send-a-message

Trengo Overview

You can build amazing customer service experiences by using the Trengo API.
It's the platform to help teams work better together, and offers features to
optimize your customer conversation. For example, you can use Trengo to:

  • Improve customer service by leveraging automation for fast and personalized
    responses
  • Increase efficiency by optimizing operational workflows
  • Gather insights from customer conversations to improve customer service
  • Automate conversations like welcome messages and error notifications
  • Filter and manage incoming conversations to make sure the right person
    provides the right answers

These are just some of the examples of what you can do with the Trengo API.
With the Trengo platform, you can make sure your customer conversations deliver
the best possible outcomes, consistently.

Action Code

import app from "../../trengo.app.mjs";

export default {
  type: "action",
  key: "trengo-send-a-message",
  version: "0.0.1",
  name: "Send A Message",
  description: "This action can be used to easily send a message or an email without having to think about contacts or tickets, [See the docs](https://developers.trengo.com/reference/send-a-message-1)",
  props: {
    app,
    channelId: {
      propDefinition: [
        app,
        "channelId",
      ],
    },
    contactIdentifier: {
      propDefinition: [
        app,
        "contactIdentifier",
      ],
      description: "The destination of the message. Based on the `Channel ID` this must be en email address or phone number.",
    },
    contactName: {
      propDefinition: [
        app,
        "contactName",
      ],
      description: "The name of the contact. Only used when the contact does not already exists.",
    },
    message: {
      propDefinition: [
        app,
        "message",
      ],
    },
    emailSubject: {
      propDefinition: [
        app,
        "emailSubject",
      ],
    },
  },
  async run ({ $ }) {
    const resp = await this.app.sendMessage({
      $,
      data: {
        channel_id: this.channelId,
        contact_identifier: this.contactIdentifier,
        contact_name: this.contactName,
        message: this.message,
        email_subject: this.emailSubject,
      },
    });
    $.export("$summary", "The message has been sent");
    return resp;
  },
};

Action Configuration

This component may be configured based on the props defined in the component code. Pipedream automatically prompts for input values in the UI.

LabelPropTypeDescription
TrengoappappThis component uses the Trengo app.
Channel IDchannelIdintegerSelect a value from the drop down menu.
IdentifiercontactIdentifierstring

The destination of the message. Based on the Channel ID this must be en email address or phone number.

NamecontactNamestring

The name of the contact. Only used when the contact does not already exists.

Messagemessagestring

The message send to the receiver.

Email SubjectemailSubjectstring

The subject of the message. Only used when the message is an email.

Action Authentication

Trengo uses API keys for authentication. When you connect your Trengo account, Pipedream securely stores the keys so you can easily authenticate to Trengo APIs in both code and no-code steps.

You need a personal access token to access the API and to perform actions on your behalf. Your personal access token needs to be send trough an Authorization Bearer request. See docs.

About Trengo

Customer service software

More Ways to Connect Trengo + Stripe

Create Contact with Trengo API on New Custom Webhook Events from Stripe API
Stripe + Trengo
 
Try it
Find Contacts with Trengo API on New Custom Webhook Events from Stripe API
Stripe + Trengo
 
Try it
Log A Voice Call with Trengo API on New Custom Webhook Events from Stripe API
Stripe + Trengo
 
Try it
Send A Team Chat Message with Trengo API on New Custom Webhook Events from Stripe API
Stripe + Trengo
 
Try it
Send A WhatsApp Message Template with Trengo API on New Custom Webhook Events from Stripe API
Stripe + Trengo
 
Try it
New Custom Webhook Events from the Stripe API

Emit new event on each webhook event

 
Try it
New Inbound Message Event from the Trengo API

Emit new events when an inbound message received. See the docs here

 
Try it
New Internal Note Event from the Trengo API

Emit new events when a internal note added. See the docs here

 
Try it
New Outbound Message Event from the Trengo API

Emit new events when an outbound message sent. See the docs here

 
Try it
New Phone Call Ended Event from the Trengo API

Emit new events when an phone call ended. See the docs here

 
Try it
Cancel a Payment Intent with the Stripe API

Cancel a payment intent. Once canceled, no additional charges will be made by the payment intent and any operations on the payment intent will fail with an error. For payment intents with status=requires_capture, the remaining amount_capturable will automatically be refunded. See the docs for more information

 
Try it
Cancel Or Reverse a Payout with the Stripe API

Cancel or reverse a payout. A payout can be canceled only if it has not yet been paid out. A payout can be reversed only if it has already been paid out. Funds will be refunded to your available balance. See the docs for more information

 
Try it
Capture a Payment Intent with the Stripe API

Capture the funds of an existing uncaptured payment intent. See the docs for more information

 
Try it
Confirm a Payment Intent with the Stripe API

Confirm that your customer intends to pay with current or provided payment method. Upon confirmation, Stripe will attempt to initiate a payment. See the docs for more information

 
Try it
Create a Customer with the Stripe API

Create a customer. See the docs for more information

 
Try it