Can I join a Google Meet / Hangout call via an API? - twilio

If I have a Google Meet link, how can I programatically join the call? I can get the dial-in phone number and use something like Twilio, but then how can I set the caller ID to have a name?
I've seen various systems join calls with a specified name for a meet / hangout call.
I apologize for the vagueness of the question. I'm not sure how to better ask it - please add comments if you need clarification and I'll happily edit the question.

If you have a number in the request , You can just call uding the twillo API
import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.Call;
import com.twilio.type.PhoneNumber;
import java.net.URI;
public class Example {
// Find your Account Sid and Token at twilio.com/console
// DANGER! This is insecure. See http://twil.io/secure
public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
public static final String AUTH_TOKEN = "your_auth_token";
public static void main(String[] args) {
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
Call call = Call.creator(
new com.twilio.type.PhoneNumber("+14155551212"),
new com.twilio.type.PhoneNumber("+15017122661"),
URI.create("http://demo.twilio.com/docs/voice.xml"))
.create();
System.out.println(call.getSid());
}
}
Source : https://www.twilio.com/docs/voice/make-calls#initiate-an-outbound-call-with-twilio
You can also use fetcher to get the existing :
import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.Call;
public class Example {
public static final String ACCOUNT_SID = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
public static final String AUTH_TOKEN = "your_auth_token";
public static void main(String[] args) {
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
Call call = Call.fetcher("CA42ed11f93dc08b952027ffbc406d0868").fetch();
System.out.println(call.getTo());
}
}
When you have a Google Hangouts for Enterprise that comes with GSuite When a Google Hangouts meet starts, It gives a dial-in number with a pin.
You can connect using curl itself
curl 'https://api.twilio.com/2010-04-01/Accounts/AC8bc5f1756b2e10ce344333e0ec6f7acacc46/Calls.json' -X POST \
--data-urlencode 'To=+1 xxxx-xxxx-3235' \
--data-urlencode 'From=+1xxxxxxxxxx6' \
--data-urlencode 'Url=https://demo.twilio.com/welcome/voice/' \
--data-urlencode 'SendDigits=wwwww34975093#‬#' \
-u AC8bc5f1756b2e10c824e0ec6f7acacc46:[AuthToken]
Source :
Twilio Join Google Hangouts Conference Call

Looks like you can set caller id once the number is verified, otherwise not
https://support.twilio.com/hc/en-us/articles/223180148-Unable-to-Display-a-Business-Name-or-Custom-Text-as-Caller-ID

Related

How to do JSON parsing in GRPC micro-services in iOS using Swift 4.1 (Xcode 10)?

