-
Notifications
You must be signed in to change notification settings - Fork 3
DEVEXP-794: Conversation Messages Send - Snippets #118
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
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6637bec
DEVEXP-794: Conversation Messages - Snippets
matsk-sinch 95c1c84
DEVEXP-794: Conversation Messages - Snippets
matsk-sinch 6ab1c1a
apis unit test
matsk-sinch 7e6a27d
update Migration Guide
matsk-sinch d447bfa
solve PR comments
matsk-sinch 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
Some comments aren't visible on the classic Files Changed page.
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
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,41 @@ | ||
| """ | ||
| Sinch Python Snippet | ||
|
|
||
| TODO: Update links when v2 is released. | ||
| This snippet is available at https://github.com/sinch/sinch-sdk-python/blob/v2.0/docs/snippets/ | ||
| """ | ||
|
|
||
| import os | ||
| from dotenv import load_dotenv | ||
| from sinch import SinchClient | ||
|
|
||
| load_dotenv() | ||
|
|
||
| sinch_client = SinchClient( | ||
| project_id=os.environ.get("SINCH_PROJECT_ID") or "MY_PROJECT_ID", | ||
| key_id=os.environ.get("SINCH_KEY_ID") or "MY_KEY_ID", | ||
| key_secret=os.environ.get("SINCH_KEY_SECRET") or "MY_KEY_SECRET", | ||
| conversation_region=os.environ.get("SINCH_CONVERSATION_REGION") or "MY_CONVERSATION_REGION" | ||
| ) | ||
|
|
||
| # The ID of the Conversation App to send the message from | ||
| app_id = "CONVERSATION_APP_ID" | ||
| # The phone number of the recipient in E.164 format (e.g. +46701234567) | ||
| recipient_identities = [ | ||
| { | ||
| "channel": "RCS", | ||
| "identity": "RECIPIENT_PHONE_NUMBER" | ||
| } | ||
| ] | ||
|
|
||
| response = sinch_client.conversation.messages.send( | ||
| app_id=app_id, | ||
| message={ | ||
| "text_message": { | ||
| "text": "[Python SDK: Conversation Message] Sample text message" | ||
| } | ||
| }, | ||
| recipient_identities=recipient_identities | ||
| ) | ||
|
|
||
| print(f"Successfully sent message.\n{response}") |
46 changes: 46 additions & 0 deletions
46
examples/snippets/conversation/messages/send_card_message/snippet.py
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,46 @@ | ||
| """ | ||
| Sinch Python Snippet | ||
|
|
||
| TODO: Update links when v2 is released. | ||
| This snippet is available at https://github.com/sinch/sinch-sdk-python/blob/v2.0/docs/snippets/ | ||
| """ | ||
|
|
||
| import os | ||
| from dotenv import load_dotenv | ||
| from sinch import SinchClient | ||
|
|
||
| load_dotenv() | ||
|
|
||
| sinch_client = SinchClient( | ||
| project_id=os.environ.get("SINCH_PROJECT_ID") or "MY_PROJECT_ID", | ||
| key_id=os.environ.get("SINCH_KEY_ID") or "MY_KEY_ID", | ||
| key_secret=os.environ.get("SINCH_KEY_SECRET") or "MY_KEY_SECRET", | ||
| conversation_region=os.environ.get("SINCH_CONVERSATION_REGION") or "MY_CONVERSATION_REGION" | ||
| ) | ||
|
|
||
| # The ID of the Conversation App to send the message from | ||
| app_id = "CONVERSATION_APP_ID" | ||
asein-sinch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # The phone number of the recipient in E.164 format (e.g. +46701234567) | ||
| recipient_identities = [ | ||
| { | ||
| "channel": "RCS", | ||
| "identity": "RECIPIENT_PHONE_NUMBER" | ||
| } | ||
| ] | ||
asein-sinch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| card_message = { | ||
| "title": "Card title", | ||
| "description": "Optional card description", | ||
| "choices": [ | ||
| {"text_message": {"text": "Yes"}, "postback_data": "yes"}, | ||
| {"text_message": {"text": "No"}, "postback_data": "no"}, | ||
| ] | ||
| } | ||
|
|
||
| response = sinch_client.conversation.messages.send_card_message( | ||
| app_id=app_id, | ||
| card_message=card_message, | ||
| recipient_identities=recipient_identities | ||
| ) | ||
|
|
||
| print(f"Successfully sent card message.\n{response}") | ||
52 changes: 52 additions & 0 deletions
52
examples/snippets/conversation/messages/send_carousel_message/snippet.py
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,52 @@ | ||
| """ | ||
| Sinch Python Snippet | ||
|
|
||
| TODO: Update links when v2 is released. | ||
| This snippet is available at https://github.com/sinch/sinch-sdk-python/blob/v2.0/docs/snippets/ | ||
| """ | ||
|
|
||
| import os | ||
| from dotenv import load_dotenv | ||
| from sinch import SinchClient | ||
|
|
||
| load_dotenv() | ||
|
|
||
| sinch_client = SinchClient( | ||
| project_id=os.environ.get("SINCH_PROJECT_ID") or "MY_PROJECT_ID", | ||
| key_id=os.environ.get("SINCH_KEY_ID") or "MY_KEY_ID", | ||
| key_secret=os.environ.get("SINCH_KEY_SECRET") or "MY_KEY_SECRET", | ||
| conversation_region=os.environ.get("SINCH_CONVERSATION_REGION") or "MY_CONVERSATION_REGION" | ||
| ) | ||
|
|
||
| # The ID of the Conversation App to send the message from | ||
| app_id = "CONVERSATION_APP_ID" | ||
| # The phone number of the recipient in E.164 format (e.g. +46701234567) | ||
| recipient_identities = [ | ||
| { | ||
| "channel": "RCS", | ||
| "identity": "RECIPIENT_PHONE_NUMBER" | ||
| } | ||
| ] | ||
|
|
||
| carousel_message = { | ||
| "cards": [ | ||
| { | ||
| "title": "Card 1", | ||
| "description": "First card description", | ||
| "choices": [{"text_message": {"text": "Option 1"}}], | ||
| }, | ||
| { | ||
| "title": "Card 2", | ||
| "description": "Second card description", | ||
| "choices": [{"url_message": {"title": "Link", "url": "https://example.com"}}], | ||
| }, | ||
| ], | ||
| } | ||
|
|
||
| response = sinch_client.conversation.messages.send_carousel_message( | ||
| app_id=app_id, | ||
| carousel_message=carousel_message, | ||
| recipient_identities=recipient_identities | ||
| ) | ||
|
|
||
| print(f"Successfully sent carousel message.\n{response}") |
45 changes: 45 additions & 0 deletions
45
examples/snippets/conversation/messages/send_choice_message/snippet.py
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,45 @@ | ||
| """ | ||
| Sinch Python Snippet | ||
|
|
||
| TODO: Update links when v2 is released. | ||
| This snippet is available at https://github.com/sinch/sinch-sdk-python/blob/v2.0/docs/snippets/ | ||
| """ | ||
|
|
||
| import os | ||
| from dotenv import load_dotenv | ||
| from sinch import SinchClient | ||
|
|
||
| load_dotenv() | ||
|
|
||
| sinch_client = SinchClient( | ||
| project_id=os.environ.get("SINCH_PROJECT_ID") or "MY_PROJECT_ID", | ||
| key_id=os.environ.get("SINCH_KEY_ID") or "MY_KEY_ID", | ||
| key_secret=os.environ.get("SINCH_KEY_SECRET") or "MY_KEY_SECRET", | ||
| conversation_region=os.environ.get("SINCH_CONVERSATION_REGION") or "MY_CONVERSATION_REGION" | ||
| ) | ||
|
|
||
| # The ID of the Conversation App to send the message from | ||
| app_id = "CONVERSATION_APP_ID" | ||
| # The phone number of the recipient in E.164 format (e.g. +46701234567) | ||
| recipient_identities = [ | ||
| { | ||
| "channel": "RCS", | ||
| "identity": "RECIPIENT_PHONE_NUMBER" | ||
| } | ||
| ] | ||
|
|
||
| choice_message = { | ||
| "text_message": {"text": "Choose an option:"}, | ||
| "choices": [ | ||
| {"text_message": {"text": "Option A"}, "postback_data": "option_a"}, | ||
| {"text_message": {"text": "Option B"}, "postback_data": "option_b"}, | ||
| ], | ||
| } | ||
|
|
||
| response = sinch_client.conversation.messages.send_choice_message( | ||
| app_id=app_id, | ||
| choice_message=choice_message, | ||
| recipient_identities=recipient_identities | ||
| ) | ||
|
|
||
| print(f"Successfully sent choice message.\n{response}") |
42 changes: 42 additions & 0 deletions
42
examples/snippets/conversation/messages/send_contact_info_message/snippet.py
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,42 @@ | ||
| """ | ||
| Sinch Python Snippet | ||
|
|
||
| TODO: Update links when v2 is released. | ||
| This snippet is available at https://github.com/sinch/sinch-sdk-python/blob/v2.0/docs/snippets/ | ||
| """ | ||
|
|
||
| import os | ||
| from dotenv import load_dotenv | ||
| from sinch import SinchClient | ||
|
|
||
| load_dotenv() | ||
|
|
||
| sinch_client = SinchClient( | ||
| project_id=os.environ.get("SINCH_PROJECT_ID") or "MY_PROJECT_ID", | ||
| key_id=os.environ.get("SINCH_KEY_ID") or "MY_KEY_ID", | ||
| key_secret=os.environ.get("SINCH_KEY_SECRET") or "MY_KEY_SECRET", | ||
| conversation_region=os.environ.get("SINCH_CONVERSATION_REGION") or "MY_CONVERSATION_REGION" | ||
| ) | ||
|
|
||
| # The ID of the Conversation App to send the message from | ||
| app_id = "CONVERSATION_APP_ID" | ||
| # The phone number of the recipient in E.164 format (e.g. +46701234567) | ||
| recipient_identities = [ | ||
| { | ||
| "channel": "RCS", | ||
| "identity": "RECIPIENT_PHONE_NUMBER" | ||
| } | ||
| ] | ||
|
|
||
| contact_info_message = { | ||
| "name": {"full_name": "John Doe"}, | ||
| "phone_numbers": [{"phone_number": "+1234567890"}], | ||
| } | ||
|
|
||
| response = sinch_client.conversation.messages.send_contact_info_message( | ||
| app_id=app_id, | ||
| contact_info_message=contact_info_message, | ||
| recipient_identities=recipient_identities | ||
| ) | ||
|
|
||
| print(f"Successfully sent contact info message.\n{response}") |
51 changes: 51 additions & 0 deletions
51
examples/snippets/conversation/messages/send_list_message/snippet.py
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,51 @@ | ||
| """ | ||
| Sinch Python Snippet | ||
|
|
||
| TODO: Update links when v2 is released. | ||
| This snippet is available at https://github.com/sinch/sinch-sdk-python/blob/v2.0/docs/snippets/ | ||
| """ | ||
|
|
||
| import os | ||
| from dotenv import load_dotenv | ||
| from sinch import SinchClient | ||
|
|
||
| load_dotenv() | ||
|
|
||
| sinch_client = SinchClient( | ||
| project_id=os.environ.get("SINCH_PROJECT_ID") or "MY_PROJECT_ID", | ||
| key_id=os.environ.get("SINCH_KEY_ID") or "MY_KEY_ID", | ||
| key_secret=os.environ.get("SINCH_KEY_SECRET") or "MY_KEY_SECRET", | ||
| conversation_region=os.environ.get("SINCH_CONVERSATION_REGION") or "MY_CONVERSATION_REGION" | ||
| ) | ||
|
|
||
| # The ID of the Conversation App to send the message from | ||
| app_id = "CONVERSATION_APP_ID" | ||
| # The phone number of the recipient in E.164 format (e.g. +46701234567) | ||
| recipient_identities = [ | ||
| { | ||
| "channel": "RCS", | ||
| "identity": "RECIPIENT_PHONE_NUMBER" | ||
| } | ||
| ] | ||
|
|
||
| list_message = { | ||
| "title": "Choose an option", | ||
| "description": "Select from the list below", | ||
| "sections": [ | ||
| { | ||
| "title": "Section 1", | ||
| "items": [ | ||
| {"choice": {"title": "Option A", "postback_data": "option_a"}}, | ||
| {"choice": {"title": "Option B", "postback_data": "option_b"}}, | ||
| ], | ||
| }, | ||
| ], | ||
| } | ||
|
|
||
| response = sinch_client.conversation.messages.send_list_message( | ||
| app_id=app_id, | ||
| list_message=list_message, | ||
| recipient_identities=recipient_identities | ||
| ) | ||
|
|
||
| print(f"Successfully sent list message.\n{response}") |
42 changes: 42 additions & 0 deletions
42
examples/snippets/conversation/messages/send_location_message/snippet.py
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,42 @@ | ||
| """ | ||
| Sinch Python Snippet | ||
| TODO: Update links when v2 is released. | ||
| This snippet is available at https://github.com/sinch/sinch-sdk-python/blob/v2.0/docs/snippets/ | ||
| """ | ||
|
|
||
| import os | ||
| from dotenv import load_dotenv | ||
| from sinch import SinchClient | ||
|
|
||
| load_dotenv() | ||
|
|
||
| sinch_client = SinchClient( | ||
| project_id=os.environ.get("SINCH_PROJECT_ID") or "MY_PROJECT_ID", | ||
| key_id=os.environ.get("SINCH_KEY_ID") or "MY_KEY_ID", | ||
| key_secret=os.environ.get("SINCH_KEY_SECRET") or "MY_KEY_SECRET", | ||
| conversation_region=os.environ.get("SINCH_CONVERSATION_REGION") or "MY_CONVERSATION_REGION" | ||
| ) | ||
|
|
||
| # The ID of the Conversation App to send the message from | ||
| app_id = "CONVERSATION_APP_ID" | ||
| # The phone number of the recipient in E.164 format (e.g. +46701234567) | ||
| recipient_identities = [ | ||
| { | ||
| "channel": "RCS", | ||
| "identity": "RECIPIENT_PHONE_NUMBER" | ||
| } | ||
| ] | ||
|
|
||
| location_message = { | ||
| "title": "Our office", | ||
| "coordinates": {"latitude": 59.3293, "longitude": 18.0686}, | ||
| } | ||
|
|
||
| response = sinch_client.conversation.messages.send_location_message( | ||
| app_id=app_id, | ||
| location_message=location_message, | ||
| recipient_identities=recipient_identities | ||
| ) | ||
|
|
||
| print(f"Successfully sent location message.\n{response}") |
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.
Uh oh!
There was an error while loading. Please reload this page.