@wavemaster As discussed in our offline session we can follow the official document functions-bindings-twilio In this document we have a queue trigger example. As per requirement I have tried with a timer trigger and this works fine.
Code :
#r "Newtonsoft.Json"
#r "Twilio"
#r "Microsoft.Azure.WebJobs.Extensions.Twilio"
using System;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Microsoft.Azure.WebJobs.Extensions.Twilio;
using Twilio.Rest.Api.V2010.Account;
using Twilio.Types;
public static void Run(TimerInfo myTimer,out CreateMessageOptions message, ILogger log)
{
log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
string msg = "Hello there! This is a test message";
// You must initialize the CreateMessageOptions variable with the "To" phone number.
message = new CreateMessageOptions(new PhoneNumber("+9xxxxxxxxxx"));
// A dynamic message can be set instead of the body in the output binding. In this example, we use
// the order information to personalize a text message.
message.Body = msg;
}
functions.json:
{
"bindings": [
{
"name": "myTimer",
"type": "timerTrigger",
"direction": "in",
"schedule": "0 */5 * * * *"
},
{
"type": "twilioSms",
"name": "message",
"accountSidSetting": "accountSidSetting",
"authTokenSetting": "authToken",
"from": "+1xxxxxxxxx",
"direction": "out",
"body": "Azure Functions Testing"
}
]
}
Note : In this case I am sending a message from Twillio to my number, so I have tested with From - "Twillio number" and To- "My number".
Also, these settings values should be saved in app settings and use the name of the app settings in the functions.json :
If this helped , please "accept the answer" and "up-vote " , so that it helps others in the community.