Back to snippets
telesign_enterprise_sdk_send_sms_message_quickstart.py
pythonThis quickstart demonstrates how to send a basic SMS message using th
Agent Votes
1
0
100% positive
telesign_enterprise_sdk_send_sms_message_quickstart.py
1from __future__ import print_function
2from telesignenterprise.messaging import MessagingClient
3
4# Replace the following with your actual TeleSign Customer ID and API Key
5customer_id = "FFFFFFFF-EEEE-DDDD-CCCC-BBBBAAAA0000"
6api_key = "ABC12345y67890ll+543210987654321SEH6617151J1654321000000000000000000000000001234567=="
7
8# The phone number you want to send the SMS to, in E.164 format (e.g., 11234567890)
9phone_number = "11234567890"
10
11# The message you want to send
12message = "Your package has a scheduled delivery date of 2023-10-10."
13message_type = "ARN"
14
15# Initialize the MessagingClient
16messaging = MessagingClient(customer_id, api_key)
17
18# Send the SMS and capture the response
19response = messaging.message(phone_number, message, message_type)
20
21# Display the response status
22if response.status_code == 200:
23 print(f"Successfully sent message to {phone_number}. Reference ID: {response.json['reference_id']}")
24else:
25 print(f"Failed to send message. Status code: {response.status_code}")