I am working on a project, that used GRPC microservices. Normally GRPC used protobuf as his default method to serialized data. But, we are using JSON as placed of protobuf. In general, we defined message and services in protobuf and complied with protoc , then merged generated file with the project. But somehow google made tough to merged JSON in GRPC. I thought Google should make a documentation like this (https://grpc.io/blog/grpc-with-json) for iOS developer too. But unfortunately, there is no separate documentation in Swift. I found it hard to used JSON type in GRPC. How will I call methods in CLIENT-SIDE code in Swift?
I want to pass two variable (data: String, idToken: String) i.e defined in Request struct after that services should give me a Response. In that way, I would understand both get and post method used in GRPC.
https://grpc.io/blog/grpc-with-json , In this link, we can check how java works with JSON+GRPC. I am adding this java code example for more understanding oh what I want to make in Swift, Maybe it will do some help.
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import io.grpc.MethodDescriptor;
public class UserManagerRpcGson {
private static final String SERVICE_NAME = "url";
public static final class Request {
public String data;
public String idToken;
}
public static final MethodDescriptor<Request, Response> REGISTER_METHOD =
MethodDescriptor.newBuilder(
marshallerFor(Request.class),
marshallerFor(Response.class))
.setFullMethodName(
MethodDescriptor.generateFullMethodName(SERVICE_NAME, "registerUser"))
.setType(MethodDescriptor.MethodType.UNARY)
.setSampledToLocalTracing(true)
.build();
static <T> MethodDescriptor.Marshaller<T> marshallerFor(Class<T> clz) {
return new MethodDescriptor.Marshaller<T>() {
#Override
public InputStream stream(T value) {
return new ByteArrayInputStream(GsonUtil.gson.toJson(value, clz).getBytes(StandardCharsets.UTF_8));
}
#Override
public T parse(InputStream stream) {
return GsonUtil.gson.fromJson(new InputStreamReader(stream, StandardCharsets.UTF_8), clz);
}
};
}
}

Is it possible to enable dual channel recording with following code

I am able to call a number with following code from the link
https://www.twilio.com/docs/api/voice/making-calls
Is it possible to enable dual channel recording with following code ?. if yes, how ?
SDK Version: 6.x 7.x
// Install the Java helper library from twilio.com/docs/java/install
import java.net.URI;
import java.net.URISyntaxException;
import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.Call;
import com.twilio.type.PhoneNumber;
public class Example {
// Find your Account Sid and Token at twilio.com/user/account
public static final String ACCOUNT_SID = "ACd6b6b7dc8ae6f3e6f7ff72c8dbbd457f";
public static final String AUTH_TOKEN = "your_auth_token";
public static void main(String[] args) throws URISyntaxException {
Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
Call call = Call.creator(new PhoneNumber("+14155551212"), new PhoneNumber("+15017250604"),
new URI("http://demo.twilio.com/docs/voice.xml")).create();
System.out.println(call.getSid());
}
}
Twilio developer evangelist here.
You are missing the parameter to record the call in your API call here. When building the call object you need something like the following:
Call call = Call.creator(
new PhoneNumber("+14155551212"),
new PhoneNumber("+15017250604"),
new URI("https://example.com/voice")
)
.setRecord(true)
.setRecordingChannels("dual")
.setRecordingStatusCallback("https://example.com/recording")
.create();
The URL that you pass to the call creator should point at an application that you control as well. This application needs to return TwiML that will connect the first call to another to give you the two legs to record. You need to use <Dial> with either <Number>, <Client>, <Sip> or <Sim>. Like this:
<Response>
<Dial>
<Number>NUMBER TO CONNECT TO</Number>
</Dial>
</Response>
Let me know if this helps at all.

Twilio does not load the TwiML instructions

I'm trying to make a call to a number using the Twilio service using a Trial Account.
I'm following the Java example here: https://www.twilio.com/docs/quickstart/java/rest/call-request
I've configured the example with my API credentials, the provided Twilio number, the destination number and the TwiML instructions url.
When I run the MakeCall class the destination number get called.
When I respond to the call I get the "trial account" message, then it asks me to press any key. When I press a key the call is dropped.
As I can see the TwiML instructions url is not called by Twilio.
I've tested also with the Test Credentials with no success.
Any idea on why the TwiML instructions url is not called?
Using the twilio-java helper library and following code from the docs you mentioned above:
We then instantiate a new client object, set the request method to
'POST', fill in the 'From', 'To' and 'Url' parameters in an
associative array, and fire off the request to Twilio!
Aside from any potential issues with your URL...did you also set the request method to POST while configuring your twilio number in the console?
import java.util.Map;
import java.util.HashMap;
import com.twilio.sdk.TwilioRestClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.instance.Account;
import com.twilio.sdk.resource.instance.Call;
import com.twilio.sdk.resource.factory.CallFactory;
public class MakeCall {
public static final String ACCOUNT_SID = "AC123";
public static final String AUTH_TOKEN = "456bef";
public static void main(String[] args) throws TwilioRestException {
TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN);
Account mainAccount = client.getAccount();
CallFactory callFactory = mainAccount.getCallFactory();
Map<String, String> callParams = new HashMap<String, String>();
callParams.put("To", "5105551212"); // Replace with your phone number
callParams.put("From", "(510) 555-1212"); // Replace with a Twilio number
callParams.put("Url", "http://demo.twilio.com/welcome/voice/"); // Configure your own URL with TwiML instructions using TwiML Bins
// Make the call
Call call = callFactory.create(callParams);
// Print the call SID (a 32 digit hex like CA123..)
System.out.println(call.getSid());
}
}

Posting and retrieving a JSON object via REST call in java

I have a Rest endpoint (jersey based) which accepts a JSON object which I retrieve by mapping it to a POJO, e.g
#POST
#Path("/test")
#Produces(MediaType.APPLICATION_JSON)
public void getResult(PojoClass pojo)
My PojoClass is:
#XmlRootElement
public class PojoClass {
private List<String> list;
public List<String> getList() {
return list;
}
public void setList(List<String> list) {
this.list = list;
}
}
Now if I send a json data via curl command:
curl -H "Content-type: application/json" -i -X 'POST' -d #/tmp/xyz.json http://127.0.0.1:8080/test
I am able to get it mapped properly into my PojoClass.
xvz.json is:
{
"list":[
"123",
"456"
]
}
The list of PojoClass will have two elements ("123" and "456").
But if do a post call from JAVA. And I am sending the same json structure as payload, it is being received as a PojoClass with list as single element, which is a concatenation like ["123","456"]
I am using "HttpURLConnection" to make a post call from java.
Is something extra needed to get the same result as cURL command ?
It was a library conflict between JSONObject and JSONArray which was corrupting my JSON in request Payload.
When I handled this error, request went just fine and everything worked like charm.

Apache Oltu Github integration example with Spring MVC

