├── .env.example ├── .gitignore ├── LICENSE ├── README.md ├── app.py ├── requirements.txt └── static ├── chat ├── index.css ├── index.html └── index.js ├── config-check.js ├── index.css ├── index.html ├── notify ├── facebook_messenger.html ├── index.html ├── notify.css └── notify.js ├── sync ├── index.css ├── index.html └── index.js └── video ├── index.html ├── quickstart.js └── site.css /.env.example: -------------------------------------------------------------------------------- 1 | DEBUG=False 2 | 3 | # Required for all uses 4 | TWILIO_ACCOUNT_SID= 5 | TWILIO_API_KEY= 6 | TWILIO_API_SECRET= 7 | 8 | # Required for Chat 9 | # TWILIO_CHAT_SERVICE_SID= 10 | 11 | # Required for Notify 12 | # TWILIO_NOTIFICATION_SERVICE_SID= 13 | 14 | # Optional for Sync 15 | # By default, this app will use the default instance for your account (named "default"). 16 | # TWILIO_SYNC_SERVICE_SID= 17 | 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | .vscode/ 3 | 4 | # Byte-compiled / optimized / DLL files 5 | __pycache__/ 6 | *.py[cod] 7 | *$py.class 8 | 9 | # C extensions 10 | *.so 11 | 12 | # Distribution / packaging 13 | .Python 14 | env/ 15 | build/ 16 | develop-eggs/ 17 | dist/ 18 | downloads/ 19 | eggs/ 20 | .eggs/ 21 | lib/ 22 | lib64/ 23 | parts/ 24 | sdist/ 25 | var/ 26 | *.egg-info/ 27 | .installed.cfg 28 | *.egg 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .coverage 44 | .coverage.* 45 | .cache 46 | nosetests.xml 47 | coverage.xml 48 | *,cover 49 | .hypothesis/ 50 | 51 | # Translations 52 | *.mo 53 | *.pot 54 | 55 | # Django stuff: 56 | *.log 57 | local_settings.py 58 | 59 | # Flask stuff: 60 | instance/ 61 | .webassets-cache 62 | 63 | # Scrapy stuff: 64 | .scrapy 65 | 66 | # Sphinx documentation 67 | docs/_build/ 68 | 69 | # PyBuilder 70 | target/ 71 | 72 | # IPython Notebook 73 | .ipynb_checkpoints 74 | 75 | # pyenv 76 | .python-version 77 | 78 | # celery beat schedule file 79 | celerybeat-schedule 80 | 81 | # dotenv 82 | .env 83 | 84 | # virtualenv 85 | venv/ 86 | ENV/ 87 | 88 | # Spyder project settings 89 | .spyderproject 90 | 91 | # Rope project settings 92 | .ropeproject 93 | 94 | # Docker 95 | Dockerfile 96 | .dockerignore 97 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 TwilioDevEd 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | Twilio 3 | 4 | 5 | # Twilio SDK Starter Application for Python 6 | 7 | This sample project demonstrates how to use Twilio APIs in a Python web 8 | application. Once the app is up and running, check out [the home page](http://localhost:5000) 9 | to see which demos you can run. You'll find examples for [Chat](https://www.twilio.com/chat), 10 | [Video](https://www.twilio.com/video), [Sync](https://www.twilio.com/sync), and more. 11 | 12 | Let's get started! 13 | 14 | ## Configure the sample application 15 | 16 | To run the application, you'll need to gather your Twilio account credentials and configure them 17 | in a file named `.env`. To create this file from an example template, do the following in your 18 | Terminal. 19 | 20 | ```bash 21 | cp .env.example .env 22 | ``` 23 | 24 | Open `.env` in your favorite text editor and configure the following values. The application runs 25 | by default in `production` environment. Feel free to update `DEBUG` to True if needed. 26 | 27 | ### Configure account information 28 | 29 | Every sample in the demo requires some basic credentials from your Twilio account. Configure these first. 30 | 31 | | Config Value | Description | 32 | | :------------- |:------------- | 33 | `TWILIO_ACCOUNT_SID` | Your primary Twilio account identifier - find this [in the console here](https://www.twilio.com/console). 34 | `TWILIO_API_KEY` | Used to authenticate - [generate one here](https://www.twilio.com/console/dev-tools/api-keys). 35 | `TWILIO_API_SECRET` | Used to authenticate - [just like the above, you'll get one here](https://www.twilio.com/console/dev-tools/api-keys). 36 | 37 | #### A Note on API Keys 38 | 39 | When you generate an API key pair at the URLs above, your API Secret will only be shown once - 40 | make sure to save this information in a secure location, or possibly your `~/.bash_profile`. 41 | 42 | ### Configure product-specific settings 43 | 44 | Depending on which demos you'd like to run, you may need to configure a few more values in your `.env` file. 45 | 46 | #### Configuring Twilio Sync 47 | 48 | Twilio Sync works out of the box, using default settings per account. Once you have your API keys configured, run the application (see below) and [open a browser](http://localhost:5000/sync)! 49 | 50 | #### Configuring Twilio Chat 51 | 52 | In addition to the above, you'll need to [generate a Chat Service](https://www.twilio.com/console/chat/services) in the Twilio Console. Put the result in your `.env` file. 53 | 54 | | Config Value | Where to get one. | 55 | | :------------- |:------------- | 56 | `TWILIO_CHAT_SERVICE_SID` | Generate one in the [Twilio Chat console](https://www.twilio.com/console/chat/services) 57 | 58 | With this in place, run the application (see below) and [open a browser](http://localhost:5000/chat)! 59 | 60 | #### Configuring Twilio Notify 61 | 62 | You will need to create a Notify Service and add at least one credential on the [Mobile Push Credential screen](https://www.twilio.com/console/notify/credentials) (such as Apple Push Notification Service or Firebase Cloud Messaging for Android) to send notifications using Notify. 63 | 64 | | Config Value | Where to get one. | 65 | | :------------- |:------------- | 66 | `TWILIO_NOTIFICATION_SERVICE_SID` | Generate one in the [Notify Console](https://www.twilio.com/console/notify/services) and put this in your `.env` file. 67 | A Push Credential | Generate one with Apple or Google and [configure it as a Notify credential](https://www.twilio.com/console/notify/credentials). 68 | 69 | Once you've done that, run the application (see below) and [open a browser](http://localhost:5000/notify)! 70 | 71 | ## Run the sample application 72 | 73 | This application uses the lightweight [Flask Framework](http://flask.pocoo.org/). 74 | 75 | We need to set up your Python environment. Install `virtualenv` via `pip`: 76 | 77 | ```bash 78 | pip install virtualenv 79 | ``` 80 | 81 | Next, we need to install our dependencies: 82 | 83 | ```bash 84 | virtualenv venv 85 | source venv/bin/activate 86 | pip install -r requirements.txt 87 | ``` 88 | 89 | Now we should be all set! Run the application using the `python` command. 90 | 91 | ```bash 92 | python app.py 93 | ``` 94 | 95 | Your application should now be running at [http://localhost:5000](http://localhost:5000). When you're finished, deactivate your virtual environment using `deactivate`. 96 | 97 | ![Home Screen](https://cloud.githubusercontent.com/assets/809856/26252870/0bfd80ac-3c77-11e7-9252-2b19dff5d784.png) 98 | 99 | ## Running the SDK Starter Kit with ngrok 100 | 101 | If you are going to connect to this SDK Starter Kit with a mobile app (and you should try it out!), your phone won't be able to access localhost directly. You'll need to create a publicly accessible URL using a tool like [ngrok](https://ngrok.com/) to send HTTP/HTTPS traffic to a server running on your localhost. Use HTTPS to make web connections that retrieve a Twilio access token. 102 | 103 | ```bash 104 | ngrok http 5000 105 | ``` 106 | 107 | ## License 108 | MIT 109 | -------------------------------------------------------------------------------- /app.py: -------------------------------------------------------------------------------- 1 | import os 2 | from flask import Flask, jsonify, request 3 | from faker import Faker 4 | from twilio.rest import Client 5 | from twilio.jwt.access_token import AccessToken 6 | from twilio.jwt.access_token.grants import ( 7 | SyncGrant, 8 | VideoGrant, 9 | ChatGrant 10 | ) 11 | from dotenv import load_dotenv 12 | from os.path import join, dirname 13 | from inflection import underscore 14 | 15 | # Convert keys to snake_case to conform with the twilio-python api definition contract 16 | def snake_case_keys(somedict): 17 | snake_case_dict = {} 18 | for key, value in somedict.items(): 19 | snake_case_dict[underscore(key)] = value 20 | return snake_case_dict 21 | 22 | app = Flask(__name__) 23 | fake = Faker() 24 | dotenv_path = join(dirname(__file__), '.env') 25 | load_dotenv(dotenv_path) 26 | 27 | @app.route('/') 28 | def index(): 29 | return app.send_static_file('index.html') 30 | 31 | @app.route('/video/') 32 | def video(): 33 | return app.send_static_file('video/index.html') 34 | 35 | @app.route('/sync/') 36 | def sync(): 37 | return app.send_static_file('sync/index.html') 38 | 39 | @app.route('/notify/') 40 | def notify(): 41 | return app.send_static_file('notify/index.html') 42 | 43 | @app.route('/chat/') 44 | def chat(): 45 | return app.send_static_file('chat/index.html') 46 | 47 | # Basic health check - check environment variables have been configured 48 | # correctly 49 | @app.route('/config') 50 | def config(): 51 | return jsonify( 52 | TWILIO_ACCOUNT_SID=os.environ['TWILIO_ACCOUNT_SID'], 53 | TWILIO_NOTIFICATION_SERVICE_SID=os.environ.get('TWILIO_NOTIFICATION_SERVICE_SID', None), 54 | TWILIO_API_KEY=os.environ['TWILIO_API_KEY'], 55 | TWILIO_API_SECRET=bool(os.environ['TWILIO_API_SECRET']), 56 | TWILIO_CHAT_SERVICE_SID=os.environ.get('TWILIO_CHAT_SERVICE_SID', None), 57 | TWILIO_SYNC_SERVICE_SID=os.environ.get('TWILIO_SYNC_SERVICE_SID', 'default'), 58 | ) 59 | 60 | @app.route('/token', methods=['GET']) 61 | def randomToken(): 62 | return generateToken(fake.user_name()) 63 | 64 | 65 | @app.route('/token', methods=['POST']) 66 | def createToken(): 67 | # Get the request json or form data 68 | content = request.get_json() or request.form 69 | # get the identity from the request, or make one up 70 | identity = content.get('identity', fake.user_name()) 71 | return generateToken(identity) 72 | 73 | @app.route('/token/', methods=['POST', 'GET']) 74 | def token(identity): 75 | return generateToken(identity) 76 | 77 | def generateToken(identity): 78 | # get credentials for environment variables 79 | account_sid = os.environ['TWILIO_ACCOUNT_SID'] 80 | api_key = os.environ['TWILIO_API_KEY'] 81 | api_secret = os.environ['TWILIO_API_SECRET'] 82 | sync_service_sid = os.environ.get('TWILIO_SYNC_SERVICE_SID', 'default') 83 | chat_service_sid = os.environ.get('TWILIO_CHAT_SERVICE_SID', None) 84 | 85 | # Create access token with credentials 86 | token = AccessToken(account_sid, api_key, api_secret, identity=identity) 87 | 88 | # Create a Sync grant and add to token 89 | if sync_service_sid: 90 | sync_grant = SyncGrant(service_sid=sync_service_sid) 91 | token.add_grant(sync_grant) 92 | 93 | # Create a Video grant and add to token 94 | video_grant = VideoGrant() 95 | token.add_grant(video_grant) 96 | 97 | # Create an Chat grant and add to token 98 | if chat_service_sid: 99 | chat_grant = ChatGrant(service_sid=chat_service_sid) 100 | token.add_grant(chat_grant) 101 | 102 | # Return token info as JSON 103 | return jsonify(identity=identity, token=token.to_jwt()) 104 | 105 | 106 | 107 | 108 | # Notify - create a device binding from a POST HTTP request 109 | @app.route('/register', methods=['POST']) 110 | def register(): 111 | # get credentials for environment variables 112 | account_sid = os.environ['TWILIO_ACCOUNT_SID'] 113 | api_key = os.environ['TWILIO_API_KEY'] 114 | api_secret = os.environ['TWILIO_API_SECRET'] 115 | service_sid = os.environ['TWILIO_NOTIFICATION_SERVICE_SID'] 116 | 117 | # Initialize the Twilio client 118 | client = Client(api_key, api_secret, account_sid) 119 | 120 | # Body content 121 | content = request.get_json() 122 | 123 | content = snake_case_keys(content) 124 | 125 | # Get a reference to the notification service 126 | service = client.notify.services(service_sid) 127 | 128 | # Create the binding 129 | binding = service.bindings.create(**content) 130 | 131 | print(binding) 132 | 133 | # Return success message 134 | return jsonify(message="Binding created!") 135 | 136 | # Notify - send a notification from a POST HTTP request 137 | @app.route('/send-notification', methods=['POST']) 138 | def send_notification(): 139 | # get credentials for environment variables 140 | account_sid = os.environ['TWILIO_ACCOUNT_SID'] 141 | api_key = os.environ['TWILIO_API_KEY'] 142 | api_secret = os.environ['TWILIO_API_SECRET'] 143 | service_sid = os.environ['TWILIO_NOTIFICATION_SERVICE_SID'] 144 | 145 | # Initialize the Twilio client 146 | client = Client(api_key, api_secret, account_sid) 147 | 148 | service = client.notify.services(service_sid) 149 | 150 | # Get the request json or form data 151 | content = request.get_json() if request.get_json() else request.form 152 | 153 | content = snake_case_keys(content) 154 | 155 | # Create a notification with the given form data 156 | notification = service.notifications.create(**content) 157 | 158 | return jsonify(message="Notification created!") 159 | 160 | @app.route('/') 161 | def static_file(path): 162 | return app.send_static_file(path) 163 | 164 | # Ensure that the Sync Default Service is provisioned 165 | def provision_sync_default_service(): 166 | client = Client(os.environ['TWILIO_API_KEY'], os.environ['TWILIO_API_SECRET'], os.environ['TWILIO_ACCOUNT_SID']) 167 | client.sync.services('default').fetch() 168 | 169 | if __name__ == '__main__': 170 | provision_sync_default_service() 171 | app.run(debug=os.environ['DEBUG'], host='0.0.0.0') 172 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | Flask==2.0.2 2 | Faker==3.0.1 3 | twilio==6.48.0 4 | python-dotenv==0.15.0 5 | inflection==0.3.1 6 | -------------------------------------------------------------------------------- /static/chat/index.css: -------------------------------------------------------------------------------- 1 | * { 2 | box-sizing:border-box; 3 | } 4 | 5 | html, body { 6 | padding:0; 7 | margin:0; 8 | height:100%; 9 | width:100%; 10 | color:#dedede; 11 | background-color: #849091; 12 | font-family: 'Helvetica Neue', Helvetica, sans-serif; 13 | } 14 | 15 | header { 16 | width:100%; 17 | position:absolute; 18 | text-align:center; 19 | bottom:20px; 20 | } 21 | 22 | header a, header a:visited { 23 | font-size:18px; 24 | color:#dedede; 25 | text-decoration:none; 26 | } 27 | 28 | header a:hover { 29 | text-decoration:underline; 30 | } 31 | 32 | section { 33 | height:70%; 34 | background-color:#2B2B2A; 35 | } 36 | 37 | section input { 38 | display:block; 39 | height:52px; 40 | width:800px; 41 | margin:10px auto; 42 | outline:none; 43 | background-color:transparent; 44 | border:none; 45 | border-bottom:1px solid #2B2B2A; 46 | padding:0; 47 | font-size:42px; 48 | color:#eee; 49 | } 50 | 51 | #messages { 52 | background-color:#232323; 53 | padding:10px; 54 | height:100%; 55 | width:800px; 56 | margin:0 auto; 57 | overflow-y:auto; 58 | } 59 | 60 | #messages p { 61 | margin:5px 0; 62 | padding:0; 63 | } 64 | 65 | .info { 66 | margin:5px 0; 67 | font-style:italic; 68 | } 69 | 70 | .message-container { 71 | margin:5px 0; 72 | color:#fff; 73 | } 74 | 75 | .message-container .username { 76 | display:inline-block; 77 | margin-right:5px; 78 | font-weight:bold; 79 | color:#849091; 80 | } 81 | 82 | .me, .username.me { 83 | font-weight:bold; 84 | color:cyan; 85 | } 86 | 87 | .message-container .username.me { 88 | display:inline-block; 89 | margin-right:5px; 90 | } -------------------------------------------------------------------------------- /static/chat/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Twilio Chat Quickstart 5 | 6 | 7 | 8 | 9 | 10 |
11 | Read the getting started guide 13 | 14 | 15 |
16 | 17 |
18 |
19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /static/chat/index.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | // Get handle to the chat div 3 | var $chatWindow = $('#messages'); 4 | 5 | // Our interface to the Chat service 6 | var chatClient; 7 | 8 | // A handle to the "general" chat channel - the one and only channel we 9 | // will have in this sample app 10 | var generalChannel; 11 | 12 | // The server will assign the client a random username - store that value 13 | // here 14 | var username; 15 | 16 | // Helper function to print info messages to the chat window 17 | function print(infoMessage, asHtml) { 18 | var $msg = $('
'); 19 | if (asHtml) { 20 | $msg.html(infoMessage); 21 | } else { 22 | $msg.text(infoMessage); 23 | } 24 | $chatWindow.append($msg); 25 | } 26 | 27 | // Helper function to print chat message to the chat window 28 | function printMessage(fromUser, message) { 29 | var $user = $('').text(fromUser + ':'); 30 | if (fromUser === username) { 31 | $user.addClass('me'); 32 | } 33 | var $message = $('').text(message); 34 | var $container = $('
'); 35 | $container.append($user).append($message); 36 | $chatWindow.append($container); 37 | $chatWindow.scrollTop($chatWindow[0].scrollHeight); 38 | } 39 | 40 | // Alert the user they have been assigned a random username 41 | print('Logging in...'); 42 | 43 | // Get an access token for the current user, passing a username (identity) 44 | $.getJSON('/token', function(data) { 45 | 46 | 47 | // Initialize the Chat client 48 | Twilio.Chat.Client.create(data.token).then(client => { 49 | console.log('Created chat client'); 50 | chatClient = client; 51 | chatClient.getSubscribedChannels().then(createOrJoinGeneralChannel); 52 | 53 | // when the access token is about to expire, refresh it 54 | chatClient.on('tokenAboutToExpire', function() { 55 | refreshToken(username); 56 | }); 57 | 58 | // if the access token already expired, refresh it 59 | chatClient.on('tokenExpired', function() { 60 | refreshToken(username); 61 | }); 62 | 63 | // Alert the user they have been assigned a random username 64 | username = data.identity; 65 | print('You have been assigned a random username of: ' 66 | + '' + username + '', true); 67 | 68 | }).catch(error => { 69 | console.error(error); 70 | print('There was an error creating the chat client:
' + error, true); 71 | print('Please check your .env file.', false); 72 | }); 73 | }); 74 | 75 | function refreshToken(identity) { 76 | console.log('Token about to expire'); 77 | // Make a secure request to your backend to retrieve a refreshed access token. 78 | // Use an authentication mechanism to prevent token exposure to 3rd parties. 79 | $.getJSON('/token/' + identity, function(data) { 80 | console.log('updated token for chat client'); 81 | chatClient.updateToken(data.token); 82 | }); 83 | } 84 | 85 | function createOrJoinGeneralChannel() { 86 | // Get the general chat channel, which is where all the messages are 87 | // sent in this simple application 88 | print('Attempting to join "general" chat channel...'); 89 | chatClient.getChannelByUniqueName('general') 90 | .then(function(channel) { 91 | generalChannel = channel; 92 | console.log('Found general channel:'); 93 | console.log(generalChannel); 94 | setupChannel(); 95 | }).catch(function() { 96 | // If it doesn't exist, let's create it 97 | console.log('Creating general channel'); 98 | chatClient.createChannel({ 99 | uniqueName: 'general', 100 | friendlyName: 'General Chat Channel' 101 | }).then(function(channel) { 102 | console.log('Created general channel:'); 103 | console.log(channel); 104 | generalChannel = channel; 105 | setupChannel(); 106 | }).catch(function(channel) { 107 | console.log('Channel could not be created:'); 108 | console.log(channel); 109 | }); 110 | }); 111 | } 112 | 113 | // Set up channel after it has been found 114 | function setupChannel() { 115 | // Join the general channel 116 | generalChannel.join().then(function(channel) { 117 | print('Joined channel as ' 118 | + '' + username + '.', true); 119 | }); 120 | 121 | // Listen for new messages sent to the channel 122 | generalChannel.on('messageAdded', function(message) { 123 | printMessage(message.author, message.body); 124 | }); 125 | } 126 | 127 | // Send a new message to the general channel 128 | var $input = $('#chat-input'); 129 | $input.on('keydown', function(e) { 130 | 131 | if (e.keyCode == 13) { 132 | if (generalChannel === undefined) { 133 | print('The Chat Service is not configured. Please check your .env file.', false); 134 | return; 135 | } 136 | generalChannel.sendMessage($input.val()) 137 | $input.val(''); 138 | } 139 | }); 140 | }); 141 | -------------------------------------------------------------------------------- /static/config-check.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | $.get('/config', function(response) { 3 | Object.keys(fields).forEach(configureField(fields, response)); 4 | Object.keys(buttons).forEach(configureButton(buttons, response)); 5 | }); 6 | 7 | // Button Ids' and Config Keys 8 | var buttons = { 9 | videoDemoButton: 'TwilioApiSecret', 10 | chatDemoButton: 'TwilioChatServiceSid', 11 | syncDemoButton: 'TwilioSyncServiceSid', 12 | notifyDemoButton: 'TwilioNotificationServiceSid' 13 | }; 14 | 15 | // Field Ids' and Masked Flag 16 | var fields = { 17 | twilioAccountSid: false, 18 | twilioApiKey: false, 19 | twilioApiSecret: true, 20 | twilioNotificationServiceSid: false, 21 | twilioChatServiceSid: false, 22 | twilioSyncServiceSid: false 23 | }; 24 | 25 | var configureField = function(fields, response) { 26 | var htmlContent = 'Not configured in .env'; 27 | var cssClass = 'unset'; 28 | return function(fieldId) { 29 | var configKey = strToConfig(fieldId); 30 | var isMasked = fields[fieldId]; 31 | if (!!response[configKey]) { 32 | htmlContent = isMasked ? 'Configured properly' : response[configKey]; 33 | cssClass = 'set'; 34 | } 35 | $('#' + fieldId).html(htmlContent).addClass(cssClass); 36 | }; 37 | }; 38 | 39 | var configureButton = function(buttons, response) { 40 | var hasBasicConfig = !!response.TWILIO_ACCOUNT_SID && 41 | !!response.TWILIO_API_KEY && 42 | !!response.TWILIO_API_SECRET; 43 | return function(buttonId) { 44 | var configKey = strToConfig(buttons[buttonId]); 45 | var cssClass = hasBasicConfig && !!response[configKey] 46 | ? 'btn-success' 47 | : 'btn-danger'; 48 | $('#' + buttonId).addClass(cssClass); 49 | }; 50 | }; 51 | 52 | var strToConfig = function(string) { 53 | return string 54 | .split(/(?=[A-Z])/) 55 | .map(function(e) { return e.toUpperCase(); }) 56 | .join('_'); 57 | } 58 | }); 59 | -------------------------------------------------------------------------------- /static/index.css: -------------------------------------------------------------------------------- 1 | .config-value.set { 2 | color:seagreen; 3 | } 4 | 5 | .config-value.unset { 6 | color:darkred; 7 | } -------------------------------------------------------------------------------- /static/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Twilio Server Starter Kit 5 | 6 | 9 | 10 | 11 | 12 | 13 |
14 |

