← Sendblue

New Message Received from Sendblue API

Pipedream makes it easy to connect APIs for Sendblue and 3,000+ other apps remarkably fast.

Trigger workflow on
New Message Received from the Sendblue API
Next, do this
Connect to 3,000+ APIs using code and no-code building blocks
No credit card required
Intro to Pipedream
Watch us build a workflow
Watch us build a workflow
8 min
Watch now ➜

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

Adyen logo
Appcues logo
Bandwidth logo
Checkr logo
ChartMogul logo
Dataminr logo
Gopuff logo
Gorgias logo
LinkedIn logo
Logitech logo
Replicated logo
Rudderstack logo
SAS logo
Scale AI logo
Webflow logo
Warner Bros. logo
Adyen logo
Appcues logo
Bandwidth logo
Checkr logo
ChartMogul logo
Dataminr logo
Gopuff logo
Gorgias logo
LinkedIn logo
Logitech logo
Replicated logo
Rudderstack logo
SAS logo
Scale AI logo
Webflow logo
Warner Bros. logo

Developers Pipedream

Getting Started

Trigger a workflow on New Message Received with Sendblue API. When you configure and deploy the workflow, it will run on Pipedream's servers 24x7 for free.

  1. Configure the New Message Received trigger
    1. Connect your Sendblue account
    2. Configure timer
    3. Optional- Configure Account Email
    4. Optional- Configure From Number
    5. Optional- Configure To Number
    6. Optional- Configure Group ID
    7. Optional- Select a Message Type
    8. Optional- Select a Service Type
    9. Optional- Select a Status
    10. Optional- Select a Order By
    11. Optional- Select a Order Direction
    12. Optional- Configure Limit
  2. Add steps to connect to 3,000+ APIs using code and no-code building blocks
  3. Deploy the workflow
  4. Send a test event to validate your setup
  5. Turn on the trigger

Details

This is a pre-built, source-available component from Pipedream's GitHub repo. The component is 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.

New Message Received on Sendblue
Description:Emit new event when a new inbound message is received. [See the documentation](https://docs.sendblue.com/api/resources/messages/methods/list)
Version:0.0.1
Key:sendblue-new-message-received

Code

import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";
import app from "../../sendblue.app.mjs";

export default {
  key: "sendblue-new-message-received",
  name: "New Message Received",
  description: "Emit new event when a new inbound message is received. [See the documentation](https://docs.sendblue.com/api/resources/messages/methods/list)",
  version: "0.0.1",
  type: "source",
  dedupe: "unique",
  props: {
    app,
    db: "$.service.db",
    timer: {
      type: "$.interface.timer",
      default: {
        intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
      },
    },
    accountEmail: {
      propDefinition: [
        app,
        "accountEmail",
      ],
    },
    fromNumberFilter: {
      propDefinition: [
        app,
        "fromNumberFilter",
      ],
    },
    toNumberFilter: {
      propDefinition: [
        app,
        "toNumberFilter",
      ],
    },
    groupIdFilter: {
      propDefinition: [
        app,
        "groupIdFilter",
      ],
    },
    messageTypeFilter: {
      propDefinition: [
        app,
        "messageTypeFilter",
      ],
    },
    serviceFilter: {
      propDefinition: [
        app,
        "serviceFilter",
      ],
    },
    statusFilter: {
      propDefinition: [
        app,
        "statusFilter",
      ],
    },
    orderBy: {
      propDefinition: [
        app,
        "orderBy",
      ],
    },
    orderDirection: {
      propDefinition: [
        app,
        "orderDirection",
      ],
    },
    limit: {
      propDefinition: [
        app,
        "limit",
      ],
    },
  },
  hooks: {
    async deploy() {
      await this.processEvent(25);
      this._setIsFirstRun(false);
    },
  },
  methods: {
    _getLastTimestamp() {
      return this.db.get("lastTimestamp") || 0;
    },
    _setLastTimestamp(timestamp) {
      this.db.set("lastTimestamp", timestamp);
    },
    _getIsFirstRun() {
      return this.db.get("isFirstRun") !== false;
    },
    _setIsFirstRun(value) {
      this.db.set("isFirstRun", value);
    },
    async processEvent(max) {
      const lastTimestamp = this._getLastTimestamp();

      // Build query params from user-selected filters
      const params = {
        is_outbound: false,
        limit: this.limit || 50,
      };

      if (this.accountEmail) {
        params.account_email = this.accountEmail;
      }

      if (this.fromNumberFilter) {
        params.from_number = this.fromNumberFilter;
      }

      if (this.toNumberFilter) {
        params.to_number = this.toNumberFilter;
      }

      if (this.groupIdFilter) {
        params.group_id = this.groupIdFilter;
      }

      if (this.messageTypeFilter) {
        params.message_type = this.messageTypeFilter;
      }

      if (this.serviceFilter) {
        params.service = this.serviceFilter;
      }

      if (this.statusFilter) {
        params.status = this.statusFilter;
      }

      if (this.orderBy) {
        params.order_by = this.orderBy;
      }

      if (this.orderDirection) {
        params.order_direction = this.orderDirection;
      }

      const response = await this.app.listMessages({
        params,
      });

      const messages = response.data || [];

      if (!messages.length) {
        return;
      }

      // Filter for messages newer than the last timestamp
      // Use date_updated as the reliable timestamp field
      const newMessages = messages.filter((message) => {
        const dateToUse = message.date_updated || message.date_sent;
        const messageTime = new Date(dateToUse).getTime();
        return messageTime > lastTimestamp;
      }).slice(0, max);

      if (newMessages.length > 0) {
        // Update the last timestamp to the most recent message
        const mostRecentTime = Math.max(...newMessages.map((m) => {
          const dateToUse = m.date_updated || m.date_sent;
          return new Date(dateToUse).getTime();
        }));
        this._setLastTimestamp(mostRecentTime);
      }

      newMessages.forEach((message) => {
        const meta = this.generateMeta(message);
        this.$emit(message, meta);
      });
    },
    generateMeta(message) {
      const dateToUse = message.date_updated || message.date_sent;
      return {
        id: message.message_handle,
        summary: `New message from ${message.from_number}`,
        ts: new Date(dateToUse).getTime(),
      };
    },
  },
  async run() {
    // Skip first run since deploy hook already executed processEvent
    if (this._getIsFirstRun()) {
      this._setIsFirstRun(false);
      return;
    }
    await this.processEvent();
  },
};

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
SendblueappappThis component uses the Sendblue app.
N/Adb$.service.dbThis component uses $.service.db to maintain state between executions.
timer$.interface.timer
Account EmailaccountEmailstring

Filter by account email

From NumberfromNumberFilterstring

Filter by sender phone number

To NumbertoNumberFilterstring

Filter by recipient phone number

Group IDgroupIdFilterstring

Filter by group ID

Message TypemessageTypeFilterstringSelect a value from the drop down menu:{ "label": "Direct Message", "value": "message" }{ "label": "Group Message", "value": "group" }
Service TypeserviceFilterstringSelect a value from the drop down menu:{ "label": "iMessage", "value": "iMessage" }{ "label": "SMS", "value": "SMS" }
StatusstatusFilterstringSelect a value from the drop down menu:REGISTEREDPENDINGSENTDELIVEREDRECEIVEDQUEUEDERRORDECLINEDACCEPTEDSUCCESS
Order ByorderBystringSelect a value from the drop down menu:{ "label": "Created At", "value": "createdAt" }{ "label": "Updated At", "value": "updatedAt" }{ "label": "Sent At", "value": "sentAt" }
Order DirectionorderDirectionstringSelect a value from the drop down menu:{ "label": "Ascending", "value": "asc" }{ "label": "Descending", "value": "desc" }
Limitlimitinteger

Maximum number of messages to return (1-1000)

Authentication

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

Sign in and copy your API keys from the API Dashboard page

About Sendblue

Simple iMessage API ready for scale.

More Ways to Use Sendblue

Triggers

New Message Received (Instant) from the Sendblue API

Emit new event when a new inbound message is received. See the documentation

 
Try it

Actions

Get Contact List with the Sendblue API

Retrieve a list of your existing contacts from Sendblue. See the documentation

 
Try it
Send Group Message with the Sendblue API

Send a message to a group of recipients in an iMessage group

 
Try it
Send Message with the Sendblue API

Send an iMessage or SMS to a specific phone number. See the documentation

 
Try it

Explore Other Apps

1
-
24
of
3,000+
apps by most popular

Node
Node
Anything you can do with Node.js, you can do in a Pipedream workflow. This includes using most of npm's 400,000+ packages.
Python
Python
Anything you can do in Python can be done in a Pipedream Workflow. This includes using any of the 350,000+ PyPi packages available in your Python powered workflows.
Notion
Notion
Notion is a new tool that blends your everyday work apps into one. It's the all-in-one workspace for you and your team.
OpenAI (ChatGPT)
OpenAI (ChatGPT)
OpenAI is an AI research and deployment company with the mission to ensure that artificial general intelligence benefits all of humanity. They are the makers of popular models like ChatGPT, DALL-E, and Whisper.
Anthropic (Claude)
Anthropic (Claude)
AI research and products that put safety at the frontier. Introducing Claude, a next-generation AI assistant for your tasks, no matter the scale.
Google Sheets
Google Sheets
Use Google Sheets to create and edit online spreadsheets. Get insights together with secure sharing in real-time and from any device.
Telegram
Telegram
Telegram, is a cloud-based, cross-platform, encrypted instant messaging (IM) service.
Google Drive
Google Drive
Google Drive is a file storage and synchronization service which allows you to create and share your work online, and access your documents from anywhere.
HTTP / Webhook
HTTP / Webhook
Get a unique URL where you can send HTTP or webhook requests
Google Calendar
Google Calendar
With Google Calendar, you can quickly schedule meetings and events and get reminders about upcoming activities, so you always know what’s next.
Schedule
Schedule
Trigger workflows on an interval or cron schedule.
Pipedream Utils
Pipedream Utils
Utility functions to use within your Pipedream workflows
Shopify
Shopify
Shopify is a complete commerce platform that lets anyone start, manage, and grow a business. You can use Shopify to build an online store, manage sales, market to customers, and accept payments in digital and physical locations.
Supabase
Supabase
Supabase is an open source Firebase alternative.
MySQL
MySQL
MySQL is an open-source relational database management system.
PostgreSQL
PostgreSQL
PostgreSQL is a free and open-source relational database management system emphasizing extensibility and SQL compliance.
AWS
AWS
Premium
Amazon Web Services (AWS) offers reliable, scalable, and inexpensive cloud computing services.
Twilio SendGrid
Twilio SendGrid
Premium
Send marketing and transactional email through the Twilio SendGrid platform with the Email API, proprietary mail transfer agent, and infrastructure for scalable delivery.
Amazon SES
Amazon SES
Amazon SES is a cloud-based email service provider that can integrate into any application for high volume email automation
Klaviyo
Klaviyo
Premium
Klaviyo unifies your data, channels, and AI agents in one platform—text, WhatsApp, email marketing, and more—driving growth with every interaction.
Zendesk
Zendesk
Premium
Zendesk is award-winning customer service software trusted by 200K+ customers. Make customers happy via text, mobile, phone, email, live chat, social media.
ServiceNow
ServiceNow
Premium
Beta
The smarter way to workflow
Slack
Slack
Slack is the AI-powered platform for work bringing all of your conversations, apps, and customers together in one place. Around the world, Slack is helping businesses of all sizes grow and send productivity through the roof.
Microsoft Teams
Microsoft Teams
Microsoft Teams has communities, events, chats, channels, meetings, storage, tasks, and calendars in one place.