Twillio SMS support in The Netherlands - azure

I want to test an Azure Logic app that uses a service like Twillio to send SMS messages. Unfortunately Twillio doesn't offer SMS support in The Netherlands. What alternatives could we choose to solve this?

I used messagebird.com for this and build their API into a custom API App that I embedded in a Logic App flow:
Client client = Client.CreateDefault("[API KEY]" , null);
Message messageResponse = client.SendMessage(message.Sender,
message.MessageText, new[] { long.Parse(message.Number) });
This could also be implemented in an Azure Function to simplify deployment.

Related

Register device on Azure notifications hub

I'm developing an application using Ionic & capacitor. My backend is Azure functions (nodejs) javascript, i'm able to get the device token using the below code:
PushNotifications.addListener(
'registration',
(token: PushNotificationToken) => {
alert('Push registration success, token: ' + token.value);
},
);
This token I send to my backend, but i don't know how to save it in Azure Notifications Hub?
Typically this is stored on your app backend. Please see this document for more information.
Let me know if there are further questions on this matter.
Was able to use azure-sb to successfully register the device and send notifications, sample code here: https://github.com/mpodwysocki/azure-notificationhubs-node-sample/blob/main/src/index.ts

Send email from Azure app service with sender as my domain email

Here is what I want to achieve: I want to send email to clients from a .NET core based web-api hosted on Azure. And I want the email's sender address to be "info#mydomain.com".. which "mydomain.com" is the domain I own from GoDaddy.
I have done some search but surprisingly haven't found any easy to follow tutorials.
It's really simple to use SendGrid, especially with for instance the Azure Functions SendGrid bindings.
For an approach where you use the SendGrid NuGet package, see How to Send Email Using SendGrid with Azure.
This guide demonstrates how to perform common programming tasks with the SendGrid email service on Azure. The samples are written in C# and supports .NET Standard 1.3. The scenarios covered include constructing email, sending email, adding attachments, and enabling various mail and tracking settings.
I end up using MailKit.
public void SendMessage(MimeMessage message)
{
using (var client = new SmtpClient())
{
client.ServerCertificateValidationCallback = (s, c, h, e) => true;
client.Connect("smtp_host", 465, SecureSocketOptions.SslOnConnect);
client.Authenticate("admin#mysite", "smtp_password");
client.Send(message);
client.Disconnect(true);
}
}

How often should I get a new service sid of twillio?

When using twillio, how often should the service sid be created and create a new services? I see 3 options. There might be more options thought.
Get the service sid/create a new service and store it in the db, then never get a new one.
Get the service sid/create a new service every time the backend server starts/runs (I'm using node/express)
Get the service sid/create a new service whenever using the twillio client is used
Here's the code:
let serviceSid = '';
async function init() {
const service = await client.verify.services.create({
friendlyName: 'someName'
});
serviceSid = service.sid;
}
Also, what's the purpose of it, if you already have an account sid?
Your Twilio ACCOUNT SID together width AUTH TOKEN has to do with your overall Twilio account. It gives you access to the entire Twilio API (Verify is just a part of it).
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);
To use the Twilio Verify product (or service if you wish) you will need to create at least one "verification service". You can do it in the Twilio console or by making API requests.
When you create a verification service you get that SID which starts with "VA" and it will be used in a verification code for example.
client.verify.services('VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
.verifications
.create({to: '+15017122661', channel: 'sms'})
.then(verification => console.log(verification.sid));
If let's say you have more than one application using Verify you'll want to create a verification service for each application.
Also, maybe the verification message template is different or maybe you expect different lengths for the verification code, etc. then you need separate verification services hence different VA SIDs.
So from your options in your question I would go with number 1 per distinct application. If you only have one app then I would get one verification service per environment (one for dev, one for QA, one for production, etc.).
Also, I would create Twilio sub-accounts for each app + environment and use them instead of the Twilio master account.

How to invoke azure easy API using angularjs in VS2013 Cordova Application?

I have created azure Easy API on azure App services.How To get the API values from Easy API using angular Js.But now I am struggling To call API.For App services there is no app key i Don't know how to Call API.
Before i have Used Azure mobile services so i can Invoke API easily by following lines.it was easy for me.
var client = new WindowsAzure.MobileServiceClient(
"https://yourservice.azure-mobile.net/",
"API KEY");
client.invokeApi('commentsapi', {
method: 'GET'
}).done(function (response) {
success(JSON.parse(response));
});
Use the v2.0.0-beta release of azure-mobile-apps-client (available via npm) - copy the MobileServiceClient.min.js to your web area and include it - if you are building the app with webpack or browserify, you can just "require('azure-mobile-apps-client')".
You don't need an API key any more. Otherwise, your client looks good.

Requesting a New Registration Id and Creating a Tag for the Azure Notification Hub with NodeJs

How to get a new registration Id for the Azure Notification Hub with JavaScript (NodeJS) and how to create the tag afterwards? The tutorial provided by the Azure documentation misses this part - it sends to all devices (null).
https://azure.microsoft.com/en-us/documentation/articles/notification-hubs-nodejs-how-to-use-notification-hubs/
var payload={
alert: 'Hello!'
};
notificationHubService.apns.send(null, payload, function(error){
if(!error){
// notification sent
}
});
Thanks!
The Notification Hub apns object also has a createNativeRegistration(token, tags, options, callback) function.
var token='abcd1234......'; // token from iOS device
var tags = ['mynewtag', 'myoldtag'];
notificationHubService.apns.createNativeRegistration(token, tags, {success:newRegistrationCompleteCallback, error:newRegistrationErrorCallback});
If you are using the npm you can read the source for it since the documentation is pretty incomplete.
If you are using Mobile Services' Node.js backend, see also the documentation for the built-in push apns object, which seems to be using the same library.

Resources