Twilio Server Starter Kit Environment Setup

15 | 16 |

Account Information

17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 |
TWILIO_ACCOUNT_SID
TWILIO_API_KEY
TWILIO_API_SECRET
31 | 32 |

Products

33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 |
NotifyTWILIO_NOTIFICATION_SERVICE_SID
ChatTWILIO_CHAT_SERVICE_SID
SyncTWILIO_SYNC_SERVICE_SID
50 | 51 |

Demos

52 | Video 53 | Sync 54 | Notify 55 | Chat 56 |
57 | 58 | 59 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /static/notify/facebook_messenger.html: -------------------------------------------------------------------------------- 1 | 2 | 27 |
32 |
33 | 34 | -------------------------------------------------------------------------------- /static/notify/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Hello App! - Notify Quickstart 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | Read the Twilio Notify guide 13 | 14 |
15 | 16 |
17 |

Send Notification to Identity

18 | 19 | 20 |

21 | 22 | 23 |

Welcome to Notify!
24 | 25 |

After you set up a notification binding, go ahead and send a notification to that identity!

26 |
27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /static/notify/notify.css: -------------------------------------------------------------------------------- 1 | * { 2 | box-sizing:border-box; 3 | } 4 | 5 | html, body { 6 | padding:0; 7 | margin:0; 8 | height:100%; 9 | width:100%; 10 | color:#dedede; 11 | background-color: #849091; 12 | font-family: 'Helvetica Neue', Helvetica, sans-serif; 13 | } 14 | 15 | header { 16 | width:100%; 17 | position:absolute; 18 | text-align:center; 19 | bottom:20px; 20 | } 21 | 22 | header a, header a:visited { 23 | font-size:18px; 24 | color:#dedede; 25 | text-decoration:none; 26 | } 27 | 28 | header a:hover { 29 | text-decoration:underline; 30 | } 31 | 32 | section { 33 | background-color:#2B2B2A; 34 | text-align:center; 35 | padding:16px; 36 | } 37 | 38 | #message { 39 | padding:6px; 40 | } 41 | -------------------------------------------------------------------------------- /static/notify/notify.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | $('#sendNotificationButton').on('click', function() { 3 | $.post('/send-notification', { 4 | identity: $('#identityInput').val(), 5 | body: "Hello, world!" 6 | }, function(response) { 7 | $('#identityInput').val(''); 8 | $('#message').html(response.message); 9 | console.log(response); 10 | }); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /static/sync/index.css: -------------------------------------------------------------------------------- 1 | * { 2 | box-sizing:border-box; 3 | } 4 | 5 | html, body { 6 | padding:0; 7 | margin:0; 8 | height:100%; 9 | width:100%; 10 | color:#dedede; 11 | background-color: #849091; 12 | font-family: 'Helvetica Neue', Helvetica, sans-serif; 13 | } 14 | 15 | header { 16 | width:100%; 17 | position:absolute; 18 | text-align:center; 19 | bottom:20px; 20 | } 21 | 22 | header a, header a:visited { 23 | font-size:18px; 24 | color:#dedede; 25 | text-decoration:none; 26 | } 27 | 28 | header a:hover { 29 | text-decoration:underline; 30 | } 31 | 32 | section { 33 | background-color:#2B2B2A; 34 | text-align:center; 35 | padding:16px; 36 | } 37 | 38 | button:hover { 39 | cursor:pointer; 40 | background-color:#000; 41 | color:#fff; 42 | } 43 | 44 | #message { 45 | padding:6px; 46 | } 47 | 48 | #board { 49 | width: 33%; 50 | margin-left: auto; 51 | margin-right: auto; 52 | } 53 | 54 | #board .board-row { 55 | width: 100%; 56 | padding-bottom: 3px; 57 | } 58 | 59 | #board .board-row button { 60 | width: 30%; 61 | height: 100px; 62 | font-size: 50px; 63 | } -------------------------------------------------------------------------------- /static/sync/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Tic-Tac-Twilio - Sync Quickstart 5 | 6 | 7 | 8 | 9 | 10 |
11 | 13 | Read the getting started guide 14 | 15 | 16 |
17 | 18 |
19 |

Tic-Tac-Twilio

20 | 21 |
22 |
23 | 24 | 25 | 26 |
27 |
28 | 29 | 30 | 31 |
32 |
33 | 34 | 35 | 36 |
37 |
38 | 39 |
40 | Welcome! Initializing Sync... 41 |
42 | 43 |

Open this page in a few tabs to test!

44 |
45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /static/sync/index.js: -------------------------------------------------------------------------------- 1 | $(function () { 2 | //We'll use message to tell the user what's happening 3 | var $message = $('#message'); 4 | 5 | //Get handle to the game board buttons 6 | var $buttons = $('#board .board-row button'); 7 | 8 | //Our interface to the Sync service 9 | var syncClient; 10 | 11 | // Every browser Sync client relies on FPA tokens to authenticate and authorize it 12 | // for access to your Sync data. 13 | // 14 | // In this quickstart, we're using our own token generator. You can generate a token 15 | // in any backend language that Twilio supports, or generate a Twilio Function so 16 | // Twilio can host it for you. See the docs for more details. 17 | // 18 | $.getJSON('/token', function (tokenResponse) { 19 | 20 | // Once we have the token, we can initialize the Sync client and start subscribing 21 | // to data. The client will initialize asynchronously while we load the rest of 22 | // the user interface. 23 | // 24 | syncClient = new Twilio.Sync.Client(tokenResponse.token, { logLevel: 'info' }); 25 | syncClient.on('connectionStateChanged', function(state) { 26 | if (state != 'connected') { 27 | $message.html('Sync is not live (websocket connection ' + state + ')…'); 28 | } else { 29 | // Now that we're connected, lets light up our board and play! 30 | $buttons.attr('disabled', false); 31 | $message.html('Sync is live!'); 32 | } 33 | }); 34 | 35 | // Let's pop a message on the screen to show that Sync is working 36 | $message.html('Loading board data…'); 37 | 38 | // Our game state is stored in a Sync document. Here, we'll attach to that document 39 | // (or create it, if it doesn't exist) and connect the necessary event handlers. 40 | // 41 | syncClient.document('SyncGame').then(function(syncDoc) { 42 | var data = syncDoc.value; 43 | if (data.board) { 44 | updateUserInterface(data); 45 | } 46 | 47 | // Any time the board changes, we want to show the new state. The 'updated' 48 | // event is for this. 49 | syncDoc.on('updated', function(event) { 50 | console.debug("Board was updated", event.isLocal? "locally." : "by the other guy."); 51 | updateUserInterface(event.value); 52 | }); 53 | 54 | // Let's make our buttons control the game state in Sync… 55 | $buttons.on('click', function (e) { 56 | // Toggle the value: X, O, or empty 57 | toggleCellValue($(e.target)); 58 | 59 | // Send updated document to Sync. This will trigger "updated" events for all players. 60 | var data = readGameBoardFromUserInterface(); 61 | syncDoc.set(data); 62 | }); 63 | }); 64 | 65 | }); 66 | 67 | //Toggle the value: X, O, or empty (  for UI) 68 | function toggleCellValue($cell) { 69 | var cellValue = $cell.html(); 70 | 71 | if (cellValue === 'X') { 72 | $cell.html('O'); 73 | } else if (cellValue === 'O') { 74 | $cell.html(' '); 75 | } else { 76 | $cell.html('X'); 77 | } 78 | } 79 | 80 | //Read the state of the UI and create a new document 81 | function readGameBoardFromUserInterface() { 82 | var board = [ 83 | ['', '', ''], 84 | ['', '', ''], 85 | ['', '', ''] 86 | ]; 87 | 88 | for (var row = 0; row < 3; row++) { 89 | for (var col = 0; col < 3; col++) { 90 | var selector = '[data-row="' + row + '"]' + 91 | '[data-col="' + col + '"]'; 92 | board[row][col] = $(selector).html().replace(' ', ''); 93 | } 94 | } 95 | 96 | return {board: board}; 97 | } 98 | 99 | //Update the buttons on the board to match our document 100 | function updateUserInterface(data) { 101 | for (var row = 0; row < 3; row++) { 102 | for (var col = 0; col < 3; col++) { 103 | var this_cell = '[data-row="' + row + '"]' + '[data-col="' + col + '"]'; 104 | var cellValue = data.board[row][col]; 105 | $(this_cell).html(cellValue === '' ? ' ' : cellValue); 106 | } 107 | } 108 | } 109 | }); 110 | -------------------------------------------------------------------------------- /static/video/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Twilio Video - Video Quickstart 5 | 6 | 7 | 8 |
9 |
10 |
11 |

Hello Beautiful

12 |
13 | 14 |
15 | 16 |
17 |

Room Name:

18 | 19 | 20 | 21 |
22 | 23 |
24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /static/video/quickstart.js: -------------------------------------------------------------------------------- 1 | var activeRoom; 2 | var previewTracks; 3 | var identity; 4 | var roomName; 5 | 6 | function attachTracks(tracks, container) { 7 | tracks.forEach(function(track) { 8 | container.appendChild(track.attach()); 9 | }); 10 | } 11 | 12 | function attachParticipantTracks(participant, container) { 13 | var tracks = Array.from(participant.tracks.values()); 14 | attachTracks(tracks, container); 15 | } 16 | 17 | function detachTracks(tracks) { 18 | tracks.forEach(function(track) { 19 | track.detach().forEach(function(detachedElement) { 20 | detachedElement.remove(); 21 | }); 22 | }); 23 | } 24 | 25 | function detachParticipantTracks(participant) { 26 | var tracks = Array.from(participant.tracks.values()); 27 | detachTracks(tracks); 28 | } 29 | 30 | // Check for WebRTC 31 | if (!navigator.webkitGetUserMedia && !navigator.mozGetUserMedia) { 32 | alert('WebRTC is not available in your browser.'); 33 | } 34 | 35 | // When we are about to transition away from this page, disconnect 36 | // from the room, if joined. 37 | window.addEventListener('beforeunload', leaveRoomIfJoined); 38 | 39 | $.getJSON('/token', function(data) { 40 | identity = data.identity; 41 | 42 | document.getElementById('room-controls').style.display = 'block'; 43 | 44 | // Bind button to join room 45 | document.getElementById('button-join').onclick = function () { 46 | roomName = document.getElementById('room-name').value; 47 | if (roomName) { 48 | log("Joining room '" + roomName + "'..."); 49 | 50 | var connectOptions = { name: roomName, logLevel: 'debug' }; 51 | if (previewTracks) { 52 | connectOptions.tracks = previewTracks; 53 | } 54 | 55 | Twilio.Video.connect(data.token, connectOptions).then(roomJoined, function(error) { 56 | log('Could not connect to Twilio: ' + error.message); 57 | }); 58 | } else { 59 | alert('Please enter a room name.'); 60 | } 61 | }; 62 | 63 | // Bind button to leave room 64 | document.getElementById('button-leave').onclick = function () { 65 | log('Leaving room...'); 66 | activeRoom.disconnect(); 67 | }; 68 | }); 69 | 70 | // Successfully connected! 71 | function roomJoined(room) { 72 | activeRoom = room; 73 | 74 | log("Joined as '" + identity + "'"); 75 | document.getElementById('button-join').style.display = 'none'; 76 | document.getElementById('button-leave').style.display = 'inline'; 77 | 78 | // Draw local video, if not already previewing 79 | var previewContainer = document.getElementById('local-media'); 80 | if (!previewContainer.querySelector('video')) { 81 | attachParticipantTracks(room.localParticipant, previewContainer); 82 | } 83 | 84 | room.participants.forEach(function(participant) { 85 | log("Already in Room: '" + participant.identity + "'"); 86 | var previewContainer = document.getElementById('remote-media'); 87 | attachParticipantTracks(participant, previewContainer); 88 | }); 89 | 90 | // When a participant joins, draw their video on screen 91 | room.on('participantConnected', function(participant) { 92 | log("Joining: '" + participant.identity + "'"); 93 | }); 94 | 95 | room.on('trackAdded', function(track, participant) { 96 | log(participant.identity + " added track: " + track.kind); 97 | var previewContainer = document.getElementById('remote-media'); 98 | attachTracks([track], previewContainer); 99 | }); 100 | 101 | room.on('trackRemoved', function(track, participant) { 102 | log(participant.identity + " removed track: " + track.kind); 103 | detachTracks([track]); 104 | }); 105 | 106 | // When a participant disconnects, note in log 107 | room.on('participantDisconnected', function(participant) { 108 | log("Participant '" + participant.identity + "' left the room"); 109 | detachParticipantTracks(participant); 110 | }); 111 | 112 | // When we are disconnected, stop capturing local video 113 | // Also remove media for all remote participants 114 | room.on('disconnected', function() { 115 | log('Left'); 116 | detachParticipantTracks(room.localParticipant); 117 | room.participants.forEach(detachParticipantTracks); 118 | activeRoom = null; 119 | document.getElementById('button-join').style.display = 'inline'; 120 | document.getElementById('button-leave').style.display = 'none'; 121 | }); 122 | } 123 | 124 | // Local video preview 125 | document.getElementById('button-preview').onclick = function() { 126 | var localTracksPromise = previewTracks 127 | ? Promise.resolve(previewTracks) 128 | : Twilio.Video.createLocalTracks(); 129 | 130 | localTracksPromise.then(function(tracks) { 131 | previewTracks = tracks; 132 | var previewContainer = document.getElementById('local-media'); 133 | if (!previewContainer.querySelector('video')) { 134 | attachTracks(tracks, previewContainer); 135 | } 136 | }, function(error) { 137 | console.error('Unable to access local media', error); 138 | log('Unable to access Camera and Microphone'); 139 | }); 140 | }; 141 | 142 | // Activity log 143 | function log(message) { 144 | var logDiv = document.getElementById('log'); 145 | logDiv.innerHTML += '

> ' + message + '

'; 146 | logDiv.scrollTop = logDiv.scrollHeight; 147 | } 148 | 149 | function leaveRoomIfJoined() { 150 | if (activeRoom) { 151 | activeRoom.disconnect(); 152 | } 153 | } 154 | -------------------------------------------------------------------------------- /static/video/site.css: -------------------------------------------------------------------------------- 1 | @import url(https://fonts.googleapis.com/css?family=Share+Tech+Mono); 2 | 3 | body, 4 | p { 5 | padding: 0; 6 | margin: 0; 7 | } 8 | 9 | body { 10 | background: #272726; 11 | } 12 | 13 | div#remote-media { 14 | height: 43%; 15 | width: 100%; 16 | background-color: #fff; 17 | text-align: center; 18 | margin: auto; 19 | } 20 | 21 | div#remote-media video { 22 | border: 1px solid #272726; 23 | margin: 3em 2em; 24 | height: 70%; 25 | max-width: 27% !important; 26 | background-color: #272726; 27 | background-repeat: no-repeat; 28 | } 29 | 30 | div#controls { 31 | padding: 3em; 32 | max-width: 1200px; 33 | margin: 0 auto; 34 | } 35 | 36 | div#controls div { 37 | float: left; 38 | } 39 | 40 | div#controls div#room-controls, 41 | div#controls div#preview { 42 | width: 16em; 43 | margin: 0 1.5em; 44 | text-align: center; 45 | } 46 | 47 | div#controls p.instructions { 48 | text-align: left; 49 | margin-bottom: 1em; 50 | font-family: Helvetica-LightOblique, Helvetica, sans-serif; 51 | font-style: oblique; 52 | font-size: 1.25em; 53 | color: #777776; 54 | } 55 | 56 | div#controls button { 57 | width: 15em; 58 | height: 2.5em; 59 | margin-top: 1.75em; 60 | border-radius: 1em; 61 | font-family: "Helvetica Light", Helvetica, sans-serif; 62 | font-size: .8em; 63 | font-weight: lighter; 64 | outline: 0; 65 | } 66 | 67 | div#controls div#room-controls input { 68 | font-family: Helvetica-LightOblique, Helvetica, sans-serif; 69 | font-style: oblique; 70 | font-size: 1em; 71 | } 72 | 73 | div#controls button:active { 74 | position: relative; 75 | top: 1px; 76 | } 77 | 78 | div#controls div#preview div#local-media { 79 | width: 270px; 80 | height: 202px; 81 | border: 1px solid #cececc; 82 | box-sizing: border-box; 83 | background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+Cjxzdmcgd2lkdGg9IjgwcHgiIGhlaWdodD0iODBweCIgdmlld0JveD0iMCAwIDgwIDgwIiB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHhtbG5zOnNrZXRjaD0iaHR0cDovL3d3dy5ib2hlbWlhbmNvZGluZy5jb20vc2tldGNoL25zIj4KICAgIDwhLS0gR2VuZXJhdG9yOiBTa2V0Y2ggMy4zLjEgKDEyMDAyKSAtIGh0dHA6Ly93d3cuYm9oZW1pYW5jb2RpbmcuY29tL3NrZXRjaCAtLT4KICAgIDx0aXRsZT5GaWxsIDUxICsgRmlsbCA1MjwvdGl0bGU+CiAgICA8ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz4KICAgIDxkZWZzPjwvZGVmcz4KICAgIDxnIGlkPSJQYWdlLTEiIHN0cm9rZT0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIHNrZXRjaDp0eXBlPSJNU1BhZ2UiPgogICAgICAgIDxnIGlkPSJjdW1tYWNrIiBza2V0Y2g6dHlwZT0iTVNMYXllckdyb3VwIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgtMTU5LjAwMDAwMCwgLTE3NDYuMDAwMDAwKSIgZmlsbD0iI0ZGRkZGRiI+CiAgICAgICAgICAgIDxnIGlkPSJGaWxsLTUxLSstRmlsbC01MiIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMTU5LjAwMDAwMCwgMTc0Ni4wMDAwMDApIiBza2V0Y2g6dHlwZT0iTVNTaGFwZUdyb3VwIj4KICAgICAgICAgICAgICAgIDxwYXRoIGQ9Ik0zOS42ODYsMC43MyBDMTcuODUsMC43MyAwLjA4NSwxOC41IDAuMDg1LDQwLjMzIEMwLjA4NSw2Mi4xNyAxNy44NSw3OS45MyAzOS42ODYsNzkuOTMgQzYxLjUyMiw3OS45MyA3OS4yODcsNjIuMTcgNzkuMjg3LDQwLjMzIEM3OS4yODcsMTguNSA2MS41MjIsMC43MyAzOS42ODYsMC43MyBMMzkuNjg2LDAuNzMgWiBNMzkuNjg2LDEuNzMgQzYxLjAwNSwxLjczIDc4LjI4NywxOS4wMiA3OC4yODcsNDAuMzMgQzc4LjI4Nyw2MS42NSA2MS4wMDUsNzguOTMgMzkuNjg2LDc4LjkzIEMxOC4zNjcsNzguOTMgMS4wODUsNjEuNjUgMS4wODUsNDAuMzMgQzEuMDg1LDE5LjAyIDE4LjM2NywxLjczIDM5LjY4NiwxLjczIEwzOS42ODYsMS43MyBaIiBpZD0iRmlsbC01MSI+PC9wYXRoPgogICAgICAgICAgICAgICAgPHBhdGggZD0iTTQ3Ljk2LDUzLjMzNSBMNDcuOTYsNTIuODM1IEwyMC4wOTMsNTIuODM1IEwyMC4wOTMsMjcuODI1IEw0Ny40NiwyNy44MjUgTDQ3LjQ2LDM4LjI1NSBMNTkuMjc5LDMwLjgwNSBMNTkuMjc5LDQ5Ljg1NSBMNDcuNDYsNDIuNDA1IEw0Ny40Niw1My4zMzUgTDQ3Ljk2LDUzLjMzNSBMNDcuOTYsNTIuODM1IEw0Ny45Niw1My4zMzUgTDQ4LjQ2LDUzLjMzNSBMNDguNDYsNDQuMjE1IEw2MC4yNzksNTEuNjY1IEw2MC4yNzksMjguOTk1IEw0OC40NiwzNi40NDUgTDQ4LjQ2LDI2LjgyNSBMMTkuMDkzLDI2LjgyNSBMMTkuMDkzLDUzLjgzNSBMNDguNDYsNTMuODM1IEw0OC40Niw1My4zMzUgTDQ3Ljk2LDUzLjMzNSIgaWQ9IkZpbGwtNTIiPjwvcGF0aD4KICAgICAgICAgICAgPC9nPgogICAgICAgIDwvZz4KICAgIDwvZz4KPC9zdmc+); 84 | background-position: center; 85 | background-repeat: no-repeat; 86 | margin: 0 auto; 87 | } 88 | 89 | div#controls div#preview div#local-media video { 90 | max-width: 100%; 91 | max-height: 100%; 92 | border: none; 93 | } 94 | 95 | div#controls div#preview button#button-preview { 96 | background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+Cjxzdmcgd2lkdGg9IjE3cHgiIGhlaWdodD0iMTJweCIgdmlld0JveD0iMCAwIDE3IDEyIiB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHhtbG5zOnNrZXRjaD0iaHR0cDovL3d3dy5ib2hlbWlhbmNvZGluZy5jb20vc2tldGNoL25zIj4KICAgIDwhLS0gR2VuZXJhdG9yOiBTa2V0Y2ggMy4zLjEgKDEyMDAyKSAtIGh0dHA6Ly93d3cuYm9oZW1pYW5jb2RpbmcuY29tL3NrZXRjaCAtLT4KICAgIDx0aXRsZT5GaWxsIDM0PC90aXRsZT4KICAgIDxkZXNjPkNyZWF0ZWQgd2l0aCBTa2V0Y2guPC9kZXNjPgogICAgPGRlZnM+PC9kZWZzPgogICAgPGcgaWQ9IlBhZ2UtMSIgc3Ryb2tlPSJub25lIiBzdHJva2Utd2lkdGg9IjEiIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCIgc2tldGNoOnR5cGU9Ik1TUGFnZSI+CiAgICAgICAgPGcgaWQ9ImN1bW1hY2siIHNrZXRjaDp0eXBlPSJNU0xheWVyR3JvdXAiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0xMjUuMDAwMDAwLCAtMTkwOS4wMDAwMDApIiBmaWxsPSIjMEEwQjA5Ij4KICAgICAgICAgICAgPHBhdGggZD0iTTEzNi40NzEsMTkxOS44NyBMMTM2LjQ3MSwxOTE5LjYyIEwxMjUuNzY3LDE5MTkuNjIgTDEyNS43NjcsMTkxMC4wOCBMMTM2LjIyMSwxOTEwLjA4IEwxMzYuMjIxLDE5MTQuMTUgTDE0MC43ODUsMTkxMS4yNyBMMTQwLjc4NSwxOTE4LjQyIEwxMzYuMjIxLDE5MTUuNTUgTDEzNi4yMjEsMTkxOS44NyBMMTM2LjQ3MSwxOTE5Ljg3IEwxMzYuNDcxLDE5MTkuNjIgTDEzNi40NzEsMTkxOS44NyBMMTM2LjcyMSwxOTE5Ljg3IEwxMzYuNzIxLDE5MTYuNDUgTDE0MS4yODUsMTkxOS4zMyBMMTQxLjI4NSwxOTEwLjM3IEwxMzYuNzIxLDE5MTMuMjQgTDEzNi43MjEsMTkwOS41OCBMMTI1LjI2NywxOTA5LjU4IEwxMjUuMjY3LDE5MjAuMTIgTDEzNi43MjEsMTkyMC4xMiBMMTM2LjcyMSwxOTE5Ljg3IEwxMzYuNDcxLDE5MTkuODciIGlkPSJGaWxsLTM0IiBza2V0Y2g6dHlwZT0iTVNTaGFwZUdyb3VwIj48L3BhdGg+CiAgICAgICAgPC9nPgogICAgPC9nPgo8L3N2Zz4=)1em center no-repeat #fff; 97 | border: none; 98 | padding-left: 1.5em; 99 | } 100 | 101 | div#controls div#log { 102 | border: 1px solid #686865; 103 | } 104 | 105 | div#controls div#room-controls { 106 | display: none; 107 | } 108 | 109 | div#controls div#room-controls input { 110 | width: 100%; 111 | height: 2.5em; 112 | padding: .5em; 113 | display: block; 114 | } 115 | 116 | div#controls div#room-controls button { 117 | color: #fff; 118 | background: 0 0; 119 | border: 1px solid #686865; 120 | } 121 | 122 | div#controls div#room-controls button#button-leave { 123 | display: none; 124 | } 125 | 126 | div#controls div#log { 127 | width: 35%; 128 | height: 9.5em; 129 | margin-top: 2.75em; 130 | text-align: left; 131 | padding: 1.5em; 132 | float: right; 133 | overflow-y: scroll; 134 | } 135 | 136 | div#controls div#log p { 137 | color: #686865; 138 | font-family: 'Share Tech Mono', 'Courier New', Courier, fixed-width; 139 | font-size: 1.25em; 140 | line-height: 1.25em; 141 | margin-left: 1em; 142 | text-indent: -1.25em; 143 | width: 90%; 144 | } 145 | --------------------------------------------------------------------------------