-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Survey Monkey - Expanding Actions #21641
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
ashwins01
merged 13 commits into
PipedreamHQ:master
from
RoboSourceTeam:claude/rk-7347-implementation
Aug 28, 2026
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
829238c
New Components - survey_monkey (send-side collector, message, recipie…
caleblehman-robosource 1be218b
survey_monkey: add send-side app methods and bump dependent component…
caleblehman-robosource 3918762
survey_monkey: fix recipient parsing edge cases and documentation acc…
caleblehman-robosource ba8694a
survey_monkey: address CodeRabbit review on #21641
caleblehman-robosource ab37f90
survey_monkey: keep recipient details out of parse error messages
caleblehman-robosource 157869b
survey_monkey: tighten object-array validation
caleblehman-robosource 4d1668e
Merge branch 'master' into claude/rk-7347-implementation
caleblehman-robosource 17a44bc
Merge branch 'master' into claude/rk-7347-implementation
caleblehman-robosource a25f96d
Merge branch 'master' into claude/rk-7347-implementation
caleblehman-robosource ecf4fa9
Merge branch 'master' into claude/rk-7347-implementation
caleblehman-robosource c8c1721
survey_monkey: address CodeRabbit review round 3 on #21641
caleblehman-robosource b37f801
Merge branch 'master' into claude/rk-7347-implementation
caleblehman-robosource 53dbebc
survey_monkey: make message IDs free-text, add List Invite Messages
caleblehman-robosource File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
98 changes: 98 additions & 0 deletions
98
components/survey_monkey/actions/add-message-recipients/add-message-recipients.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| import { ConfigurationError } from "@pipedream/platform"; | ||
| import surveyMonkey from "../../survey_monkey.app.mjs"; | ||
| import base from "../common/base-survey.mjs"; | ||
| import { parseObjectArray } from "../../common/utils.mjs"; | ||
|
|
||
| export default { | ||
| ...base, | ||
| key: "survey_monkey-add-message-recipients", | ||
| name: "Add Message Recipients", | ||
| description: "Add recipients to an invite message, from new contacts, existing contact IDs, contact lists, or any combination. Uses the bulk endpoint, so nothing is re-added: a recipient already on the message or collector comes back under `existing`, while `duplicate` reports addresses repeated within this one request. [See the documentation](https://api.surveymonkey.com/v3/docs?javascript#api-endpoints-post-collectors-collector_id-messages-message_id-recipients-bulk)", | ||
| version: "0.0.1", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: false, | ||
| }, | ||
| type: "action", | ||
| props: { | ||
| ...base.props, | ||
| collectorId: { | ||
| propDefinition: [ | ||
| surveyMonkey, | ||
| "collectorId", | ||
| (c) => ({ | ||
| surveyId: c.survey, | ||
| }), | ||
| ], | ||
| }, | ||
| messageId: { | ||
| propDefinition: [ | ||
| surveyMonkey, | ||
| "messageId", | ||
| ], | ||
| description: "The ID of the invite message to add recipients to. Run **List Invite Messages** to find valid message IDs, or use the `id` returned by **Create Invite Message**.", | ||
| }, | ||
| contacts: { | ||
| type: "string[]", | ||
| label: "Contacts", | ||
| description: "New contacts to add, each a JSON object. Email is required for email collectors and phone number for SMS collectors. **Example:** `{\"email\": \"jane@example.com\", \"first_name\": \"Jane\", \"last_name\": \"Doe\"}` or `{\"phone_number\": \"+1 202 555 0156\"}`. Careful with `custom_fields`: if any one contact supplies them, SurveyMonkey clears the existing custom fields of every other contact in the same call that does not.", | ||
| optional: true, | ||
| }, | ||
| contactIds: { | ||
| type: "string[]", | ||
| label: "Contact IDs", | ||
| description: "IDs of existing SurveyMonkey contacts to add as recipients, e.g. `[\"123456\"]`. Contacts live in your SurveyMonkey address book rather than in this action — find their IDs at `GET /v3/contacts`, which returns an `id` per contact, or in the `succeeded[].id` values a previous run of this action returned.", | ||
| optional: true, | ||
| }, | ||
| contactListIds: { | ||
| type: "string[]", | ||
| label: "Contact List IDs", | ||
| description: "IDs of existing contact lists whose contacts should be added as recipients, e.g. `[\"123456\"]`. Contact lists are managed in SurveyMonkey rather than here — find their IDs at `GET /v3/contact_lists`, or in the list's URL in the SurveyMonkey UI.", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const { | ||
| contactIds, contactListIds, | ||
| } = this; | ||
| const contacts = parseObjectArray(this.contacts, "Contacts"); | ||
|
|
||
| if (!contacts?.length && !contactIds?.length && !contactListIds?.length) { | ||
| throw new ConfigurationError("Set at least one of **Contacts**, **Contact IDs**, or **Contact List IDs**."); | ||
| } | ||
|
|
||
| const response = await this.surveyMonkey.addMessageRecipients({ | ||
| $, | ||
| collectorId: this.collectorId, | ||
| messageId: this.messageId, | ||
| data: { | ||
| contacts, | ||
| contact_ids: contactIds, | ||
| contact_list_ids: contactListIds, | ||
| }, | ||
| }); | ||
|
|
||
| // The endpoint answers 200 even when every recipient was rejected, sorting | ||
| // them into per-reason buckets, so the counts are the only signal that a | ||
| // send will actually reach anyone. | ||
| const skipped = [ | ||
| "invalids", | ||
| "existing", | ||
| "bounced", | ||
| "opted_out", | ||
| "duplicate", | ||
| ] | ||
| .map((bucket) => response?.[bucket]?.length | ||
| ? `${response[bucket].length} ${bucket.replace("_", " ")}` | ||
| : null) | ||
| .filter(Boolean) | ||
| .join(", "); | ||
|
|
||
| $.export("$summary", `Successfully added ${response?.succeeded?.length ?? 0} recipient(s)${skipped | ||
| ? `; skipped ${skipped}` | ||
| : ""}`); | ||
|
|
||
| return response; | ||
| }, | ||
| }; | ||
126 changes: 126 additions & 0 deletions
126
components/survey_monkey/actions/create-collector/create-collector.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| import base from "../common/base-survey.mjs"; | ||
| import constants from "../../common/constants.mjs"; | ||
|
|
||
| export default { | ||
| ...base, | ||
| key: "survey_monkey-create-collector", | ||
| name: "Create Collector", | ||
| description: "Create a collector for a survey. A collector is the channel responses come in through — an SMS or email invitation, a web link, or a popup. [See the documentation](https://api.surveymonkey.com/v3/docs?javascript#api-endpoints-post-surveys-survey_id-collectors)", | ||
| version: "0.0.1", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: false, | ||
| }, | ||
| type: "action", | ||
| props: { | ||
| ...base.props, | ||
| type: { | ||
| type: "string", | ||
| label: "Type", | ||
| description: "The kind of collector to create. Every type except **Web link** requires a paid SurveyMonkey plan.", | ||
| options: constants.COLLECTOR_TYPES, | ||
| }, | ||
| name: { | ||
| type: "string", | ||
| label: "Name", | ||
| description: "A nickname for the collector.", | ||
| }, | ||
| senderEmail: { | ||
| type: "string", | ||
| label: "Sender Email", | ||
| description: "Sender email for email collectors. The address must be verified in your SurveyMonkey account before invitations will send.", | ||
| optional: true, | ||
| }, | ||
| thankYouMessage: { | ||
| type: "string", | ||
| label: "Thank You Message", | ||
| description: "Message shown on the thank you page once a respondent completes the survey. SurveyMonkey treats this as the older form of `thank_you_page` and recommends that object instead — pass it through **Additional Options** to use it.", | ||
| optional: true, | ||
| }, | ||
| closedPageMessage: { | ||
| type: "string", | ||
| label: "Closed Page Message", | ||
| description: "Message shown once the survey is closed.", | ||
| optional: true, | ||
| }, | ||
| redirectUrl: { | ||
| type: "string", | ||
| label: "Redirect URL", | ||
| description: "Redirect respondents to this URL on survey completion.", | ||
| optional: true, | ||
| }, | ||
| closeDate: { | ||
| type: "string", | ||
| label: "Close Date", | ||
| description: "When the collector should close, e.g. `2026-12-03T10:15:30+00:00`.", | ||
| optional: true, | ||
| }, | ||
| responseLimit: { | ||
| type: "integer", | ||
| label: "Response Limit", | ||
| description: "Close the collector after this many responses.", | ||
| optional: true, | ||
| }, | ||
| anonymousType: { | ||
| type: "string", | ||
| label: "Anonymous Type", | ||
| description: "Turns off IP tracking. For email collectors it also removes the respondent's email address and name from the response.", | ||
| options: constants.ANONYMOUS_TYPES, | ||
| optional: true, | ||
| }, | ||
| editResponseType: { | ||
| type: "string", | ||
| label: "Edit Response Type", | ||
| description: "When respondents can edit their response.", | ||
| options: constants.EDIT_RESPONSE_TYPES, | ||
| optional: true, | ||
| }, | ||
| isBrandingEnabled: { | ||
| type: "boolean", | ||
| label: "Is Branding Enabled", | ||
| description: "Whether the popup has SurveyMonkey branding. Only applies to popup collectors.", | ||
| optional: true, | ||
| }, | ||
| additionalOptions: { | ||
| type: "object", | ||
| label: "Additional Options", | ||
| description: "Any other collector option to send in the request body, e.g. `{\"thank_you_page\": {\"is_enabled\": true, \"message\": \"Thanks!\"}}` or the popup-only `width`/`height`/`sample_rate` settings. See the documentation for the full list. Note that values typed directly into this field arrive as strings, so pass booleans and numbers from a previous step or an expression when the API expects those types.", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const declared = { | ||
| type: this.type, | ||
| name: this.name, | ||
| sender_email: this.senderEmail, | ||
| thank_you_message: this.thankYouMessage, | ||
| closed_page_message: this.closedPageMessage, | ||
| redirect_url: this.redirectUrl, | ||
| close_date: this.closeDate, | ||
| response_limit: this.responseLimit, | ||
| anonymous_type: this.anonymousType, | ||
| edit_response_type: this.editResponseType, | ||
| is_branding_enabled: this.isBrandingEnabled, | ||
| }; | ||
|
|
||
| const response = await this.surveyMonkey.createCollector({ | ||
| $, | ||
| surveyId: this.survey, | ||
| data: { | ||
| ...this.additionalOptions, | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| // Declared props take precedence over Additional Options, but only | ||
| // where one was actually set: an unset optional prop is `undefined`, | ||
| // and letting that through would drop the matching Additional Options | ||
| // key from the serialized body instead of leaving it alone. | ||
| ...Object.fromEntries(Object.entries(declared).filter(([ | ||
| , | ||
| value, | ||
| ]) => value !== undefined)), | ||
| }, | ||
| }); | ||
|
|
||
| $.export("$summary", `Successfully created ${this.type} collector "${this.name}"`); | ||
| return response; | ||
| }, | ||
| }; | ||
139 changes: 139 additions & 0 deletions
139
components/survey_monkey/actions/create-invite-message/create-invite-message.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,139 @@ | ||
| import { ConfigurationError } from "@pipedream/platform"; | ||
| import surveyMonkey from "../../survey_monkey.app.mjs"; | ||
| import base from "../common/base-survey.mjs"; | ||
| import constants from "../../common/constants.mjs"; | ||
|
|
||
| export default { | ||
| ...base, | ||
| key: "survey_monkey-create-invite-message", | ||
| name: "Create Invite Message", | ||
| description: "Create an invite message on an email or SMS collector. Add recipients with **Add Message Recipients**, then deliver it with **Send Invite Message**. [See the documentation](https://api.surveymonkey.com/v3/docs?javascript#api-endpoints-post-collectors-collector_id-messages)", | ||
| version: "0.0.1", | ||
| annotations: { | ||
| destructiveHint: false, | ||
| openWorldHint: true, | ||
| readOnlyHint: false, | ||
| }, | ||
| type: "action", | ||
| props: { | ||
| ...base.props, | ||
| collectorId: { | ||
| propDefinition: [ | ||
| surveyMonkey, | ||
| "collectorId", | ||
| (c) => ({ | ||
| surveyId: c.survey, | ||
| }), | ||
| ], | ||
| }, | ||
| type: { | ||
| type: "string", | ||
| label: "Type", | ||
| description: "The type of message to create. Use `sms` for SMS collectors and `invite` for email collectors.", | ||
| options: constants.MESSAGE_TYPES, | ||
| default: "invite", | ||
| optional: true, | ||
| }, | ||
| subject: { | ||
| type: "string", | ||
| label: "Subject", | ||
| description: "Subject line of the email message. Not used for SMS messages.", | ||
| optional: true, | ||
| }, | ||
| bodyText: { | ||
| type: "string", | ||
| label: "Body Text", | ||
| description: "The plain text body of the message, and the only body an SMS message can use. SurveyMonkey advises keeping an SMS body to 30 characters or fewer, including spaces, so the invitation stays a single text. Include the `[SurveyLink]` placeholder, or recipients get an invitation with no way to reach the survey. Per SurveyMonkey's Anti-Spam Policy the `[OptOutLink]` must stay visible and its purpose clearly explained.", | ||
| optional: true, | ||
| }, | ||
| bodyHtml: { | ||
| type: "string", | ||
| label: "Body HTML", | ||
| description: "The HTML body of an email message, and email-only — it does not apply to `sms` messages, and it overrides **Body Text** when both are set. The same placeholders apply as for **Body Text** — `[SurveyLink]`, `[OptOutLink]`, `[PrivacyLink]` and `[FooterLink]` — and the Anti-Spam Policy requires that the opt-out link stay visible rather than being hidden in the markup.", | ||
| optional: true, | ||
| }, | ||
| fromMessageId: { | ||
| propDefinition: [ | ||
| surveyMonkey, | ||
| "messageId", | ||
| ], | ||
| label: "Copy From Message", | ||
| description: "The ID of an existing message on this collector to copy the new message from, e.g. to reuse a template. Run **List Invite Messages** to find valid message IDs.", | ||
| optional: true, | ||
| }, | ||
| fromCollectorId: { | ||
| type: "string", | ||
| label: "Copy From Collector ID", | ||
| description: "Copy the message from the most recent message on another collector.", | ||
| optional: true, | ||
| }, | ||
| includeRecipients: { | ||
| type: "boolean", | ||
| label: "Include Recipients", | ||
| description: "Whether to copy the recipients of the message being copied from.", | ||
| optional: true, | ||
| }, | ||
| recipientStatus: { | ||
| type: "string", | ||
| label: "Recipient Status", | ||
| description: "The set of recipients to send to.", | ||
| options: [ | ||
| "reminder", | ||
| "thank_you", | ||
| ], | ||
| optional: true, | ||
| }, | ||
| embedFirstQuestion: { | ||
| type: "boolean", | ||
| label: "Embed First Question", | ||
| description: "Whether to embed the survey's first question in an email invitation.", | ||
| optional: true, | ||
| }, | ||
| isBrandingEnabled: { | ||
| type: "boolean", | ||
| label: "Is Branding Enabled", | ||
| description: "Whether SurveyMonkey branding is shown in the message.", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const { | ||
| type, subject, bodyText, bodyHtml, fromMessageId, fromCollectorId, | ||
| } = this; | ||
|
|
||
| const isCopy = !!(fromMessageId || fromCollectorId); | ||
|
|
||
| // `body_html` is documented as the HTML body of the *email* message, so it | ||
| // cannot carry an SMS's content — accepting it alone for `sms` would send a | ||
| // message with nothing in it. | ||
| if (!isCopy && type === "sms" && !bodyText) { | ||
| throw new ConfigurationError("An SMS message needs **Body Text** — **Body HTML** applies to email messages only. Alternatively, copy an existing message with **Copy From Message** or **Copy From Collector ID**."); | ||
| } | ||
|
|
||
| if (!isCopy && type !== "sms" && !bodyText && !bodyHtml) { | ||
| throw new ConfigurationError("Set **Body Text** or **Body HTML**, or copy an existing message with **Copy From Message** or **Copy From Collector ID**."); | ||
| } | ||
|
|
||
| const response = await this.surveyMonkey.createMessage({ | ||
| $, | ||
| collectorId: this.collectorId, | ||
| data: { | ||
| type, | ||
| subject, | ||
| body_text: bodyText, | ||
| body_html: bodyHtml, | ||
| from_message_id: fromMessageId, | ||
| from_collector_id: fromCollectorId, | ||
| include_recipients: this.includeRecipients, | ||
| recipient_status: this.recipientStatus, | ||
| embed_first_question: this.embedFirstQuestion, | ||
| is_branding_enabled: this.isBrandingEnabled, | ||
| }, | ||
| }); | ||
|
|
||
| $.export("$summary", `Successfully created ${type} message${response.subject | ||
| ? ` "${response.subject}"` | ||
| : ` #${response.id}`}`); | ||
| return response; | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.