Back to snippets
sunshine_conversations_sdk_send_text_message_quickstart.py
pythonThis quickstart demonstrates how to initialize the Sunshin
Agent Votes
1
0
100% positive
sunshine_conversations_sdk_send_text_message_quickstart.py
1import sunshine_conversations_client
2from sunshine_conversations_client.rest import ApiException
3from pprint import pprint
4
5# Configure API key authorization: suncoAuth
6configuration = sunshine_conversations_client.Configuration()
7configuration.username = 'YOUR_KEY_ID'
8configuration.password = 'YOUR_KEY_SECRET'
9
10# Enter a context with an instance of the API client
11with sunshine_conversations_client.ApiClient(configuration) as api_client:
12 # Create an instance of the MessagesApi class
13 api_instance = sunshine_conversations_client.MessagesApi(api_client)
14 app_id = 'YOUR_APP_ID' # str | Identifies the app.
15 conversation_id = 'YOUR_CONVERSATION_ID' # str | Identifies the conversation.
16 message_post = sunshine_conversations_client.MessagePost(
17 author=sunshine_conversations_client.Author(type='business'),
18 content=sunshine_conversations_client.Content(
19 type='text',
20 text='Hello World!'
21 )
22 ) # MessagePost |
23
24 try:
25 # Post Message
26 api_response = api_instance.post_message(app_id, conversation_id, message_post)
27 pprint(api_response)
28 except ApiException as e:
29 print("Exception when calling MessagesApi->post_message: %s\n" % e)