Skip to content
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

Allow creation of MessagingResponse from Twiml string #956

Open
amcurative opened this issue Sep 8, 2023 · 0 comments
Open

Allow creation of MessagingResponse from Twiml string #956

amcurative opened this issue Sep 8, 2023 · 0 comments

Comments

@amcurative
Copy link

amcurative commented Sep 8, 2023

Issue Summary

It seem silly but there is constructors and functions to generate Twiml but no way to create these objects from a given TwiMl string. The use case is using a Twilio function to call multiple webhooks (since UI only allows to call one webhook) but webhook responds with a Twiml string as Twilio expects but the function must call the Twilio context function with a twiml.MessagingResponse object and there seems to be no easy way to go from a Twiml string to a MessagingResponse object short of parsing the text out of the TwiML and recreating the message from plain text.

Either the Twilio function context should allow for a Twiml string and not only specifically expect MessagingResponse object or MessagingResponse should be easily created from a Twiml string.

I don't want to modify my webhook to return differently because the same webhook is being used by another number which only needs to call just this webhook so no need for a function and when Twilio calls the webhook, it expects Twiml

My workaround for now is to use regex to strip out the xml tags and recreate the message using the constructors with the plain string but seems crappy

Steps to Reproduce

  1. Go to a phone number settings
  2. Setup to call multiple webhooks, you can't. So have to use a function.
  3. In function definition, you call all webhooks and call the context function with one of the responses, coming as Twiml string.
  4. Doesn't work. It expects MessagingResponse. No easy way to create that for a given Twiml either.

Code Snippet

# paste code here

Exception/Log

# paste exception/log here

Technical details:

  • twilio-node version:
  • node version:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant