API for sending group SMS - text

Does anyone know of an service / api that lets you send a group message? I've been searching through Twilio's docs - seems like you can only send a message to one person.
Ideal use case:
[API Number] ----Sends Text----> (Friend 1 + Friend 2 + Friend 3)
And the result is a group message with 4 people in it - the three friends and the API.

d7networks.com is doing it with their RESTful API
========================================================
curl -X POST -H 'Authorization: Basic xxxxxxx==' -d '{
"messages": [
{
"to": [
"777771",
"777772",
"777773"
],
"content": "Same content goes to 3 numbers",
"from": "TEST"
}
]
}' http://sms.d7networks.com:8080/secure/sendbatch

You can't do it exactly as you describe but you can build something that creates a group SMS where everyone is texting the same #. This blog post shows how to build a group messaging app like this with Meteor, MongoDB and Twilio.

As far as I can tell http://www.bandwidth.com is the only sms api that supports group texting. You can see it in action at https://bandwidth.wistia.com/medias/ymd7q9utm0#. Unfortunately their trial doesn't have access to this feature (the trial uses api v1 and this is a feature of api v2) and there's no easy way to sign up for an account.

Related

Azure search for user, groups, or service principle by name or email address via Rest API or python module (MS Graph)?

In azure when adding a user, group, or service principle to a role you can search by name and email address in the same search (screenshot below). When I look at the MS Graph APIs there are separate APIs for users, groups, and service principles (MS Graph API documentation links below). And it looks like the search options cannot be mixed (just display name or just email).
Does anyone know how to achieve a search like this using an Azure REST API. I'm curious if anyone knows what calls Azure is actually doing and if they are part of the published rest API? Or if one search is combining like multiple API calls which would be confusing since are paginated that would be hard to figure out what to display from which....
I'm building an app to add permissions and I'm trying to recreate a feature like this search.
Only way I can think of to achieve this now would be to select an option to search for either 'groups', 'users', or 'service principles'. Then another options to select search by 'email' or search by 'displayName' (but not both as the same search). This seems more clunky but technically ok.... but I'd rather do it like the azure screenshot below.
https://learn.microsoft.com/en-us/graph/api/user-list?view=graph-rest-1.0&tabs=http
https://learn.microsoft.com/en-us/graph/api/group-list?view=graph-rest-1.0&tabs=http
https://learn.microsoft.com/en-us/graph/api/serviceprincipal-list?view=graph-rest-1.0&tabs=http
Microsoft Graph API provides batching functionality where you can batch multiple requests together and send them as a single request for processing. In your case, on the server-side (Graph API side) three requests will be processed but from your application you will be sending a single request and get a single response.
Your request would be something like:
{
"requests": [
{
"id": "1",
"method": "GET",
"url": "/users?$filter=<your-filter-criteria>"
},
{
"id": "2",
"method": "GET",
"url": "/groups?$filter=<your-filter-criteria>"
},
{
"id": "3",
"method": "GET",
"url": "/servicePrincipals?$filter=<your-filter-criteria>"
}
]
}
You can learn more about the batching capability in Microsoft Graph API here: https://learn.microsoft.com/en-us/graph/json-batching.
So the batching answer was not exactly what I wanted but something really cool that I'll likely end up using in the future!
Since batching could get ugly with the paging results since say I want 30 total results (so i set paging to 10,10,10) then if one gives 10 and has nextlink and the next gives 0 and the last give 5. I now have 15 results to display but paging with the other and the sorting of results after the next could throw results earlier. It might just be weird and I don't have time to think it through.
I just ended up doing a drop down for users, groups, and service principals. And you have to search separate. Not as cool as how MS does it internally but its consistent, predictable, and works.

How to pull plain text from website using Azure Bot?

