STRATCONN-6815 - [Twilio Messaging] - String if non string payload values#3794
Open
joe-ayoub-segment wants to merge 2 commits into
Open
STRATCONN-6815 - [Twilio Messaging] - String if non string payload values#3794joe-ayoub-segment wants to merge 2 commits into
joe-ayoub-segment wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Ensures Twilio Messaging “ContentVariables” values are sent as strings by coercing non-string values prior to JSON encoding, and adds a regression test to verify the new behavior for numeric/boolean inputs.
Changes:
- Stringifies
contentVariablesvalues before settingContentVariablesin the Twilio payload. - Adds a unit test asserting the outbound encoded request body contains stringified
ContentVariables.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
packages/destination-actions/src/destinations/twilio-messaging/sendMessage/utils.ts |
Coerces contentVariables values to strings before JSON encoding into ContentVariables. |
packages/destination-actions/src/destinations/twilio-messaging/sendMessage/__tests__/index.test.ts |
Adds a test validating non-string contentVariables (numbers/booleans) are stringified in the request body. |
Comment on lines
+98
to
+102
| if (Object.keys(contentVariables ?? {}).length > 0) { | ||
| contentTemplate.ContentVariables = JSON.stringify(contentVariables) | ||
| const stringified = Object.fromEntries( | ||
| Object.entries(contentVariables ?? {}).map(([k, v]) => [k, String(v)]) | ||
| ) | ||
| contentTemplate.ContentVariables = JSON.stringify(stringified) |
Comment on lines
+232
to
+235
| const expectedBody = 'To=%2B1234567890&MessagingServiceSid=MG1234567890abcdef1234567890abcdef&ContentSid=HX1234567890abcdef1234567890abcdef&ContentVariables=%7B%22amount_to_finance%22%3A%2212899%22%2C%22cash_price%22%3A%2212500%22%2C%22monthly_payment%22%3A%22285.28%22%2C%22term%22%3A%2260%22%2C%22is_approved%22%3A%22true%22%2C%22vehicle%22%3A%22500+Mhev%22%7D' | ||
|
|
||
| nock('https://api.twilio.com') | ||
| .post(`/2010-04-01/Accounts/${defaultSettings.accountSID}/Messages.json`, expectedBody) |
sayan-das-in
approved these changes
May 15, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Testing
Tested locally - but sent to production twilio - which sent an SMS with the correct values.
See video for full test walkthrough. https://drive.google.com/file/d/1ULAU6TMb3yZUltXSUwy5y6yAUIwkjw7Z/view?usp=sharing
Security Review
Please ensure sensitive data is properly protected in your integration.
type: 'password'New Destination Checklist
verioning-info.tsfile. example