-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add documentation for sending messages to Signal #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| --- | ||
| related: | ||
| - title: Core Services | ||
| url: learn/system-architecture/overview/core-services.md | ||
| --- | ||
|
|
||
| # Send messages to Signal | ||
|
|
||
| !!! Info "Overview" | ||
| Send direct Signal messages from the BEC IPython client by addressing recipients with their phone numbers. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - You have a running BEC IPython client session. | ||
| - Signal messaging is enabled for your deployment or session. | ||
|
|
||
| !!! tip "Private phone numbers" | ||
|
|
||
| Make sure to not commit source code with your private phone number to version control. If you want to share code that includes phone numbers, consider using environment variables or configuration files to keep the numbers private. | ||
|
|
||
| ## 1. Create and send a simple message | ||
|
|
||
| Create a new Signal message object from the BEC client and send it to a phone number: | ||
|
|
||
| ```py | ||
| msg = bec.messaging.signal.new() | ||
| msg.add_text("Beamline is ready for alignment.") | ||
| msg.send(scope="+41791234567") | ||
| ``` | ||
|
|
||
| You can also create and send a short message in one line: | ||
|
|
||
| ```py | ||
| bec.messaging.signal.new("Beamline checks completed.").send(scope="+41791234567") | ||
| ``` | ||
|
|
||
| ## 2. Send to phone numbers directly | ||
|
|
||
| For Signal, pass the recipient phone number to `send(scope=...)`. | ||
|
|
||
| ```py | ||
| msg = bec.messaging.signal.new("Scan finished successfully.") | ||
| msg.send(scope="+41791234567") | ||
| ``` | ||
|
|
||
| BEC normalizes valid phone numbers before sending them to Signal. | ||
| For example, Swiss numbers such as `079 123 45 67` and `0041 79 123 45 67` are converted to `+41791234567`. | ||
|
|
||
| ```py | ||
| msg = bec.messaging.signal.new("Direct message using a local number.") | ||
| msg.send(scope="079 123 45 67") | ||
| ``` | ||
|
|
||
| !!! warning "Country codes required" | ||
|
|
||
| BEC always normalizes valid phone numbers without country codes to use the Swiss country code `+41` by default. If you want to send messages to phone numbers in other countries, make sure to include the correct country code in the recipient number. | ||
|
|
||
| You can also send the same message to more than one phone number: | ||
|
|
||
| ```py | ||
| msg = bec.messaging.signal.new("Please confirm detector status.") | ||
| msg.send(scope=["+41791234567", "+41795554433"]) | ||
| ``` | ||
|
|
||
| ## 3. Attach a file | ||
|
|
||
| Add attachments from a local path before sending the message: | ||
|
|
||
| ```py | ||
| msg = bec.messaging.signal.new("Attached: latest detector snapshot.") | ||
| msg.add_attachment("/path/to/snapshot.png") | ||
| msg.send(scope="+41791234567") | ||
| ``` | ||
|
|
||
| Attachments must exist on disk and must be smaller than 5 MB. | ||
|
|
||
| <!-- TODO: Uncomment once we have a better support for stickers --> | ||
| <!-- ## 4. Add a sticker | ||
|
|
||
| Signal messages can include stickers: | ||
|
|
||
| ```py | ||
| msg = bec.messaging.signal.new("Alignment completed.") | ||
| msg.add_sticker("sticker_123") | ||
| msg.send(scope="+41791234567") | ||
| ``` | ||
|
|
||
| ## 5. Combine text and stickers | ||
|
|
||
| You can also mix text and stickers in one message: | ||
|
|
||
| ```py | ||
| msg = bec.messaging.signal.new() | ||
| msg.add_text("The scan queue is empty.") | ||
| msg.add_sticker("sticker_123") | ||
| msg.send(scope="+41791234567") | ||
| ``` --> | ||
|
|
||
| !!! success "Congratulations!" | ||
|
|
||
| You can now send direct Signal messages from the BEC IPython client, address recipients by phone number, and include attachments when needed. | ||
|
|
||
| ## Common pitfalls | ||
|
|
||
| - `bec.messaging.signal.new()` raises an error if Signal messaging is not enabled for the current deployment or session. | ||
| - `send(scope=...)` is where you provide the recipient phone number. | ||
| - `add_attachment(...)` fails if the file does not exist or is larger than 5 MB. | ||
| - Valid phone numbers are normalized automatically before sending. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have some documentation to how enable the messaging on signal or who to contact to enable it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, we are missing the GUI for it and I don't think we should tell them how to use curl