Skip to content

Instantly share code, notes, and snippets.

@ktoraskartwilio
ktoraskartwilio / MessageRotator.java
Last active December 28, 2015 04:18
Message Sender Rotator. Randomly picks a phone number to send the message "From"
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import com.twilio.sdk.TwilioRestClient;
import com.twilio.sdk.TwilioRestException;
import com.twilio.sdk.resource.instance.Account;
@ktoraskartwilio
ktoraskartwilio / DropDID.java
Created November 21, 2013 22:32
Drop DID's from an account
/*
* This class gets the list of IncomingPhoneNumbers(DID's)
* for an account. Based on the cut off date, the filtered
* DID's are deleted from this account
*
*/
public class DropDID {
@ktoraskartwilio
ktoraskartwilio / MessageAlerts.java
Last active December 31, 2015 22:09
Message alert notifications generation code.
package com.twilio.demo;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
@ktoraskartwilio
ktoraskartwilio / autodialer.rb
Last active August 29, 2015 13:56
Auto Dialer
require "sinatra"
require 'rubygems'
require 'twilio-ruby'
accountsid = "<Your AccountSid>"
authtoken = "<Your AuthToken>"
callerid = "<CallerId>"
#Hash of phone numbers to <Dial> out to
phonenumbers = { "1" => "+15555555555",
import com.google.i18n.phonenumbers.CountryCodeToRegionCodeMap;
import com.google.i18n.phonenumbers.NumberParseException;
import com.google.i18n.phonenumbers.PhoneNumberUtil;
import com.google.i18n.phonenumbers.Phonenumber;
import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber;
import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber.CountryCodeSource;
public static String lookupCountryLibPhoneNumber(String phonenumber) {
String countryKey = null;
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Gather timeout="10" finishOnKey="*" action="endpoint to process DTMF">
<Say>Enter 1 for Mortgage Department</Say>
<Say>Enter 2 for Customer Support</Say>
</Gather>
</Response>
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Enqueue workflowSid="WW0123456789abcdef0123456789abcdef"/>
<Task>{"account_number": "12345abcdef"}</Task>
</Enqueue>
</Response>
{
"task_routing":{
"filters":[
{
"friendly_name":"Gold Tickets",
"expression":"customer_value == 'Gold' AND type == 'ticket'",
"targets":[
{
"queue":"WQ0123456789abcdef0123456789abcdef",
"priority":"2"
{
"instruction" "dequeue",
"to": "+14151112222",
"from": "+18001231234",
"post_work_activity_sid": "WA0123456789abcdef0123456789abcdef"
}
@ktoraskartwilio
ktoraskartwilio / TwilioProgVideo_ICE_Server_Setup.java
Last active February 15, 2017 00:12
TwilioProgVideo_ICE_Server_Setup
VideoClient videoClient = new VideoClient(this, VIDEO_ACCESS_TOKEN);
/*
* Documentation related to ICE servers can be found here:
* https://media.twiliocdn.com/sdk/android/video/releases/1.0.0-beta8/docs/com/twilio/video/IceServer.html
*/
Set<IceServer> iceServers = new HashSet<>();
iceServers.add(new IceServer("stun:foo.bar.address?transport=udp"));
iceServers.add(new IceServer("turn:foo.bar.address:3478?transport=udp", "fake", "pass"));