Skip to main content

Updating the Look of Video Conferences

Overview

We're going to be changing the look of our Video Conferences using Video API endpoints.
The Update a Video Conference endpoint allows us to update the look of any Video Conference by passing it Hex color codes.

Full code example: Updating the Look of Video Confereces
import requests
from requests.auth import HTTPBasicAuth

# TODO: Update these variables with your own
spaceURL = 'YOURSPACE.signalwire.com'
projectID = "XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
authToken = "PTxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

AUTH = HTTPBasicAuth(
projectID,
authToken
)

class LayoutColors:
def __init__(self, primary, background, foreground, success, negative):
self.primary = primary
self.background = background
self.foreground = foreground
self.success = success
self.negative = negative

# TODO: Pick the colors to use
LIGHT_COLORS = LayoutColors(
"#FFFFFF", # Primary - Used for CTA buttons and selected items.
"#FFFFFF", # Background - Main background color.
"#FFFFFF", # Foreground - Main foreground color.
"#FFFFFF", # Success - Used for success indications.
"#FFFFFF" # Negative - Used for error indications.
)

DARK_COLORS = LayoutColors(
"#FFFFFF", # Primary - Used for CTA buttons and selected items.
"#FFFFFF", # Background - Main background color.
"#FFFFFF", # Foreground - Main foreground color.
"#FFFFFF", # Success - Used for success indications.
"#FFFFFF" # Negative - Used for error indications.
)

# Function to make the request to the url endpoint
def getData(url):
payload = {}
headers = {}

response = requests.request(
"GET",
url,
headers = headers,
data = payload,
auth = HTTPBasicAuth(
projectID,
authToken)).json()

allData = response['data']

while "next" in response['links'].keys():
response = requests.get(
response['links']['next'],
auth=HTTPBasicAuth(projectID, authToken)).json()

allData.extend(response['data'])

return allData

VIDEO_CONFERENCES_URL = f"https://{spaceURL}/api/video/conferences"

# Get all Video Conferences
videoConferences = getData(VIDEO_CONFERENCES_URL)

# Loop through video conferences
for conference in videoConferences:
payload = {
"light_primary": LIGHT_COLORS.primary,
"light_background": LIGHT_COLORS.background,
"light_foreground": LIGHT_COLORS.foreground,
"light_success": LIGHT_COLORS.success,
"light_negative": LIGHT_COLORS.negative,
"dark_primary": DARK_COLORS.primary,
"dark_background": DARK_COLORS.background,
"dark_foreground": DARK_COLORS.foreground,
"dark_success": DARK_COLORS.success,
"dark_negative": DARK_COLORS.negative
}

try:
response = requests.put(
f"https://{spaceURL}/api/video/conferences/{conference['id']}",
json = payload,
auth = AUTH)

print(f"{conference['display_name']} room colors updated successfully.")

except requests.exceptions.HTTPError as errh:
print("An Http Error occurred:" + repr(errh))
except requests.exceptions.ConnectionError as errc:
print("An Error Connecting to the API occurred:" + repr(errc))
except requests.exceptions.Timeout as errt:
print("A Timeout Error occurred:" + repr(errt))
except requests.exceptions.RequestException as err:
print("An Unknown Error occurred" + repr(err))

What do I need to run this code?

You will need your SignalWire API credentials, which you can find in the API tab of your SignalWire Space, as well as the requests Python library.

How to Run Snippet?

If you copy the code and save it to a file named updateVideoConferencesLook.py, for example, to run it you will need to run:

  • MacOS/Linux - python3 updateVideoConferencesLook.py
  • Windows - py updateVideoConferencesLook.py

Code Walkthrough

Load necessary libraries and set up SignalWire client variables

You will first need to define your own spaceURLprojectID, and authToken variables to be used throughout the code.

import requests
from requests.auth import HTTPBasicAuth

# TODO: Update these variables with your own
spaceURL = 'YOURSPACE.signalwire.com'
projectID = "XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
authToken = "PTxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

AUTH = HTTPBasicAuth(
projectID,
authToken
)

Prepare the colors

In this step we prepare the colors that will be used later on in the code to update the light and dark variants of the room. By default we've made it so that all of the colors are set to #FFFFFF (white), but you can get color palette ideas from Color Hunt.

class LayoutColors:
def __init__(self, primary, background, foreground, success, negative):
self.primary = primary
self.background = background
self.foreground = foreground
self.success = success
self.negative = negative

# TODO: Pick the colors to use
LIGHT_COLORS = LayoutColors(
"#FFFFFF", # Primary - Used for CTA buttons and selected items.
"#FFFFFF", # Background - Main background color.
"#FFFFFF", # Foreground - Main foreground color.
"#FFFFFF", # Success - Used for success indications.
"#FFFFFF" # Negative - Used for error indications.
)

DARK_COLORS = LayoutColors(
"#FFFFFF", # Primary - Used for CTA buttons and selected items.
"#FFFFFF", # Background - Main background color.
"#FFFFFF", # Foreground - Main foreground color.
"#FFFFFF", # Success - Used for success indications.
"#FFFFFF" # Negative - Used for error indications.
)

Get all Video Conferences

Here we create the getData function which we then use to connect to the List Video Conferences endpoint so we can get the list of Video Conferences to update.

# Function to make the request to the url endpoint
def getData(url):
payload = {}
headers = {}

response = requests.request(
"GET",
url,
headers = headers,
data = payload,
auth = HTTPBasicAuth(
projectID,
authToken)).json()

allData = response['data']

while "next" in response['links'].keys():
response = requests.get(
response['links']['next'],
auth=HTTPBasicAuth(projectID, authToken)).json()

allData.extend(response['data'])

return allData

VIDEO_CONFERENCES_URL = f"https://{spaceURL}/api/video/conferences"

# Get all Video Conferences
videoConferences = getData(VIDEO_CONFERENCES_URL)

Update each Video Conference

In the last step of our code we iterate through the list of video conferences, and update each one using the Update a Video Conference endpoint, along with the color profiles we selected.

# Loop through video conferences
for conference in videoConferences:
payload = {
"light_primary": LIGHT_COLORS.primary,
"light_background": LIGHT_COLORS.background,
"light_foreground": LIGHT_COLORS.foreground,
"light_success": LIGHT_COLORS.success,
"light_negative": LIGHT_COLORS.negative,
"dark_primary": DARK_COLORS.primary,
"dark_background": DARK_COLORS.background,
"dark_foreground": DARK_COLORS.foreground,
"dark_success": DARK_COLORS.success,
"dark_negative": DARK_COLORS.negative
}

try:
response = requests.put(
f"https://{spaceURL}/api/video/conferences/{conference['id']}",
json = payload,
auth = AUTH)

print(f"{conference['display_name']} room colors updated successfully.")

except requests.exceptions.HTTPError as errh:
print("An Http Error occurred:" + repr(errh))
except requests.exceptions.ConnectionError as errc:
print("An Error Connecting to the API occurred:" + repr(errc))
except requests.exceptions.Timeout as errt:
print("A Timeout Error occurred:" + repr(errt))
except requests.exceptions.RequestException as err:
print("An Unknown Error occurred" + repr(err))

Wrap up

Our Video Conference endpoints make it really easy to update everything about them without having to do so manually from your SignalWire Space!

Sign Up Here

If you would like to test this example out, create a SignalWire account and Space.

Please feel free to reach out to us on our Community Slack or create a Support ticket if you need guidance!