Microsoft graph call transfer using specified resource account / number - microsoft-graph-api

Using a Microsoft Teams bot and the graph call create api, I am able to call myself (as operator) and transfer the call to an outbound PTSN number. When the bot calls myself, I can confirm it calls using the specified resource account and the associated phone number. However, when transferring this call to the PTSN number, the receiving PTSN number sees my number instead of the bot's resource account number.
Is there a way to specify which resource account to use when transferring the call to the PTSN number? I have searched the docs, but could not find any solution.
To make it clear:
Bot calls operator using resource account (e.g. +318001234).
Operator takes the call, the bot receives the established state update and starts the transfer to the PTSN number (e.g. +31612345678)
The receiver of the transfer now sees the number of the person being transferred. I would like the receiver to see the number of the bot (+318001234 in this example).
Request payload used to transfer:
{
"transferTarget": {
"endpointType": "default",
"identity": {
"phone": {
"id": [PTSN NUMBER OF RECEIVER]
}
},
},
"transferee": {
"identity": {
"user": {
"id": [ID OF OPERATOR],
"tenantId": [OPERATOR TENANT ID]
}
}
}
}

Related

Pass a From phone number to Dialogflow via a Twilio Integration

I have a Dialogflow Bot that is integrated with a Twilio phone number. I am trying to get Twilio to pass the "from" number that initiates an interaction to Dialogflow, so I can later log it in a fulfillment.
I put this in Fulfillment:
function reschedule(agent) {
const OriginalDetectIntentRequest = agent.parameters.OriginalDetectIntentRequest;
then: axios.post('https://sheetdb.io/api/v1/q0te84lfo1aal?sheet=Appointments', {
"data": {
"student": student,
"to_date": to_date,
"from_date": from_date,
"created": new Date(),
"OriginalDetectIntentRequest" : OriginalDetectIntentRequest,
}
});
Everything posts except the OriginalDetectIntentRequest.
Here's the reference: https://cloud.google.com/dialogflow/es/docs/reference/rest/v2/OriginalDetectIntentRequest

Issue passing in custom parameters to Twilio API

I am attempting to build out a process that will do the following:
New contact lands in my CRM (Podio)
The CRM is triggered to send a POST containing a custom parameter to Twilio which will then initiate a flow
The Twilio flow will call my cell and prompt me to connect to the new contact
Once I press 1, it will take the custom parameter (new contact's phone number) and connect
me to them.
So far, I have been able to get 1-3 with no problem.
However, according to the the API documentation from Twilio I should be able to pass a 3rd parameter in the JSON body of my HTTP request containing custom "Parameters". When I attempt this the parameters aren't showing in the Twilio studio logs and thus I am unable to connect the call to the new lead.
This is the JSON body I am sending over to my Twilio Flow's API
{
"To": "+1xxxxxxxxx1",
"From": "+1xxxxxxxxx2",
"Parameters": {
"name": "example name",
"prospectphone": "+1xxxxxxxxx3"
}
}
When I view the logs in Twilio this is what I received.
{
"contact": {
"channel": {
"address": "+1xxxxxxxxx2"
}
},
"trigger": {
"request": {
"from": "+1xxxxxxxxx2",
"to": "+1xxxxxxxxx1",
"parameters": {}
}
},
"widgets": {},
"flow": {
"flow_sid": "FW936f72c0eb8d3945d0d55c62465e37a8",
"data": {},
"channel": {
"address": "+1xxxxxxxxx2"
},
"sid": "FN955cdb12827f84c8af8fc9b5264e5a28"
}
}
I really can't figure out what I'm missing here? Has anyone run into this before? Is this something you can only do if you're using the SDK or does the additional parameter need to be passed in some other way?
It should be sent x-www-form-urlencoded.
From the documentation:
"Note: the JSON value must explicitly be passed as a string, not as a hash object. Depending on your particular HTTP library, you may need to add quotes or URL encode the JSON string."
Trigger a Twilio Studio Flow Execution via the REST API

twilio access token grants for voice documentation

I have a browser based twilio phone app that works well, but for better security we are integrating access tokens now. But we can't find ANY documentation on grants anywhere. We are constructing everything ourselves in our backend, so we are specifically looking for the variables we need to put in our JSON for that, for receiving calls and sending calls.
I have asked Twilio, but it's sunday. When they return a response, if that comes first, and if it works, I'll put it here to help others who might be looking for this as we are.
ie. here is the JSON payload:
{"sub":"AC*****","nbf":1578251940,"iss":"SK*****","exp":1578338340,"iat":1578252060,"grants":{"identity":"ID_whatever","voice":{"service_sid":"AP*****"}},"jti":"SK*****"}
Any help is appreciated.
Twilio have responded with a working payload template, here it is in case anyone else needs it.
{
// API key SID concatenated with current timestamp
"jti": "SK...-1578329486",
// API key SID
"iss": "SK...",
// account SID
"sub": "AC...",
// expiration timesetamp
"exp": 1578333086,
"grants": {
// Client name
"identity": "alice",
"voice": {
"incoming": {
// if incoming connections are allowed
"allow": true
},
"outgoing": {
// if outgoing connections are allowed, the application SID
"application_sid": "AP..."
}
}
}

Get multiple mobile phone numbers via microsoft graph api from outlook.com contact

Im trying to read all contact data from my outlook.com account into my app via
https://graph.microsoft.com/beta/me/contacts?$top=10000
At first glance, this seems to work well, but later I noticed this:
For contacts with multiple mobile phone numbers, Microsoft only sends the first mobile phone number.
In v1.0 api version of graph, there is simply no field for a second mobile phone number, but in beta api each contact has the property phones, which is a collection of objects of phone resource type. Therefore it should be possible to get multiple mobile phone numbers.
Is this a bug in the API or am I doing something wrong? Is there a different API, that provides all contact data?
EDIT:
As requested per comment: I really mean multiple mobile phone numbers:
It looks like multiple mobile phone numbers isn't supported by Graph. In v1.0 API, each contact has a mobilePhone string property (not an array). In beta Graph API, when you try adding multiple mobile phone numbers to a contact you get the following error:
PATCH https://graph.microsoft.com/beta/me/contacts/{contact-id}
{
"phones": [
{ "number": "1234567891", type: "home"},
{ "number": "9876543210", type: "mobile"},
{ "number": "4564564562", type: "mobile"}, // second mobile number
]
}
// Response
{
"error": {
"code": "ErrorInvalidProperty",
"message": "The multi-value property Phones has too many entries of the following type: of type: contacts:PhoneNumber:MobilePhone. The maximum number allowed is 1.",
"innerError": {
"request-id": "578d85ba-e467-47a4-8cc1-5671fde4a83f",
"date": "2017-12-29T20:07:46"
}
}
}
However, you can get all phone numbers for all contacts in one call when contacts have different types of numbers - home, mobile, etc. I just tested this with an outlook.com account and here are the API calls to set multiple phone numbers on a contact and get them all in one API call.
I found a random contact to test with, copied their ID and made a PATCH request to https://graph.microsoft.com/beta/me/contacts/[contact-id].
Patch body:
{
"phones": [
{ "number": "1234567891", type: "home"},
{ "number": "9876543210", type: "mobile"},
]
}
To confirm the phones were in fact updated, I sent a request to GET https://graph.microsoft.com/beta/me/contacts/[contact-id]/phones and the two phone numbers were returned in the JSON response.
Sending this same request to the v1.0 endpoint won't work since there isn't a phones property on a contact. However, you can still get this data in v1.0 since it's just split across multiple fields.
It looks like sending a request to GET https://graph.microsoft.com/beta/me/contacts?$select=phones returns phones for all users.
The beta API is subject to change so we don't recommend building production applications that depend on the this endpoint. Please keep an eye on the public changelog for when this will move to v1.0.
If you would like to see support for multiple mobile phones in Graph API, please post on our UserVoice.

Check if twitter account has been deactivated?

I'm using the twitter4j API and I want to see if, given the ID of a user's account, if that account has been deactivated.
You need to use users/show. It will give you an error code if the user has been suspended.
For example
https://api.twitter.com/1.1/users/show.json?screen_name=nero
Returns
{
"errors": [
{
"code": 63,
"message": "User has been suspended."
}
]
}
If you only have the ID, you can make a similar call - https://api.twitter.com/1.1/users/show.json?user_id=.....
With Twitter4J you use showUser and pass it either the string of the username, or the int of the user ID.
As far as I know there is no dedicated method to do this but using users/lookup (in your case this method) with the user ids you are getting back the the active users only. So if some id is missing from the response those users are the suspended ones.

Resources