Send a message
Send a variety of messages through the Pinnacle SDK.
You can send messages using the send
method provided by the Pinnacle
class in the SDK.
Send
send(messsage: Message, phone_number: Optional[str]) -> dict[str, str]
Parameters
Message object containing the content and type of the message you want to send. See below for the types of messages you can send.
The phone number of the recipient. It should be in E.164 format (e.g., +14155552671).
If not provided, the message will be sent to the phone number associated with your account. See Get account number for more details.
Returns
Returns a dictionary containing the status of the sent message. The structure of the dictionary is as follows:
message
: Message from the server indicating the result of the send operation.
Messages
SMS/MMS Message
To send a standard SMS or MMS message, create a SMSMessage
object with the desired content and optional medial url.
SMSMessage(content: str, medialUrl: Optional[str] = None)
Parameters
The text content of the SMS or MMS message.
The URL of the media to be sent with the MMS message.
Usage
from rcs import Pinnacle, SMSMessage
pinn = Pinnacle(
api_key=YOUR_API_KEY,
webhook_url=YOUR_WEBHOOK_URL,
)
message = SMSMessage(
"Hello, this is a test SMS message!",
image_url # Optional media URL
)
pinn.send(
message,
phone_number,
)
Text RCS Message
To send a RCS text message, create a RCSBasicMessage
object with the desired content.
RCSBasicMessage(text: str)
Parameters
The text content of the RCS message.
Usage
from rcs import Pinnacle, RCSBasicMessage
pinn = Pinnacle(
api_key=YOUR_API_KEY,
webhook_url=YOUR_WEBHOOK_URL,
)
message = RCSBasicMessage("Hello, this is a test message!")
pinn.send(
message,
phone_number,
)
Media RCS Message
To send a RCS media message, create a RCSMediaMessage
object with the desired content.
RCSMediaMessage(media_type: MediaType, media_url: str)
Parameters
The type of media being sent. See the MediaType for available options.
The URL of the media to be sent.
Usage
from rcs import Pinnacle, RCSMediaMessage
pinn = Pinnacle(
api_key=YOUR_API_KEY,
webhook_url=YOUR_WEBHOOK_URL,
)
message = RCSMediaMessage(
media_type="file",
media_url=MEDIA_URL
)
pinn.send(
message,
phone_number,
)
Card Message
To send a Card, create a Card
object with the desired content.
Card(title: str, subtitle: Optional[str] = None, image_url: Optional[str] = None)
Parameters
The title of the card. Max length is 80 characters.
The subtitle of the card. Max length is 80 characters.
The URL of the image to be displayed on the card.
Styling
Horizontal card
To create a horizontal card, use the with_horizontal_style
method.
with_horizontal_style(
width: Optional[CardWidth] = None,
thumbnail_url: Optional[str] = None,
image_alignment: Optional[CardImageAlignment] = None
)
Parameters
The width of the card. See the CardWidth for available options.
The URL of the thumbnail image to be displayed on the card.
The alignment of the image on the card. See the CardImageAlignment for available options.
Vertical card
To create a vertical card, use the with_vertical_style
method.
with_vertical_style(
width: Optional[CardWidth] = None,
thumbnail_url: Optional[str] = None,
media_height: Optional[MediaHeight] = None,
)
Parameters
The width of the card. See the CardWidth for available options.
The URL of the thumbnail image to be displayed on the card.
The height of the media on the card. See the MediaHeight for available options.
Buttons
You can also add buttons to your card using the with_buttons
method. Max length is 4 buttons.
with_buttons(buttons: List[Action])
Parameters
A list of Action objects to be included as buttons on the card. See the Action for more details on how to create an action.
Usage
from rcs import Pinnacle, Card
pinn = Pinnacle(
api_key=YOUR_API_KEY,
webhook_url=YOUR_WEBHOOK_URL,
)
message = (
Card(
title="Card Title",
subtitle="Card Description", # Optional
image_url=card_image_url, # Optional
)
.with_horizontal_style(
width="medium",
image_alignment="left",
)
.with_buttons(
[
Action(
title="URL",
).weburl("https://example.com"),
]
)
)
pinn.send(
message,
phone_number,
)
Carousel Message
To send a Carousel, create a Carousel
object with a list of cards.
Carousel(cards: List[Card])
Parameters
A list of Card objects to be included in the carousel. Max length is 10 cards.
Usage
from rcs import Pinnacle, Card
pinn = Pinnacle(
api_key=YOUR_API_KEY,
webhook_url=YOUR_WEBHOOK_URL,
)
card = (
Card(
title="Card Title",
subtitle="Card Description", # Optional
image_url=card_image_url, # Optional
)
.with_horizontal_style(
width="medium",
image_alignment="left",
)
.with_buttons(
[
Action(
title="URL",
).weburl("https://example.com"),
]
)
)
message = Carousel(cards=[card, card]) # Add multiple cards
pinn.send(
message,
phone_number,
)
Quick Replies
You can optionally attach quick replies to your messages. To do this, use the with_quick_replies
method on your message object.
with_quick_replies(quick_replies: List[Action])
Action
Actions are used to create quick replies and buttons. There are two steps to creating a button:
- Create an
Action
object. - Specify what type of action using methods like
weburl
,postback
, etc.
To create an action for quick replies, create an Action
with its class and action-specific function.
Create an action
Action(title: str)
Parameters
The title of the action that will be displayed as a quick reply or button. Max length is 25 characters.
Usage
from rcs import Action
action = Action(title="Quick Reply")
Action Types
Web URL
Open a URL when the action is clicked.
weburl(url: str)
The URL to be opened when the action is clicked.
Call
Call a phone number when the action is clicked.
call(phone_number: str)
The phone number to be called. It should be in E.164 format (e.g., +14155552671).
Postback
Send a postback message when the action is clicked.
postback(payload: str, execute: Optional[str] = None)
The payload to be sent in the postback message. Max length is 1000 characters.
Optional parameter to specify additional data to be executed.
Share Location
Share a location when the action is clicked.
share_location()
Schedule Event
Schedules a calendar event when the action is clicked.
calendar(title: str, start_time: datetime, end_time: datetime, description: Optional[str] = None)
The title of the event.
The start time of the event.
The end time of the event.
Optional description of the event.
Usage
from datetime import datetime
from rcs import Action
action = Action(title="Schedule Event").calendar(
title="Meeting",
start_time=datetime(2023, 1, 1, 10, 0),
end_time=datetime(2023, 1, 1, 11, 0),
description="Discuss project updates"
)
Add quick replies
with_quick_replies(quick_replies: List[Action])
Parameters
A list of Action objects to be included as quick replies. Max length is 11.
from rcs import Pinnacle, Card
pinn = Pinnacle(
api_key=YOUR_API_KEY,
webhook_url=YOUR_WEBHOOK_URL,
)
message = (
Card(
title="Card Title",
subtitle="Card Description", # Optional
image_url=card_image_url, # Optional
)
.with_buttons(
[
Action(
title="URL",
).weburl("https://example.com"),
]
).with_quick_replies(
[
Action(
title="URL",
).weburl("https://example.com"),
Action(
title="Call",
).call("+14155552671"),
]
)
)
pinn.send(
message,
phone_number,
)
Types
MediaType
The MediaType
can be one of the following:
text
image
video
audio
file
CardWidth
The CardWidth
can be one of the following:
small
medium
CardImageAlignment
The CardImageAlignment
can be one of the following:
left
right
MediaHeight
The MediaHeight
can be one of the following:
small
medium
tall
Was this page helpful?