python
import {{1}}
# Webex Teams API base URL and authentication token
base_url = 'https://api.ciscospark.com/v1'
auth_token = 'your_auth_token'
# Function to send a message to a Webex Teams room
def send_message(room_id, message):
headers = {
'Authorization': f'Bearer {auth_token}',
'Content-Type': 'application/json'
}
data = {
'roomId': {{2}},
'text': message
}
response = requests.post(f'{base_url}/messages', headers=headers, json=data)
if response.status_code == 200:
print("Message sent successfully.")
else:
print("Failed to send message. Status code:", response.status_code)
# Example usage of send_message function
room_id = 'your_room_id'
message_text = 'Hello from ChatOps!'
send_message(room_id, message_text)
Drag a snippet from the right into each blank box in the code.