I'm working on an Azure Chatbot that will be connected to Facebook Messenger. The purpose of the bot is to look for the phrase of the day more or less. I currently have a url that returns the phrase of the day in plain text.
What I need the bot to do is for example:
User: "Hi, what is the phrase for today?"
The Bot will search the url and retrieve the plain text returned.
Bot: "The phrase for today is 'Don't Give Up!'"
I'm currently using QnA Maker for a knowledgebase, but it only works for static FAQs, not for pulling text from a website. Any help will be appreciated.
Thanks,
Axel
There's a couple of different ways you can go about this:
Programmatically Update Your QnA Knowledgebase
You'd need to create some kind of separate function (maybe using Azure Functions) outside of your bot that makes this API request every day.
curl -v -X PATCH "https://westus.api.cognitive.microsoft.com/qnamaker/v4.0/knowledgebases/{kbId}"
-H "Content-Type: application/json"
-H "Ocp-Apim-Subscription-Key: {subscription key}"
--data-ascii "{body}"
Body:
{
"add": {
"qnaList": [
{
"id": 0,
"answer": "You can change the default message if you use the QnAMakerDialog. See this for details: https://docs.botframework.com/en-us/azure-bot-service/templates/qnamaker/#navtitle",
"source": "Custom Editorial",
"questions": [
"How can I change the default message from QnA Maker?"
],
"metadata": []
},
[...]
Have the bot use an HTTP Request to get the Daily Phrase
Alternatively:
You would start by either intercepting messages that equal/contain:
"Hi, what is the phrase for today?"
Or, if you want the user's question to be a little more flexible, you could use LUIS to parse user input and return an intent.
Once you code that into your bot, just have the bot make a regular HTTP request to your website to the phrase, then send that to the user.
I can provide some code examples, if needed, but please provide a code sample of where in your bot you want this to occur. The URL for your phrase may also be helpful.

API call IBM Watson Natural Language Understanding-xq - Python or Postman

I'm struggling to connect to the IBM Watson API for Natural Language Understanding.
I've added it to the Resource list in my IAM account. I've got to the page with an example POST request to connect to the API, and I can't seem to authenticate. I've blanked out the API key from this request but in the pages the key is supplied so I'm struggling to see why it's not working
curl -X POST -u "#######" \
-H "Content-Type: application/json" \
-d '{ "text": "I still have a dream. It is a dream deeply rooted in the
American dream. I have a dream that one day this nation will rise up and
live out the true meaning of its creed: \"We hold these truths to be
self-evident, that all men are created equal.\"", "features": {
"sentiment": {}, "keywords": {} }}' \
"https://gateway-lon.watsonplatform.net/natural-language-
understanding/api/v1/analyze?version=2018-03-19"
I've tried pasting this into Postman but I just get a 401 Unauthorized response, which makes me think it's something in the account pages of the IAM, but they've chnage the interface and not update the documentation, and I'm going round in circles because the instructions don't match the menus.
Any pointers would be appreciated. I intend to query through Python, so I'm hoping once I can get past the authentication issue it's as simple as copying the Python code out of Postman
Your -u credentials should be:
-u "apikey:#######"
As per the API documentation -
https://cloud.ibm.com/apidocs/natural-language-understanding#authentication
Somehow the API credentials were not being recognised. I must have done something wrong in the initial IAM setup, which meant that when I deleted the credentials, re-created them and then copied the new key ... everything immediately started working. Complete mystery as to why but hopefully this helps someone. Here are the instructions I followed
https://console.bluemix.net/docs/services/natural-language-understanding/getting-started.html#getting-started-tutorial
I used the SDK as suggested by Simon O'Doherty
It might also be related to me having gone into the "Manage" >> "Account" and deleted any Access Groups and Service IDs I'd attempted to create by following the "Getting Started with IAM" instructions from here, which I suspect might have been what confused me
IAM getting started (not required)

Instagram Subscription API always creates just 1 subscription and overwrites the other

I finally figured out how to create subscription. And it works fine, I get pushes from Instagram everytime I add new media.
Now the problem is, I've set up a mechanism so that our users can sync their insta to our site. So I should be able to create multiple subscriptions to the same client_id. From what I understand subscriptions is built to do just that. Now when another user comes along and creates a new subscription the other one (created with another instagram account) is getting deleted and replaced. I receive a successful instagram subscription with the exact same subscription_id as the one for my other subscription. When I list the subscriptions with curl I only see 1 subscription with the subscription_id 0.
{"data": [{"id": 0, "type": "subscription", "object": "user", "object_id": null, "aspect": "media", "subscription_id": 0, "callback_url": "**callbackurlReplacedForSecurityReasons"}], "meta": {"code": 200}}
How can this be?
From the docs the call to create the subscription looks like this:
curl -F 'client_id=CLIENT-ID' \
-F 'client_secret=CLIENT-SECRET' \
-F 'object=user' \
-F 'aspect=media' \
-F 'verify_token=myVerifyToken' \
-F 'callback_url=http://YOUR-CALLBACK/URL' \
https://api.instagram.com/v1/subscriptions/
Now I've set the verify_token to a unique string for each call in order to test if that was the problem as the doc said it should be individual for every request but it did not matter, same problem.
The problem exists for Sandbox mode and Live mode.
Is there anything else I am missing here? Am I getting this whole feature wrong? Is there only a way to create 1 subscription per client_id but if so why does it give me back a subscription_id?
Ok I've figured it out myself by surfing the web somewhere I've found a hint that enlighted me :D It is really poorly documented how subscriptions work on instagram side.
I was getting that feature completely wrong. My understanding was, that I have to create a subscription per user and if the user don't want it anymore he just deletes it.
How it really works is as follows:
You create 1 subscription for the whole client (not every user). Each user just has to authorize the application and THATS IT! Your callback method will now receive all updates of those users who have authorized your client. If they don't want it anymore they either have to deauthorize your client (which is very unlikely that he will find that option ;)) or you just don't react to incoming messages anymore.
A bit off topic but good to know:
I also want to add the structure of the json that is coming from insta to your callback because this is not documented on instagram side (you have no idea what you get without testing it yourself)
the json you receive when new media is posted looks as follows:
[{
"object": "user",
"object_id": "4857061161",
"changed_aspect": "media",
"time": 1502958709,
"data": {
"media_id": "1583254852313311736_4857061161"
},
"subscription_id": 0
}]
object_id is the instagram user id which you can use to differentiate between users and map to your internal user in the authorization process!
Also notice that it is wrapped in an array for whatever reason...

Slack API, get current location

Is there any method to get current user location. Let say I created some "slash" command /map. When I am calling this command - POST message being send to my nodejs server, and server returns some json data.
{
"channel": "#map",
"username": "test",
"unfurl_links": true,
"icon_emoji": ":world_map:",
"attachments": [
{
"fallback": "Required plain-text summary of the attachment.",
"pretext": "Beautiful Personalized Map Sharing",
"image_url": "http://static.mapjam.com/yrjkbmb/auto/640x480.jpg",
"thumb_url": "http://static.mapjam.com/yrjkbmb/auto/640x480.jpg"
}
]
}
Because I am authenticated I am able to get some Slack user info:
username
email etc..
How can I access Slack user lat, long if it is possible though
Currently there is nothing available in the user info to get the geographical position of a user from the Slack API.
Please refer to the Users Info Slack API documentation and the User Type documentation.
If you are expecting to create a slash command the slack application would have to have permissions to your devices location. Looking at the permissions on my android app id does not request permissions to the devices location.
Just spit-balling, there could be a way to do it. This is completely hypothetical simplified method. You would have to have a helper application on the device that has permissions to the location of the device. That app would listen for the /location /map request then post to the channel where the request came from.

Resources