I'm developing an "Apache Oltu Spring MVC Github" integration example. In this example I will be sending "App ID" and "Secret" to get the "access_token" in order to access the protected resources like "Gist", "user" etc.
So first step is to create / register the "App" using https://github.com/settings/applications/new.
Once you create a App make sure to Note: AppID and Secret, we need these values to be used in Spring code.
To develop this functionality / code - I search a lot and I did not find any ready made code. So I decided to furnish / explain my code below. So one can find these links useful.
I've taken a reference of following URL's to developed whole code:-
https://developer.github.com/v3/oauth/
https://cwiki.apache.org/confluence/display/OLTU/OAuth+2.0+Client+Quickstart
http://www.jasha.eu/blogposts/2013/09/retrieve-facebook-profile-data-java-apache-oltu.html
Attached is the screen shot to register the "App" on Github. "MyApp" is the App that I created.
Use the same code from http://www.jasha.eu/blogposts/2013/09/retrieve-facebook-profile-data-java-apache-oltu.html, just make sure to change the
AUTHORIZATION_URL = "https://github.com/login/oauth/authorize";
ACCESS_TOKEN_URL = "https://github.com/login/oauth/access_token"
To get Protected Resource like User Profile use: https://api.github.com/user
The output I get when run the code:
The user4798111 has mentioned is correct and just adding some more details. Pre-requisite, you need to register App on Github. Once you registered the App, you will get the CLIENT_SECRET,CLIENT_ID to be used to get the Protected resources from the github.
If you're using the OAuthClientRequest API to to make an initial call, you need to have the following details
private static final String AUTHORIZATION_URL = "https://github.com/login/oauth/authorize";
private static final String CLIENT_ID = "8515a1e4XXXXXXX";
private static final String CLIENT_SECRET = "ae3487601d891d257f7193XXXXXXXXX";
private static final String REDIRECT_URL = "http://localhost:8080/apache-oltu/github/redirect";
private static final String ACCESS_TOKEN_URL = "https://github.com/login/oauth/access_token";
#RequestMapping(value = "/auth", method = RequestMethod.GET)
public String authenticate() throws OAuthSystemException {
OAuthClientRequest request = OAuthClientRequest
.authorizationLocation(AUTHORIZATION_URL)
.setClientId(CLIENT_ID)
.setRedirectURI(REDIRECT_URL)
.setResponseType("code")
.setScope("user,gist,user:email,user:follow,public_repo,repo,repo_deployment,repo:status,repo:invite")
.buildQueryMessage();
System.out.println("REDIRECT TO: "+request.getLocationUri());
return "redirect:" + request.getLocationUri();
}
The same something simllar you would need to use like below
request= new OAuthBearerClientRequest("https://api.github.com/user").
setAccessToken(oAuthResponse.getAccessToken()).
buildQueryMessage();
The information about the scopes and other details can be found here:
https://developer.github.com/apps/building-integrations/setting-up-and-registering-oauth-apps/about-authorization-options-for-oauth-apps/
https://developer.github.com/apps/building-integrations/setting-up-and-registering-oauth-apps/about-scopes-for-oauth-apps/
The result which could see is below for reference:
{
"login":"JavaHelper",
"id":8208031,
"avatar_url":"https://avatars0.githubusercontent.com/u/8208031?v=4",
"gravatar_id":"",
"url":"https://api.github.com/users/JavaHelper",
"html_url":"https://github.com/JavaHelper",
"followers_url":"https://api.github.com/users/JavaHelper/followers",
"following_url":"https://api.github.com/users/JavaHelper/following{/other_user}",
"gists_url":"https://api.github.com/users/JavaHelper/gists{/gist_id}",
"starred_url":"https://api.github.com/users/JavaHelper/starred{/owner}{/repo}",
"subscriptions_url":"https://api.github.com/users/JavaHelper/subscriptions",
"organizations_url":"https://api.github.com/users/JavaHelper/orgs",
"repos_url":"https://api.github.com/users/JavaHelper/repos",
"events_url":"https://api.github.com/users/JavaHelper/events{/privacy}",
"received_events_url":"https://api.github.com/users/JavaHelper/received_events",
"type":"User",
"site_admin":false,
"name":"JavaProgramer",
"company":null,
"blog":"",
"location":null,
"email":null,
"hireable":null,
"bio":null,
"public_repos":45,
"public_gists":0,
"followers":4,
"following":60,
"created_at":"2014-07-19T10:03:42Z",
"updated_at":"2017-09-09T12:55:57Z",
"private_gists":0,
"total_private_repos":0,
"owned_private_repos":0,
"disk_usage":142270,
"collaborators":0,
"two_factor_authentication":false,
"plan":{
"name":"free",
"space":976562499,
"collaborators":0,
"private_repos":0
}
}

Resources