Hello,
I am trying to build flow in Studio which will:
- receive SMS, parse message body, use parsed number as parameter for my http request (client's PABX is sending to my Twilio number sms with info about non answered call like 'You have unanswered call from 227636555 at 14:45')
- i want to get 227636555 from text messages and use it as one of parameters of my http request (in studio project below for test reason i just try to send back sms with number as message body)

When i am using my function_1 defined as
exports.handler = function(context, event, callback) {
let regexp = /[1-9]{9}/;
var str = event.Body;
var matches_array = str.match(regexp);
var numer = matches_array[0];
// callback(null, {"numer": numer});
var client = context.getTwilioClient();
client.messages.create({
to: event.From,
from: event.To,
body: numer
}, function(err, res) {
callback(null,twiml);
})
};
and connected directly to Twilio number it is working just FINE and i am receiving SMS from Twilio with just number as body.
When i am using my function_1 defined as
exports.handler = function(context, event, callback) {
let regexp = /[1-9]{9}/;
var str = event.Body;
var matches_array = str.match(regexp);
var numer = matches_array[0];
callback(null, {"numer": numer});
};
testing it with browser and Twilio function link (https://ultra-xxx.twil.io/numer?Body=You%20have%20unanswered%20call%20from%20227636555%20at%2014:45'
i receive proper info like {"numer":"227636555
"}.
When using it in flow it produces error - which i can recreate when i will change .twil.io/numer?Body=You%20h to
.twil.io/numer?body=You%20h
"widgets": {
"send_message_1": {},
"function_1": {
"status_code": 500,
"content_type": "application/json",
"parsed": {
"message": "Cannot read property 'match' of undefined",
"name": "TypeError",
"stack": "TypeError: Cannot read property 'match' of undefined\n at Object.exports.handler (/var/task/handlers/ZFf75157b5c8bf2e3fb63edec4132b4f3e.js:8:26)\n at Object.exports.handler (/var/task/node_modules/enigma-lambda/index.js:268:10)\n at exports.handler (/var/task/enigma.js:17:9)"
},
"body": "{\"message\":\"Cannot read property 'match' of undefined\",\"name\":\"TypeError\",\"stack\":\"TypeError: Cannot read property 'match' of undefined\\n at Object.exports.handler (/var/task/handlers/ZFf75157b5c8bf2e3fb63edec4132b4f3e.js:8:26)\\n at Object.exports.handler (/var/task/node_modules/enigma-lambda/index.js:268:10)\\n at exports.handler (/var/task/enigma.js:17:9)\"}"
}
Do you have any suggestion what i am doing wrong and how to set up my function to return value also in Twilio Studio?
regards
Tomek