Search code examples
node.jstwiliotwilio-apitwilio-programmable-chat

Can I receive message in both Messaging service and Function? I don't receive the message in Twilio function


Currently, I have the following setup in Twilio. I send a message to my Twilio number, and it is being processed in Messaging service but the function doesn't run. Or receive any triggers or request.

Wondering if it the message can be sent to both or not?

enter image description here

When I tested the function alone it was being invoked and working as expected.


Solution

  • You can only react once per incoming message, so either a Studio flow, Function, TwiML or similar. When using a Messaging Service, you can define this callback in the service itself. Or, you can select the "Defer to sender's webhook" configuration in the Messaging Service, meaning inbound messages will hit whatever inbound message handler is configured on your individual phone numbers.

    A workaround to trigger two Functions, or a Studio flow and a Function, would be invoking the second callback programmatically from a Function.