Skip to content

[TRIGGER] New SMS in Aircall #17538

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 10, 2025
Merged

[TRIGGER] New SMS in Aircall #17538

merged 1 commit into from
Jul 10, 2025

Conversation

jcortes
Copy link
Collaborator

@jcortes jcortes commented Jul 8, 2025

WHY

Resolves #17285

Summary by CodeRabbit

  • New Features

    • Added a new trigger to emit events when a new SMS is received in Aircall.
  • Bug Fixes

    • Corrected how webhook IDs are stored for Aircall webhook triggers to ensure proper event tracking.
  • Chores

    • Updated version numbers for several Aircall triggers and the overall package.

Copy link

vercel bot commented Jul 8, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs-v2 ⬜️ Ignored (Inspect) Jul 10, 2025 3:19pm
pipedream-docs ⬜️ Ignored (Inspect) Jul 10, 2025 3:19pm
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Jul 10, 2025 3:19pm

Copy link
Contributor

coderabbitai bot commented Jul 8, 2025

Warning

Rate limit exceeded

@jcortes has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 15 minutes and 5 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 72fa924 and 9d6b420.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (7)
  • components/aircall/package.json (1 hunks)
  • components/aircall/sources/common/common-webhook.mjs (1 hunks)
  • components/aircall/sources/new-call-ended/new-call-ended.mjs (1 hunks)
  • components/aircall/sources/new-note-added/new-note-added.mjs (1 hunks)
  • components/aircall/sources/new-number-created/new-number-created.mjs (1 hunks)
  • components/aircall/sources/new-sms/new-sms.mjs (1 hunks)
  • components/aircall/sources/new-tag-added/new-tag-added.mjs (1 hunks)

Walkthrough

A new "New SMS" trigger source was added for Aircall, emitting events when an SMS is received. The webhook ID assignment in the common webhook logic was updated, and version numbers were incremented in several Aircall-related files. No other functional changes were introduced.

Changes

File(s) Change Summary
components/aircall/sources/new-sms/new-sms.mjs Added new source module for "New SMS" trigger in Aircall, with event handling and metadata logic.
components/aircall/sources/common/common-webhook.mjs Changed webhook ID assignment from webhook.id to webhook.webhook_id.
components/aircall/package.json Updated package version from 0.1.1 to 0.2.0.
components/aircall/sources/new-call-ended/new-call-ended.mjs
components/aircall/sources/new-note-added/new-note-added.mjs
components/aircall/sources/new-number-created/new-number-created.mjs
components/aircall/sources/new-tag-added/new-tag-added.mjs
Incremented version numbers in default exports.

Sequence Diagram(s)

sequenceDiagram
    participant Aircall API
    participant CommonWebhookSource
    participant NewSMSSource

    Aircall API-->>CommonWebhookSource: Sends "message.received" webhook
    CommonWebhookSource->>NewSMSSource: Passes event data
    NewSMSSource->>NewSMSSource: generateMeta(event)
    NewSMSSource-->>CommonWebhookSource: Emits event with metadata
Loading

Assessment against linked issues

