I am developing an integration from SharePoint to yammer enterprise.
The integration will be two images, the envelope and the bell icon from yammer.
Along those should the the correct numbers. Through all the API's given at
https://developer.yammer.com/docs/ I have only managed to find the amount of notifications at the networks/current.json.
Under many different api's are numbers with names such as unseen messages, but they do not referer to this specific number. It should be easy to find and I am sure that somebody out there is smart enough to know this.
If Anybody knows which api I should call, then I it would be much appreciated if they share it =)
you can check the following code and you will get unseen notification and unseen message count.
yam.platform.request({
url: "networks/current.json",
method: "GET",
data: {},
success: function (networks) {
for (var i = 0; i < networks.length; i++) {
if (networks[i].permalink === "permalink_name") {
var msgCount = networks[i].unseen_message_count;
var notificationCount = networks[i].unseen_notification_count;
}
}
},
error: function () {
console.log("There was an error with the request.");
}
});
Related
I am having some problems, I want to change the name of the sender. I mean, it is possible to assign an Alphanumeric Sender ID, I reviewed the documentation and followed the guidelines, in the response of the twilio api the name goes but when in the messages I receive it sends them to the same number. I know that it is not something due to the regulations of the country because according to the twilio documentation, it is possible. (https://support.twilio.com/hc/en-us/articles/223133767-International-support-for-Alphanumeric-Sender-ID) What is happening? How can I fix? Do I have to do any configuration?
How I want the sender ID to be seen
As I receive the sender ID
UPDATING QUESTION
Ok, the way I have structured the code is as follows:
I am working on a nodejs project, I need to send a message to multiple phone numbers so in order to do it I used the SMS notification service offered by Twilio, this is the method that was created:
async sendSMSAsNotify(req: Request, res: Response) {
try {
console.log("req.body:", req.body);
let messageBody = req.body.body;
console.log(messageBody);
let numberList = req.body.toBinding;
let extractBody = messageBody.replace(/<[^>]+>/g, '');
console.log(extractBody);
var decodedStripedHtml = he.decode(extractBody);
//console.log(decodedStripedHtml);
//console.log(`Body: ${messageBody}`);
var numbers = [];
for (let i = 0; i < numberList.length; i++) {
numbers.push(
JSON.stringify({
binding_type: "sms",
address: numberList[i],
})
);
}
const notificationOpts = {
toBinding: numbers,
body: decodedStripedHtml,
title: 'MyCompany'
};
// console.log("numbers:", notificationOpts.toBinding);
// console.log("body", notificationOpts.body);
const response = await this.client.notify
.services(process.env.SERVICE_SID_NTF)
.notifications.create(notificationOpts);
console.log('response', response);
res.json({
msg: `Message sent successfully! ${response}`,
});
} catch (e) {
throw new HttpException(HttpErrors.NOT_FOUND_ERROR, HttpStatus.NOT_FOUND);
}
}
The sendSMSAsNotify() method works great, I can send the same SMS to multiple numbers. But now what I want to achieve is that every message I send shows the sender id. I didn't find how to do it in the documentation of the SMS notification service, so I tried to change it and use a very simple method to send SMS via twilio to a single number just for testing.
async sendSMS(sms: SMSDto) {
try {
return await this.client.messages.create({
body: sms.message,
from: 'MyCompany',
to: sms.number,
});
} catch (e) {
return e
}
}
But in neither of the two methods in which I tried to change the sender identification it did not allow me and that is what brings me here, I really need help, it is a requirement that I need to fulfill and I cannot find a way to help me.
First up, while the list of countries that support alphanumeric sender IDs does contain Honduras there are further guidelines for SMS in Honduras that say:
Dynamic Alphanumeric Sender IDs are not fully supported for Honduras mobile operators. Sender IDs may be overwritten with a local long code or short code outside the Twilio platform.
So, even if you set everything up as I am about to explain, it is still possible that your sender ID may be overwritten with a local long code or short code and that Twilio is unable to do anything about that.
That being said, here's how to set up for alphanumeric sender IDs.
Since you are using Notify to send the messages, you will have set up a Messaging Service to use with Notify.
The Messaging Service controls how the SMS messages are sent out from Notify, from a pool of numbers. That pool can also contain your alphanumeric sender ID
So, to send from an alphanumeric sender ID you need to go to your Sender Pool within your Messaging Service and add an alpha sender.
Once you have the alpha sender set in your Messaging Service's pool, it will be used to send your messages out. You can even remove any long code numbers you have in the pool, if you do not plan to use them, though they are useful to fallback to if you do send to a country that doesn't support alphanumeric sender IDs.
Is it possible that you are in a country that does not support alphanumeric sender IDs and that Twilio falls back on a short code then?
PS: It would be helpful if you could add a code snippet, that shows the code you run, to your question.
Hello I am quite new to Twilio, but I have tried to look up how to answer this question. I would like to use Twilio Functions to solve my problem. I was wondering if it is possible for two people to send SMS messages to each other without revealing either of their numbers.
I was hoping to do this with only one new number per pair.
I imagined it would be through a conditional statement, where person X sends a message to the twilio number and person Y receives it, and vice versa. I assume this cannot be done with the twiML bins because of this conditional statement.
Thanks for your attention.
Twilio developer evangelist here.
You could absolutely do this with Twilio Functions. Here's a simple example of using a number to mask SMS messages between two callers.
class NumberMapping {
constructor() {
this.mapping = {};
}
addMaskedPair(numberA, numberB, twilioNumber) {
if (!this.mapping[twilioNumber]) {
this.mapping[twilioNumber] = {};
}
this.mapping[twilioNumber][numberA] = numberB;
this.mapping[twilioNumber][numberB] = numberA;
}
findNumber(from, to) {
const numberPairs = this.mapping[to];
if (!numberPairs) { return undefined; }
return numberPairs[from];
}
}
const numberMapping = new NumberMapping();
numberMapping.addMaskedPair('+1234567890', '+1098765432', '+1203948576');
exports.handler = function(context, event, callback) {
const to = numberMapping.findNumber(event.From, event.To);
if (typeof to !== 'undefined') {
const response = new Twilio.twiml.MessagingResponse();
response.message({ from: event.To, to: to }, event.Body);
callback(null, response);
} else {
callback(new Error(`Number mapping couldn't be found for sender ${event.From} and Twilio number ${event.To}.`));
}
};
The idea is that you create a NumberMapping object that maps between the two external numbers and your Twilio number. You add your mappings using:
numberMapping.addMaskedPair(firstNumber, secondNumber, twilioNumber);
and then when you need to retrieve the other number in a pair you can call
numberMapping.findNumber(number, twilioNumber);
The rest is just the function to return TwiML.
Note, you will only need as many Twilio numbers as there are relationships of the number that has the maximum set of relationships.
Let me know if that helps at all.
You need to purchase a number from twilio, then use node JS code to send and receive sms with it. You can also send voice messages too. The thing with twilio is that when you receive messages, twilio saves it to its website so you have to go to website and check it explicitly with your account.
You can create account and receive messages with this link
Here is some tutorial on how to send messages, you have to choose node.JS option.
I am using Amazon SNS Mobile Push Notifications both for android and ios. I am quite successful with sending push notification with text and icon only. Now i am trying to send the notification with an image bottom. I searched every where but couldn't find a perfect docs to work on. Any suggestions please.
i installed this package using npm , i used this to send push notification. please refer this link.
https://www.npmjs.com/package/sns-mobile
AWS_SNS_App.getUsers(function (err, allDevices) {
if (err) {
console.log(err, err.stack); // an error occurred
} else {
if (allDevices.length != 0) {
var totalDevices = 0;
for (var i = 0; i < allDevices.length; i++) {
totalDevices = totalDevices + 1;
AWS_SNS_App.sendMessage(allDevices[i].EndpointArn, message, function (err, messageId) {
if (err) {
console.log('An error occured sending message to device %s');
res.send(err);
} else {
//res.send('Successfully sent a message to device , MessageID was : ' + messageId);
}
});
}
if (totalDevices === allDevices.length) {
res.send('Successfully sent a message to all devices');
}
}
}
});
sendMessage(endpointArn, message, callback) Send a message to a user.
The message parameter can be a String, or an Object with the formats
below. The callback format is callback(err, messageId).
from docs it indicates to send a endpointArn,message and we will get a callback of any response. what i suppose to send an image along with the image, is that possible or any another way to do that.
thanks.
Every image-containing push notification sent could contain a mediaReference that the app can later use to obtain content from a web service or from the apps bundled resources.
In any media case, the final resource link / bundle-resource-ref. can be composed within the app, (example) depending on other parameters within the push.
Remember that if the resource is not bundled you will have to download the image before displaying the notification (using it)
So the solution is in the client-side...
Implement specific methods for each of your platforms (android & ios), perform the required operations (i repeat, different and specific to the platform) in order to display the push notification with the image.
NOTE :
Tell me if you need references for building platform specific notifications with images. (and if so, what min sdk version you are using for each)
First of all thank you for your awesome work in building and maintaining this library.
I have a scenario in which I need to check if the person answered within 10 seconds. I have some code that looks similar to this where I measure the start time in the first waterfall step and I measure the end time in the next waterfall step, I ll find the difference between both in the second waterfall step.
bot.dialog('/duration', [(session, args)=>{
session.dialogData.startTime = new Date().getTime()
}, (session, results)=>{
session.dialogData.endTime = new Date().getTime()
}])
I feel that the code above is not accurate. I have seen a session.message.timestamp property. How would it be different than the code above
Is there a better way to measure time differences like these?
How do I account for network latency in such a scenario?
Thank you for your answers in advance
You can set the time you send the message and then re-evaluate with the message timestamp like:
var bot = new builder.UniversalBot(connector, [
function (session) {
session.userData.lastMessageSent = new Date();
builder.Prompts.text(session, 'Send something in 10 seconds or you die.');
},
function (session, result) {
if (session.userData.lastMessageSent) {
var lastMessageSent = new Date(session.userData.lastMessageSent);
var lastMessageReceived = new Date(session.message.timestamp);
var diff = lastMessageReceived - lastMessageSent / 1000;
if (diff >= 10) {
session.send('Game over.');
} else {
session.send('Good boy!');
}
}
}
]);
A better way to do that might be using the Application Insights connection when registering a bot.
This way the Bot Framework service measures your requests/responses and stores the timestamp automatically into Application Insights.
Once you copy the instrumentation key to the bot registration page, events under customEvents in Application Insights Analytics.
In case you just to have an actionable code, the answer above is a better solution.
I'm trying to send a raw push notification message from Azure to my mobile device through an Web API. Previously I made use of a toast message and I got that working just fine, but not so much with the raw message type. This is what I've tried so far in my web API, without any success:
var jObject = new JObject
{
{
"Body", pushMessage.Body
},
{
"From", pushMessage.From
},
{
"Date", DateTime.Now.ToString(CultureInfo.InvariantCulture)
},
{
"Title", pushMessage.Title
},
{
"TargetType", pushMessage.TargetType.ToString()
}
};
Notification notification = new WindowsNotification(jObject.ToString());
notification.Headers.Add("X-WNS-Type", "wns/raw");
notification.ContentType = "application/json";
var task = Notifications.Instance.Hub.SendNotificationAsync(notification, "some tag value");
The above code never pushes the actual message. Could someone please provide me with some information regarding this. I've tried various methods described on the web, without any success.
Many thanks!
Turns out the above code works just fine - there was an issue with one of the settings in Azure ... pretty stupid mistake in the end o_O