This documentation is for v0 of our APIs and might change. See
https://v1.docs.wgtwo.com for
our guaranteed stable APIs.
#How to set up call forwarding
#Overview
This example shows you how to forward calls to other numbers or services. In order to forward calls
your credentials need to have one or more of callforwarding.disable
, callforwarding.to_voicemail
,
callforwarding.to_number
rights.
For call forwarding to a number or a trunk, you can either forward all calls, unconditional
forwarding, or you can forward if busy
, unanswered
and/or unavailable
.
Forwarding to voicemail can be done to the default voicemail service, or a custom service.
#Limitations
- Call forwarding is not available to special/premium/international numbers.
- Forwarding to trunk is only available if you have a trunk set up for you. Please get in touch with products@wgtwo.com if you want to discuss this option.
- Forwarding to non-default voicemail services is only available with prior approval. Please get in touch with products@wgtwo.com if you want to discuss this option.
#Forward all calls (unconditional) to another number
#!/usr/bin/env bash
grpcurl \
-H "Authorization: Bearer ${ACCESS_TOKEN}"\
-import-path . \
-proto wgtwo/callforward/v0/callforward.proto \
-d '{
"subscriber": { "e164": "+4672xxxxxxx"},
"unconditional": {
"forward_to_number": { "e164": "+4672xxxxxxx"}
}
}' \
sandbox.api.wgtwo.com:443 \
wgtwo.callforward.v0.CallForwardingService/SetToNumber
<dependencies>
undefined
<dependency>
<groupId>com.github.working-group-two.wgtwoapis</groupId>
<artifactId>utils-grpc</artifactId>
<version>cca7093</version>
</dependency>
</depenencies>
Snippet
package com.wgtwo.examples.thirdpartydev.forwarding
import com.wgtwo.api.v0.callforward.CallForwardingProto
import com.wgtwo.api.v0.callforward.CallForwardingServiceGrpc
import com.wgtwo.api.common.Environment
import com.wgtwo.api.v0.common.PhoneNumberProto
import com.wgtwo.api.util.auth.BearerToken
import com.wgtwo.api.util.auth.Channels
private val channel = Channels.createChannel(Environment.PRODUCTION)
private val credentials = BearerToken { "MY_ACCESS_TOKEN" } // Add your credentials
private val stub = CallForwardingServiceGrpc.newBlockingStub(channel).withCallCredentials(credentials)
fun main() {
val message = with(CallForwardingProto.NumberCallForwardingRequest.newBuilder()) {
this.subscriber = with(PhoneNumberProto.PhoneNumber.newBuilder()) {
this.e164 = "+4672xxxxxxx"
build()
}
this.unconditional = with(CallForwardingProto.Unconditional.newBuilder()) {
this.forwardToNumber = with(PhoneNumberProto.PhoneNumber.newBuilder()) {
this.e164 = "+4672xxxxxxx"
build()
}
build()
}
build()
}
val result = stub.setToNumber(message)
if (result.status == CallForwardingProto.CallForwardingResponse.Status.ACCEPTED) {
println("Successfully set call forwarding")
} else {
println("""
Failed to set call forwarding:
status=${result.status}
description=${result.errorMessage}"
""".trimIndent())
}
}
#Forward calls if busy or unavailable (conditional) to another number
#!/usr/bin/env bash
grpcurl \
-H "Authorization: Bearer ${ACCESS_TOKEN}"\
-import-path . \
-proto wgtwo/callforward/v0/callforward.proto \
-d '{
"subscriber": { "e164": "+4672xxxxxxx"},
"conditional": {
"busy": { "e164": "+4672xxxxxxx"},
"unavailable": { "e164": "+4672xxxxxxx"}
}
}' \
sandbox.api.wgtwo.com:443 \
wgtwo.callforward.v0.CallForwardingService/SetToNumber
<dependencies>
undefined
<dependency>
<groupId>com.github.working-group-two.wgtwoapis</groupId>
<artifactId>utils-grpc</artifactId>
<version>cca7093</version>
</dependency>
</depenencies>
Snippet
package com.wgtwo.examples.thirdpartydev.forwarding
import com.wgtwo.api.v0.callforward.CallForwardingProto
import com.wgtwo.api.v0.callforward.CallForwardingServiceGrpc
import com.wgtwo.api.common.Environment
import com.wgtwo.api.v0.common.PhoneNumberProto
import com.wgtwo.api.util.auth.BearerToken
import com.wgtwo.api.util.auth.Channels
private val channel = Channels.createChannel(Environment.PRODUCTION)
private val credentials = BearerToken { "MY_ACCESS_TOKEN" } // Add your credentials
private val stub = CallForwardingServiceGrpc.newBlockingStub(channel).withCallCredentials(credentials)
fun main() {
val message = with(CallForwardingProto.NumberCallForwardingRequest.newBuilder()) {
this.subscriber = with(PhoneNumberProto.PhoneNumber.newBuilder()) {
this.e164 = "+4672xxxxxxx"
build()
}
this.conditional = with(CallForwardingProto.Conditional.newBuilder()) {
this.busy = with(PhoneNumberProto.PhoneNumber.newBuilder()) {
this.e164 = "+4672xxxxxxx"
build()
}
this.unavailable = with(PhoneNumberProto.PhoneNumber.newBuilder()) {
this.e164 = "+4672xxxxxxx"
build()
}
build()
}
build()
}
val result = stub.setToNumber(message)
if (result.status == CallForwardingProto.CallForwardingResponse.Status.ACCEPTED) {
println("Successfully set call forwarding")
} else {
println("""
Failed to set call forwarding:
status=${result.status}
description=${result.errorMessage}"
""".trimIndent())
}
}
#Forward all calls (unconditional) to a trunk
#!/usr/bin/env bash
grpcurl \
-H "Authorization: Bearer ${ACCESS_TOKEN}"\
-import-path . \
-proto wgtwo/callforward/v0/callforward.proto \
-d '{
"subscriber": { "e164": "+4672xxxxxxx"},
"unconditional_trunk_forwarding": {
"forward_to_trunk": { "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}
}
}' \
sandbox.api.wgtwo.com:443 \
wgtwo.callforward.v0.CallForwardingService/SetToTrunk
<dependencies>
undefined
<dependency>
<groupId>com.github.working-group-two.wgtwoapis</groupId>
<artifactId>utils-grpc</artifactId>
<version>cca7093</version>
</dependency>
</depenencies>
Snippet
package com.wgtwo.examples.thirdpartydev.forwarding
import com.wgtwo.api.v0.callforward.CallForwardingProto
import com.wgtwo.api.v0.callforward.CallForwardingServiceGrpc
import com.wgtwo.api.common.Environment
import com.wgtwo.api.v0.common.PhoneNumberProto
import com.wgtwo.api.util.auth.BearerToken
import com.wgtwo.api.util.auth.Channels
private val channel = Channels.createChannel(Environment.PRODUCTION)
private val credentials = BearerToken { "MY_ACCESS_TOKEN" } // Add your credentials
private val stub = CallForwardingServiceGrpc.newBlockingStub(channel).withCallCredentials(credentials)
fun main() {
val message = with(CallForwardingProto.TrunkCallForwardingRequest.newBuilder()) {
this.subscriber = with(PhoneNumberProto.PhoneNumber.newBuilder()) {
this.e164 = "+4672xxxxxxx"
build()
}
this.unconditionalTrunkForwarding = with(CallForwardingProto.UnconditionalTrunkForwarding.newBuilder()) {
this.forwardToTrunk = with(CallForwardingProto.Trunk.newBuilder()) {
this.id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
build()
}
build()
}
build()
}
val result = stub.setToTrunk(message)
if (result.status == CallForwardingProto.CallForwardingResponse.Status.ACCEPTED) {
println("Successfully set call forwarding")
} else {
println("""
Failed to set call forwarding:
status=${result.status}
description=${result.errorMessage}"
""".trimIndent())
}
}
#Forward calls if busy or unavailable or no answer (conditional) to default voicemail
#!/usr/bin/env bash
grpcurl \
-H "Authorization: Bearer ${ACCESS_TOKEN}"\
-import-path . \
-proto wgtwo/callforward/v0/callforward.proto \
-d '{
"subscriber": { "e164": "+4672xxxxxxx"},
"conditional": {
"busy": { "e164": "+4672xxxxxxx"},
"unavailable": { "e164": "+4672xxxxxxx"},
"no_reply": { "e164": "+4672xxxxxxx"}
}
}' \
sandbox.api.wgtwo.com:443 \
wgtwo.callforward.v0.CallForwardingService/SetToVoicemail
<dependencies>
undefined
<dependency>
<groupId>com.github.working-group-two.wgtwoapis</groupId>
<artifactId>utils-grpc</artifactId>
<version>cca7093</version>
</dependency>
</depenencies>
Snippet
package com.wgtwo.examples.thirdpartydev.forwarding
import com.wgtwo.api.v0.callforward.CallForwardingProto
import com.wgtwo.api.v0.callforward.CallForwardingServiceGrpc
import com.wgtwo.api.common.Environment
import com.wgtwo.api.v0.common.PhoneNumberProto
import com.wgtwo.api.util.auth.BearerToken
import com.wgtwo.api.util.auth.Channels
private val channel = Channels.createChannel(Environment.PRODUCTION)
private val credentials = BearerToken { "MY_ACCESS_TOKEN" } // Add your credentials
private val stub = CallForwardingServiceGrpc.newBlockingStub(channel).withCallCredentials(credentials)
fun main() {
val message = with(CallForwardingProto.VoicemailCallForwardingRequest.newBuilder()) {
this.subscriber = with(PhoneNumberProto.PhoneNumber.newBuilder()) {
this.e164 = "+4672xxxxxxx"
build()
}
build()
}
val result = stub.setToVoicemail(message)
if (result.status == CallForwardingProto.CallForwardingResponse.Status.ACCEPTED) {
println("Successfully set call forwarding")
} else {
println("""
Failed to set call forwarding:
status=${result.status}
description=${result.errorMessage}"
""".trimIndent())
}
}
#Disable call forwarding
#!/usr/bin/env bash
grpcurl \
-H "Authorization: Bearer ${ACCESS_TOKEN}"\
-import-path . \
-proto wgtwo/callforward/v0/callforward.proto \
-d '{
"subscriber": { "e164": "+4672xxxxxxx"}
}' \
sandbox.api.wgtwo.com:443 \
wgtwo.callforward.v0.CallForwardingService/Disable
<dependencies>
undefined
<dependency>
<groupId>com.github.working-group-two.wgtwoapis</groupId>
<artifactId>utils-grpc</artifactId>
<version>cca7093</version>
</dependency>
</depenencies>
Snippet
package com.wgtwo.examples.thirdpartydev.forwarding
import com.wgtwo.api.v0.callforward.CallForwardingProto
import com.wgtwo.api.v0.callforward.CallForwardingServiceGrpc
import com.wgtwo.api.common.Environment
import com.wgtwo.api.v0.common.PhoneNumberProto
import com.wgtwo.api.util.auth.BearerToken
import com.wgtwo.api.util.auth.Channels
private val channel = Channels.createChannel(Environment.PRODUCTION)
private val credentials = BearerToken { "MY_ACCESS_TOKEN" } // Add your credentials
private val stub = CallForwardingServiceGrpc.newBlockingStub(channel).withCallCredentials(credentials)
fun main() {
val message = with(CallForwardingProto.DisableCallForwardingRequest.newBuilder()) {
this.subscriber = with(PhoneNumberProto.PhoneNumber.newBuilder()) {
this.e164 = "+4672xxxxxxx"
build()
}
build()
}
val result = stub.disable(message)
if (result.status == CallForwardingProto.CallForwardingResponse.Status.ACCEPTED) {
println("Successfully disabled call forwarding")
} else {
println("""
Failure to disable call forwarding:
status=${result.status}
description=${result.errorMessage}"
""".trimIndent())
}
}