Objective Addressed Explanation
Implement a "New SMS" trigger source for Aircall that emits events on incoming SMS (Issue #17285)
Ensure the trigger uses the correct Aircall webhook event type and constructs appropriate metadata (#17285)

Poem

A bunny hops with glee today,
For Aircall texts now light the way!
With every SMS that’s new,
Triggers hop in—yes, it’s true!
Webhooks set and versions rise,
🐇✨ Aircall’s magic multiplies!

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
components/aircall/sources/new-sms/new-sms.mjs (2)

16-18: Confirm Aircall event type constant

message.received is correct for inbound SMS, but Aircall’s docs also emit message.sent. If you plan to cover both directions later, consider parameterising or renaming to sms-received for clarity.


3-10: Minor metadata alignment

The component’s description should start with a verb per Pipedream guidelines (e.g., “Emit an event when…”).
Also bumping the package to 0.2.0 while the source stays 0.0.1 is fine, but remember to increment this source when behaviour changes.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between aca5029 and 508d866.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (6)
  • components/aircall/package.json (1 hunks)
  • components/aircall/sources/common/common-webhook.mjs (1 hunks)
  • components/aircall/sources/new-call-ended/new-call-ended.mjs (1 hunks)
  • components/aircall/sources/new-note-added/new-note-added.mjs (1 hunks)
  • components/aircall/sources/new-number-created/new-number-created.mjs (1 hunks)
  • components/aircall/sources/new-sms/new-sms.mjs (1 hunks)
🧰 Additional context used
🧠 Learnings (5)
components/aircall/sources/new-note-added/new-note-added.mjs (1)
Learnt from: GTFalcao
PR: PipedreamHQ/pipedream#15376
File: components/monday/sources/name-updated/name-updated.mjs:6-6
Timestamp: 2025-01-23T03:55:15.166Z
Learning: Source names in Monday.com components don't need to start with "New" if they emit events for updated items (e.g., "Name Updated", "Column Value Updated") rather than new items. This follows the component guidelines exception where the "New" prefix is only required when emits are limited to new items.
components/aircall/package.json (1)
Learnt from: jcortes
PR: PipedreamHQ/pipedream#14935
File: components/sailpoint/package.json:15-18
Timestamp: 2024-12-12T19:23:09.039Z
Learning: When developing Pipedream components, do not add built-in Node.js modules like `fs` to `package.json` dependencies, as they are native modules provided by the Node.js runtime.
components/aircall/sources/new-number-created/new-number-created.mjs (1)
Learnt from: GTFalcao
PR: PipedreamHQ/pipedream#15376
File: components/monday/sources/name-updated/name-updated.mjs:6-6
Timestamp: 2025-01-23T03:55:15.166Z
Learning: Source names in Monday.com components don't need to start with "New" if they emit events for updated items (e.g., "Name Updated", "Column Value Updated") rather than new items. This follows the component guidelines exception where the "New" prefix is only required when emits are limited to new items.
components/aircall/sources/common/common-webhook.mjs (2)
Learnt from: GTFalcao
PR: PipedreamHQ/pipedream#12697
File: components/salesforce_rest_api/sources/common-webhook-methods.mjs:1-71
Timestamp: 2024-10-08T15:33:38.240Z
Learning: The `common-webhook-methods.mjs` object is designed to be extended, similar to an abstract class, and intentionally does not implement certain methods like `generateWebhookMeta` and `getEventType` to enforce implementation in subclasses.
Learnt from: GTFalcao
PR: PipedreamHQ/pipedream#12697
File: components/salesforce_rest_api/sources/common-webhook-methods.mjs:1-71
Timestamp: 2024-07-24T02:06:47.016Z
Learning: The `common-webhook-methods.mjs` object is designed to be extended, similar to an abstract class, and intentionally does not implement certain methods like `generateWebhookMeta` and `getEventType` to enforce implementation in subclasses.
components/aircall/sources/new-sms/new-sms.mjs (3)
Learnt from: GTFalcao
PR: PipedreamHQ/pipedream#12697
File: components/salesforce_rest_api/sources/common-webhook-methods.mjs:1-71
Timestamp: 2024-10-08T15:33:38.240Z
Learning: The `common-webhook-methods.mjs` object is designed to be extended, similar to an abstract class, and intentionally does not implement certain methods like `generateWebhookMeta` and `getEventType` to enforce implementation in subclasses.
Learnt from: GTFalcao
PR: PipedreamHQ/pipedream#12697
File: components/salesforce_rest_api/sources/common-webhook-methods.mjs:1-71
Timestamp: 2024-07-24T02:06:47.016Z
Learning: The `common-webhook-methods.mjs` object is designed to be extended, similar to an abstract class, and intentionally does not implement certain methods like `generateWebhookMeta` and `getEventType` to enforce implementation in subclasses.
Learnt from: GTFalcao
PR: PipedreamHQ/pipedream#15376
File: components/monday/sources/name-updated/name-updated.mjs:6-6
Timestamp: 2025-01-23T03:55:15.166Z
Learning: Source names in Monday.com components don't need to start with "New" if they emit events for updated items (e.g., "Name Updated", "Column Value Updated") rather than new items. This follows the component guidelines exception where the "New" prefix is only required when emits are limited to new items.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Publish TypeScript components
  • GitHub Check: Verify TypeScript components
  • GitHub Check: Lint Code Base
  • GitHub Check: pnpm publish
🔇 Additional comments (5)
components/aircall/package.json (1)

3-3: LGTM! Appropriate version bump for new features.

The minor version bump from 0.1.1 to 0.2.0 correctly follows semantic versioning for the addition of new SMS trigger functionality.

components/aircall/sources/new-call-ended/new-call-ended.mjs (1)

8-8: LGTM! Appropriate patch version bump.

The patch version increment from 0.0.2 to 0.0.3 is correct since no functional changes were made to this component.

components/aircall/sources/new-number-created/new-number-created.mjs (1)

8-8: LGTM! Appropriate patch version bump.

The patch version increment from 0.0.2 to 0.0.3 is correct since no functional changes were made to this component.

components/aircall/sources/new-note-added/new-note-added.mjs (1)

8-8: LGTM! Appropriate patch version bump.

The patch version increment from 0.0.2 to 0.0.3 is correct since no functional changes were made to this component.

components/aircall/sources/common/common-webhook.mjs (1)

24-24: LGTM – Webhook ID property updated consistently

  • All instances of the old webhook.id reference have been replaced with webhook.webhook_id.
  • Verified in:
    components/aircall/sources/common/common-webhook.mjs (activate/deactivate flows)
    components/aircall/aircall.app.mjs (createWebhook/deleteWebhook)
  • No remaining mismatches detected; the change correctly aligns with the API wrapper’s response handling.

Comment on lines +19 to +25
generateMeta(data) {
return {
id: data.id,
summary: `New SMS received from ${data.raw_digits} to ${data.number.digits}`,
ts: data.created_at,
};
},
Copy link
Contributor

@coderabbitai coderabbitai bot Jul 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Harden generateMeta to avoid runtime crashes + ensure correct timestamp type

data.number can be null for ported numbers, and created_at is an ISO string.
Pipedream expects ts in milliseconds since epoch, so passing the raw ISO string may break sorting / dedupe. Defensive access & conversion fixes both issues:

-      return {
-        id: data.id,
-        summary: `New SMS received from ${data.raw_digits} to ${data.number.digits}`,
-        ts: data.created_at,
-      };
+      return {
+        id: data.id,
+        summary: `New SMS from ${data.raw_digits}` +
+          (data.number?.digits ? ` to ${data.number.digits}` : ""),
+        ts: Date.parse(data.created_at),
+      };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
generateMeta(data) {
return {
id: data.id,
summary: `New SMS received from ${data.raw_digits} to ${data.number.digits}`,
ts: data.created_at,
};
},
generateMeta(data) {
return {
id: data.id,
summary: `New SMS from ${data.raw_digits}` +
(data.number?.digits ? ` to ${data.number.digits}` : ""),
ts: Date.parse(data.created_at),
};
},
🤖 Prompt for AI Agents
In components/aircall/sources/new-sms/new-sms.mjs around lines 19 to 25, the
generateMeta function assumes data.number is always an object and
data.created_at is already a timestamp, which can cause runtime errors and
incorrect timestamp handling. Update the code to safely access
data.number.digits only if data.number is not null, and convert data.created_at
from an ISO string to milliseconds since epoch before assigning it to ts. This
will prevent crashes and ensure the timestamp is in the expected format.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe CodeRabbit's questioning here is correct - ts should be in milliseconds , please double check if the API returns created_at in milliseconds, or convert it otherwise

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧩 Analysis chain

@GTFalcao, you're absolutely right to question this. Let me check the Aircall API documentation and examine how other Aircall components handle timestamps.


🏁 Script executed:

#!/bin/bash
# Check other Aircall components to see how they handle timestamps in generateMeta
find components/aircall -name "*.mjs" -type f | xargs grep -l "generateMeta" | head -5

Length of output: 389


🏁 Script executed:

#!/bin/bash
# Look at how other Aircall components handle timestamps
rg "generateMeta" components/aircall/ -A 10 -B 2

Length of output: 7038


🏁 Script executed:

#!/bin/bash
# Search for any references to created_at in Aircall components
rg "created_at" components/aircall/ -A 3 -B 3

Length of output: 1321


🌐 Web query:

Aircall API webhook payload format created_at timestamp format

💡 Result:

In Aircall's API, the created_at timestamp in webhook payloads is formatted as an ISO 8601 string, which includes the date and time in UTC. For example, a created_at value might look like "2020-02-18T20:52:22.000Z". (developer.aircall.io)

This format is consistent across various resources in Aircall's API, such as Users, Teams, Calls, and Numbers. For instance, when creating a new User, the response includes a created_at field with this timestamp format:

{
  "user": {
    "id": 458,
    "direct_link": "https://api.aircall.io/v1/users/458",
    "name": "Jeffrey Curtis",
    "email": "jeffrey.curtis@aircall.io",
    "available": false,
    "availability_status": "available",
    "created_at": "2020-02-18T20:52:22.000Z",
    "time_zone": "Etc/UTC",
    "language": "en-US",
    "numbers": [],
    "wrap_up_time": 0
  }
}

Similarly, when retrieving a Team, the created_at field is also in the ISO 8601 format:

{
  "team": {
    "id": 123,
    "direct_link": "https://api.aircall.io/v1/teams/123",
    "name": "Sales Team",
    "created_at": "2020-02-18T20:52:22.000Z",
    "users": [
      {
        "id": 456,
        "direct_link": "https://api.aircall.io/v1/users/456",
        "name": "John Doe",
        "email": "john.doe@aircall.io",
        "available": true,
        "availability_status": "available",
        "created_at": "2019-12-29T10:03:18.000Z",
        "time_zone": "America/New_York",
        "language": "en-US"
      }
    ]
  }
}

This consistent timestamp format ensures uniformity across Aircall's API responses and webhook payloads.

Citations:


Perfect! I've confirmed that the conversion is absolutely needed. Here's what I found:

From the Aircall API documentation: The created_at field is returned as an ISO 8601 string (e.g., "2020-02-18T20:52:22.000Z"), not milliseconds.

From the existing codebase: I found that other Aircall components have the same issue:

  • new-number-created.mjs has a comment saying "Convert created_at timestamp to a Date object" but doesn't actually convert it
  • new-call-ended.mjs also uses the raw timestamp without conversion
  • Only new-note-added.mjs and new-tag-added.mjs use Date.now() (which is already in milliseconds)

The fix: CodeRabbit's suggestion to use Date.parse(data.created_at) is correct. This will convert the ISO string to milliseconds since epoch, which is what Pipedream expects for proper sorting and deduplication.

You're absolutely right to question this - the conversion is essential for the component to work correctly. The existing components (new-number-created and new-call-ended) likely have the same bug and should be fixed in a follow-up.


✏️ Learnings added
Learnt from: GTFalcao
PR: PipedreamHQ/pipedream#17538
File: components/aircall/sources/new-sms/new-sms.mjs:19-25
Timestamp: 2025-07-09T18:07:12.388Z
Learning: In Aircall API webhook payloads, the `created_at` field is returned as an ISO 8601 string format (e.g., "2020-02-18T20:52:22.000Z"), not as milliseconds since epoch. For Pipedream components, this needs to be converted to milliseconds using `Date.parse()` before assigning to the `ts` field in `generateMeta()`.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


🧠 Learnings used
Learnt from: GTFalcao
PR: PipedreamHQ/pipedream#12697
File: components/salesforce_rest_api/sources/common-webhook-methods.mjs:1-71
Timestamp: 2024-10-08T15:33:38.240Z
Learning: The `common-webhook-methods.mjs` object is designed to be extended, similar to an abstract class, and intentionally does not implement certain methods like `generateWebhookMeta` and `getEventType` to enforce implementation in subclasses.

Learnt from: GTFalcao
PR: PipedreamHQ/pipedream#12697
File: components/salesforce_rest_api/sources/common-webhook-methods.mjs:1-71
Timestamp: 2024-07-24T02:06:47.016Z
Learning: The `common-webhook-methods.mjs` object is designed to be extended, similar to an abstract class, and intentionally does not implement certain methods like `generateWebhookMeta` and `getEventType` to enforce implementation in subclasses.

Learnt from: GTFalcao
PR: PipedreamHQ/pipedream#14265
File: components/the_magic_drip/sources/common.mjs:35-43
Timestamp: 2024-10-10T19:18:27.998Z
Learning: In `components/the_magic_drip/sources/common.mjs`, when processing items in `getAndProcessData`, `savedIds` is intentionally updated with IDs of both emitted and non-emitted items to avoid emitting retroactive events upon first deployment and ensure only new events are emitted as they occur.

Learnt from: GTFalcao
PR: PipedreamHQ/pipedream#15376
File: components/monday/sources/name-updated/name-updated.mjs:6-6
Timestamp: 2025-01-23T03:55:15.166Z
Learning: Source names in Monday.com components don't need to start with "New" if they emit events for updated items (e.g., "Name Updated", "Column Value Updated") rather than new items. This follows the component guidelines exception where the "New" prefix is only required when emits are limited to new items.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @GTFalcao I've already checked this and it is in miliseconds

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Copy link
Collaborator

@GTFalcao GTFalcao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's one possible issue that CodeRabbit flagged, please check it out - other than that looks good to go.

Comment on lines +19 to +25
generateMeta(data) {
return {
id: data.id,
summary: `New SMS received from ${data.raw_digits} to ${data.number.digits}`,
ts: data.created_at,
};
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe CodeRabbit's questioning here is correct - ts should be in milliseconds , please double check if the API returns created_at in milliseconds, or convert it otherwise

@jcortes jcortes force-pushed the aircall-new-source-component branch 2 times, most recently from 6088a93 to 72fa924 Compare July 10, 2025 14:46
@jcortes jcortes force-pushed the aircall-new-source-component branch from 72fa924 to 9d6b420 Compare July 10, 2025 15:19
@jcortes
Copy link
Collaborator Author

jcortes commented Jul 10, 2025

/approve

@jcortes jcortes merged commit d359048 into master Jul 10, 2025
11 checks passed
@jcortes jcortes deleted the aircall-new-source-component branch July 10, 2025 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

[TRIGGER] New SMS in Aircall
2 participants