diff --git a/example/Conversation_APIs/Delete_APIs/delete_api_async.py b/example/Conversation_APIs/Delete_APIs/delete_api_async.py new file mode 100644 index 0000000..4da1b79 --- /dev/null +++ b/example/Conversation_APIs/Delete_APIs/delete_api_async.py @@ -0,0 +1,225 @@ +import symbl + +payload2 = { + "name": "TestingTextAPI", + "trackers": [{ + "name": "text_tracker", + "vocabulary": [ + "indians", + "thoughts", + "vaccination" + ] + }], + "detectEntities": "true", + "enableAllTrackers": "true", + "messages": [ + { + "payload": { + "content": "Let us talk about India Australia Testaments start seeing each other in the past as much we thought like it will be one-sided." + }, + "from": { + "userId": "natalia@example.com", + "name": "Natalia" + }, + "duration": { + "startTime": "2020-07-21T16:04:19.01Z", + "endTime": "2020-07-21T16:04:20.99Z" + } + }, + { + "payload": { + "content": "Only working with is occupied at the moment:blush: , but just generally /there's going to be a lot of (infographic) making done and if you would like to make them yourself I can give you access to then gauge:confetti_ball: . ." + }, + "from": { + "userId": "mike@abccorp.com", + "name": "Mike" + }, + "duration": { + "startTime": "2020-07-21T16:04:19.99Z", + "endTime": "2020-07-21T16:04:20.99Z" + } + }, + { + "payload": { + "content": "We wouldn't have thought like India can win that test match. tomorrow on 21 june, 2021 is our match i think" + }, + "from": { + "userId": "natalia@example.com", + "name": "Natalia" + }, + "duration": { + "startTime": "2020-07-21T16:04:20.99Z", + "endTime": "2020-07-21T16:04:21.99Z" + } + }, + { + "payload": { + "content": "Yeah, no one could ever like predict that India would dominate all the other matches against really started harassing Indians alone, including mom." + }, + "from": { + "userId": "steve@abccorp.com", + "name": "Steve" + }, + "duration": { + "startTime": "2020-07-21T16:04:20.99Z", + "endTime": "2020-07-21T16:04:22.99Z" + } + }, + { + "payload": { + "content": "Other mothers but against give it to fight and Australians also then accepted the defeat gracefully and congratulated the Indian team for their unique victory." + }, + "from": { + "userId": "natalia@example.com", + "name": "Natalia" + }, + "duration": { + "startTime": "2020-07-21T16:04:23.99Z", + "endTime": "2020-07-21T16:04:24.99Z" + } + }, + { + "payload": { + "content": "And a test on this much." + }, + "from": { + "userId": "mike@abccorp.com", + "name": "Mike" + }, + "duration": { + "startTime": "2020-07-21T16:04:25.99Z", + "endTime": "2020-07-21T16:04:26.99Z" + } + }, + { + "payload": { + "content": "We will again have to talk based on the topic Rohit water to the topics, and we see the topics that are generated here." + }, + "from": { + "userId": "natalia@example.com", + "name": "Natalia" + }, + "duration": { + "startTime": "2020-07-21T16:04:27.99Z", + "endTime": "2020-07-21T16:04:29.99Z" + } + }, + { + "payload": { + "content": "I don't know what clean water spaghetti tacos." + }, + "from": { + "userId": "steve@abccorp.com", + "name": "Steve" + }, + "duration": { + "startTime": "2020-07-21T16:04:30.99Z", + "endTime": "2020-07-21T16:04:31.99Z" + } + }, + { + "payload": { + "content": "Australian distance Indians, so we can talk about Indians." + }, + "from": { + "userId": "steve@abccorp.com", + "name": "Steve" + }, + "duration": { + "startTime": "2020-07-21T16:04:32.99Z", + "endTime": "2020-07-21T16:04:33.99Z" + } + }, + { + "payload": { + "content": "Yeah, yeah, we can talk about it." + }, + "from": { + "userId": "natalia@example.com", + "name": "Natalia" + }, + "duration": { + "startTime": "2020-07-21T16:04:34.99Z", + "endTime": "2020-07-21T16:04:35.99Z" + } + }, + { + "payload": { + "content": "Let us talk about the Indian culture." + }, + "from": { + "userId": "mike@abccorp.com", + "name": "Mike" + }, + "duration": { + "startTime": "2020-07-21T16:04:36.99Z", + "endTime": "2020-07-21T16:04:37.99Z" + } + }, + { + "payload": { + "content": "We will again have to talk based on the topic Rohit water to the topics, and we see the topics that are generated here." + }, + "from": { + "userId": "natalia@example.com", + "name": "Natalia" + }, + "duration": { + "startTime": "2020-07-21T16:04:38.99Z", + "endTime": "2020-07-21T16:04:40.99Z" + } + }, + { + "payload": { + "content": "Let us go." + }, + "from": { + "userId": "steve@abccorp.com", + "name": "Steve" + }, + "duration": { + "startTime": "2020-07-21T16:04:40.99Z", + "endTime": "2020-07-21T16:04:41.99Z" + } + }, + { + "payload": { + "content": "Indians are really very current Indians are great people but sometimes pay." + }, + "from": { + "userId": "steve@abccorp.com", + "name": "Steve" + }, + "duration": { + "startTime": "2020-07-21T16:04:42.99Z", + "endTime": "2020-07-21T16:04:43.99Z" + } + }, + { + "payload": { + "content": "Also, very violent." + }, + "from": { + "userId": "steve@abccorp.com", + "name": "Steve" + }, + "duration": { + "startTime": "2020-07-21T16:08:44.99Z", + "endTime": "2020-07-21T16:08:45.99Z" + } + } + ], + "entities": [ + { + "customType": "identify_org", + "text": "platform" + } + ] + +} + +conversation_object = symbl.Text.process(payload=payload2) +print(conversation_object.get_members()) +print(conversation_object.delete_conversation()) +print(conversation_object.get_messages()) + diff --git a/example/Conversation_APIs/Delete_APIs/delete_api_conversationApi.py b/example/Conversation_APIs/Delete_APIs/delete_api_conversationApi.py new file mode 100644 index 0000000..82f8038 --- /dev/null +++ b/example/Conversation_APIs/Delete_APIs/delete_api_conversationApi.py @@ -0,0 +1,4 @@ +import symbl +#to use the delete API using ConversationApi class +conversation_id = "1234567890" +print(symbl.Conversations.delete_conversation(conversation_id)) diff --git a/example/Conversation_APIs/Delete_APIs/delete_api_streaming.py b/example/Conversation_APIs/Delete_APIs/delete_api_streaming.py new file mode 100644 index 0000000..2aed8de --- /dev/null +++ b/example/Conversation_APIs/Delete_APIs/delete_api_streaming.py @@ -0,0 +1,14 @@ +import symbl +events = { + 'message': lambda response: print(response), + 'message_response': lambda response: print('Final Messages -> ', [ message['payload']['content'] for message in response['messages']]) +} +connection_object = symbl.Streaming.start_connection(insight_types=['question', 'action_item'],speaker= { + 'userId': 'abc@example.com', + 'name': 'abc', + }) +connection_object.subscribe(events) + +connection_object.send_audio_from_mic() + +print(connection_object.conversation.delete_conversation()) \ No newline at end of file diff --git a/example/Conversation_APIs/Delete_APIs/delete_api_telephony_pstn.py b/example/Conversation_APIs/Delete_APIs/delete_api_telephony_pstn.py new file mode 100644 index 0000000..c7e1c24 --- /dev/null +++ b/example/Conversation_APIs/Delete_APIs/delete_api_telephony_pstn.py @@ -0,0 +1,64 @@ + +import symbl + + +phoneNumber = "" # Zoom phone number to be called, which is mentioned into the Zoom meeting invitation +meetingId = "" # Your zoom meetingId +password = "" # Your zoom meeting passcode +emailId = "" # Email address on which you would like to receive the detailed summary of the meeting + + +# here are all events supported by Telephony API, you just need to uncomment the event which you would like to use +events = { + 'transcript_response': lambda transcript: print('printing the transcript response ', str(transcript)) + ,'message_response': lambda message: print('printing the message response ', str(message)) + #,'insight_response': lambda insight: print('printing the insight response ', str(insight)) + #,'topic_response': lambda topic: print('printing the topic response ', str(topic)) +} + +connection_object = symbl.Telephony.start_pstn( + phone_number=phoneNumber, + dtmf = ",,{}#,,{}#".format(meetingId, password), + actions = [ + { + "invokeOn": "stop", + "name": "sendSummaryEmail", + "parameters": { + "emails": [ + emailId + ], + }, + }, + ]) + +connection_object.subscribe(events) + +connection_object.conversation.delete_conversation() + +# you can get the response from the conversation object, when you will stop the connection explicitly using keyboard interrupt or by using +# connection_object.stop() # you can also stop the connection after sspecifying some interval of timing + +# To get the message from the meeting +#print(connection_object.conversation.get_messages()) + +#To get the conversation data from the conversation +#print(connection_object.conversation.get_conversation()) + +# To get the action items from the meeting +# print(connection_object.conversation.get_action_items()) + +# To get the follow ups from the meeting +# print(connection_object.conversation.get_follow_ups()) + +# To get the members information from the meeting +# print(connection_object.conversation.get_members()) + +# To get the topics from the meeting +# print(connection_object.conversation.get_topics()) + +# To get the questions from the meeting +# print(connection_object.conversation.get_questions()) + +# To get the analytics from the conversation +#print(connection_object.conversation.get_analytics()) + diff --git a/example/Conversation_APIs/Delete_APIs/delete_api_telephony_sip.py b/example/Conversation_APIs/Delete_APIs/delete_api_telephony_sip.py new file mode 100644 index 0000000..ff1058f --- /dev/null +++ b/example/Conversation_APIs/Delete_APIs/delete_api_telephony_sip.py @@ -0,0 +1,45 @@ +from symbl.utils.Threads import Thread +import symbl +import time + +# here are all events supported by Telephony API, you just need to uncomment the event which you would like to use +events = { + 'transcript_response': lambda transcript: print('printing the transcript response ', str(transcript)) + ,'message_response': lambda message: print('printing the message response ', str(message)) + #,'insight_response': lambda insight: print('printing the insight response ', str(insight)) + #,'topic_response': lambda topic: print('printing the topic response ', str(topic)) +} + +sip_uri = "" +connection_object = symbl.Telephony.start_sip(uri=sip_uri) + +connection_object.subscribe(events) + +print(connection_object.conversation.delete_conversation()) + +# you can get the response from the conversation object, when you will stop the connection explicitly using keyboard interrupt or by using +# connection_object.stop() + +# To get the message from the conversation +#print(connection_object.conversation.get_messages()) + +#To get the conversation data from the conversation +#print(connection_object.conversation.get_conversation()) + +# To get the action items from the conversation +# print(connection_object.conversation.get_action_items()) + +# To get the follow ups from the conversation +# print(connection_object.conversation.get_follow_ups()) + +# To get the members information from the conversation +# print(connection_object.conversation.get_members()) + +# To get the topics from the conversation +# print(connection_object.conversation.get_topics()) + +# To get the questions from the conversation +# print(connection_object.conversation.get_questions()) + +# To get the analytics from the conversation +#print(connection_object.conversation.get_analytics()) diff --git a/example/Conversation_APIs/Post_APIs/formatted_transcript_ConversationApi.py b/example/Conversation_APIs/Post_APIs/formatted_transcript_ConversationApi.py new file mode 100644 index 0000000..0123cb7 --- /dev/null +++ b/example/Conversation_APIs/Post_APIs/formatted_transcript_ConversationApi.py @@ -0,0 +1,15 @@ +import symbl +#to test API using ConversationApi class + +payload = { + 'contentType': 'text/markdown', + # 'contentType': 'text/srt', + 'createParagraphs': "true", + 'phrases': { + 'highlightOnlyInsightKeyPhrases': "true", + 'highlightAllKeyPhrases': "true" + }, + 'showSpeakerSeparation': "true" +} +conversation_id = "1234567890" #update with your conversation id +print(symbl.Conversations.get_formatted_transcript(parameters=payload,conversation_id=conversation_id)) diff --git a/example/Conversation_APIs/Post_APIs/formatted_transcript_api_async.py b/example/Conversation_APIs/Post_APIs/formatted_transcript_api_async.py new file mode 100644 index 0000000..e082fc1 --- /dev/null +++ b/example/Conversation_APIs/Post_APIs/formatted_transcript_api_async.py @@ -0,0 +1,234 @@ +import symbl + +payload2 = { + "name": "TestingTextAPI", + "trackers": [{ + "name": "text_tracker", + "vocabulary": [ + "indians", + "thoughts", + "vaccination" + ] + }], + "detectEntities": "true", + "enableAllTrackers": "true", + "messages": [ + { + "payload": { + "content": "Let us talk about India Australia Testaments start seeing each other in the past as much we thought like it will be one-sided." + }, + "from": { + "userId": "natalia@example.com", + "name": "Natalia" + }, + "duration": { + "startTime": "2020-07-21T16:04:19.01Z", + "endTime": "2020-07-21T16:04:20.99Z" + } + }, + { + "payload": { + "content": "Only working with is occupied at the moment:blush: , but just generally /there's going to be a lot of (infographic) making done and if you would like to make them yourself I can give you access to then gauge:confetti_ball: . ." + }, + "from": { + "userId": "mike@abccorp.com", + "name": "Mike" + }, + "duration": { + "startTime": "2020-07-21T16:04:19.99Z", + "endTime": "2020-07-21T16:04:20.99Z" + } + }, + { + "payload": { + "content": "We wouldn't have thought like India can win that test match. tomorrow on 21 june, 2021 is our match i think" + }, + "from": { + "userId": "natalia@example.com", + "name": "Natalia" + }, + "duration": { + "startTime": "2020-07-21T16:04:20.99Z", + "endTime": "2020-07-21T16:04:21.99Z" + } + }, + { + "payload": { + "content": "Yeah, no one could ever like predict that India would dominate all the other matches against really started harassing Indians alone, including mom." + }, + "from": { + "userId": "steve@abccorp.com", + "name": "Steve" + }, + "duration": { + "startTime": "2020-07-21T16:04:20.99Z", + "endTime": "2020-07-21T16:04:22.99Z" + } + }, + { + "payload": { + "content": "Other mothers but against give it to fight and Australians also then accepted the defeat gracefully and congratulated the Indian team for their unique victory." + }, + "from": { + "userId": "natalia@example.com", + "name": "Natalia" + }, + "duration": { + "startTime": "2020-07-21T16:04:23.99Z", + "endTime": "2020-07-21T16:04:24.99Z" + } + }, + { + "payload": { + "content": "And a test on this much." + }, + "from": { + "userId": "mike@abccorp.com", + "name": "Mike" + }, + "duration": { + "startTime": "2020-07-21T16:04:25.99Z", + "endTime": "2020-07-21T16:04:26.99Z" + } + }, + { + "payload": { + "content": "We will again have to talk based on the topic Rohit water to the topics, and we see the topics that are generated here." + }, + "from": { + "userId": "natalia@example.com", + "name": "Natalia" + }, + "duration": { + "startTime": "2020-07-21T16:04:27.99Z", + "endTime": "2020-07-21T16:04:29.99Z" + } + }, + { + "payload": { + "content": "I don't know what clean water spaghetti tacos." + }, + "from": { + "userId": "steve@abccorp.com", + "name": "Steve" + }, + "duration": { + "startTime": "2020-07-21T16:04:30.99Z", + "endTime": "2020-07-21T16:04:31.99Z" + } + }, + { + "payload": { + "content": "Australian distance Indians, so we can talk about Indians." + }, + "from": { + "userId": "steve@abccorp.com", + "name": "Steve" + }, + "duration": { + "startTime": "2020-07-21T16:04:32.99Z", + "endTime": "2020-07-21T16:04:33.99Z" + } + }, + { + "payload": { + "content": "Yeah, yeah, we can talk about it." + }, + "from": { + "userId": "natalia@example.com", + "name": "Natalia" + }, + "duration": { + "startTime": "2020-07-21T16:04:34.99Z", + "endTime": "2020-07-21T16:04:35.99Z" + } + }, + { + "payload": { + "content": "Let us talk about the Indian culture." + }, + "from": { + "userId": "mike@abccorp.com", + "name": "Mike" + }, + "duration": { + "startTime": "2020-07-21T16:04:36.99Z", + "endTime": "2020-07-21T16:04:37.99Z" + } + }, + { + "payload": { + "content": "We will again have to talk based on the topic Rohit water to the topics, and we see the topics that are generated here." + }, + "from": { + "userId": "natalia@example.com", + "name": "Natalia" + }, + "duration": { + "startTime": "2020-07-21T16:04:38.99Z", + "endTime": "2020-07-21T16:04:40.99Z" + } + }, + { + "payload": { + "content": "Let us go." + }, + "from": { + "userId": "steve@abccorp.com", + "name": "Steve" + }, + "duration": { + "startTime": "2020-07-21T16:04:40.99Z", + "endTime": "2020-07-21T16:04:41.99Z" + } + }, + { + "payload": { + "content": "Indians are really very current Indians are great people but sometimes pay." + }, + "from": { + "userId": "steve@abccorp.com", + "name": "Steve" + }, + "duration": { + "startTime": "2020-07-21T16:04:42.99Z", + "endTime": "2020-07-21T16:04:43.99Z" + } + }, + { + "payload": { + "content": "Also, very violent." + }, + "from": { + "userId": "steve@abccorp.com", + "name": "Steve" + }, + "duration": { + "startTime": "2020-07-21T16:08:44.99Z", + "endTime": "2020-07-21T16:08:45.99Z" + } + } + ], + "entities": [ + { + "customType": "identify_org", + "text": "platform" + } + ] + +} +payload = { + 'contentType': 'text/markdown', + # 'contentType': 'text/srt', + 'createParagraphs': "true", + 'phrases': { + 'highlightOnlyInsightKeyPhrases': "true", + 'highlightAllKeyPhrases': "true" + }, + 'showSpeakerSeparation': "true" +} + +#to test API using conversation class +conversation_object = symbl.Text.process(payload=payload2) +print(conversation_object.get_formatted_transcript(parameters= payload)) + diff --git a/example/Conversation_APIs/Post_APIs/formatted_transcript_api_streaming.py b/example/Conversation_APIs/Post_APIs/formatted_transcript_api_streaming.py new file mode 100644 index 0000000..cc1b086 --- /dev/null +++ b/example/Conversation_APIs/Post_APIs/formatted_transcript_api_streaming.py @@ -0,0 +1,24 @@ +import symbl +events = { + 'message': lambda response: print(response), + 'message_response': lambda response: print('Final Messages -> ', [ message['payload']['content'] for message in response['messages']]) +} +connection_object = symbl.Streaming.start_connection(insight_types=['question', 'action_item'],speaker= { + 'userId': 'abc@example.com', + 'name': 'abc', + }) +connection_object.subscribe(events) + +connection_object.send_audio_from_mic() + +payload = { + 'contentType': 'text/markdown', + # 'contentType': 'text/srt', + 'createParagraphs': "true", + 'phrases': { + 'highlightOnlyInsightKeyPhrases': "true", + 'highlightAllKeyPhrases': "true" + }, + 'showSpeakerSeparation': "true" +} +print(connection_object.conversation.get_formatted_transcript(parameters= payload)) \ No newline at end of file diff --git a/example/Conversation_APIs/Post_APIs/formatted_transcript_api_telephony_pstn.py b/example/Conversation_APIs/Post_APIs/formatted_transcript_api_telephony_pstn.py new file mode 100644 index 0000000..7bf592a --- /dev/null +++ b/example/Conversation_APIs/Post_APIs/formatted_transcript_api_telephony_pstn.py @@ -0,0 +1,74 @@ + +import symbl + + +phoneNumber = "" # Zoom phone number to be called, which is mentioned into the Zoom meeting invitation +meetingId = "" # Your zoom meetingId +password = "" # Your zoom meeting passcode +emailId = "" # Email address on which you would like to receive the detailed summary of the meeting + + +# here are all events supported by Telephony API, you just need to uncomment the event which you would like to use +events = { + 'transcript_response': lambda transcript: print('printing the transcript response ', str(transcript)) + ,'message_response': lambda message: print('printing the message response ', str(message)) + #,'insight_response': lambda insight: print('printing the insight response ', str(insight)) + #,'topic_response': lambda topic: print('printing the topic response ', str(topic)) +} + +connection_object = symbl.Telephony.start_pstn( + phone_number=phoneNumber, + dtmf = ",,{}#,,{}#".format(meetingId, password), + actions = [ + { + "invokeOn": "stop", + "name": "sendSummaryEmail", + "parameters": { + "emails": [ + emailId + ], + }, + }, + ]) + +connection_object.subscribe(events) + +payload = { + 'contentType': 'text/markdown', + # 'contentType': 'text/srt', + 'createParagraphs': "true", + 'phrases': { + 'highlightOnlyInsightKeyPhrases': "true", + 'highlightAllKeyPhrases': "true" + }, + 'showSpeakerSeparation': "true" +} +print(connection_object.conversation.get_formatted_transcript(parameters= payload)) + +# you can get the response from the conversation object, when you will stop the connection explicitly using keyboard interrupt or by using +# connection_object.stop() # you can also stop the connection after sspecifying some interval of timing + +# To get the message from the meeting +#print(connection_object.conversation.get_messages()) + +#To get the conversation data from the conversation +#print(connection_object.conversation.get_conversation()) + +# To get the action items from the meeting +# print(connection_object.conversation.get_action_items()) + +# To get the follow ups from the meeting +# print(connection_object.conversation.get_follow_ups()) + +# To get the members information from the meeting +# print(connection_object.conversation.get_members()) + +# To get the topics from the meeting +# print(connection_object.conversation.get_topics()) + +# To get the questions from the meeting +# print(connection_object.conversation.get_questions()) + +# To get the analytics from the conversation +#print(connection_object.conversation.get_analytics()) + diff --git a/example/Conversation_APIs/Post_APIs/formatted_transcript_api_telephony_sip.py b/example/Conversation_APIs/Post_APIs/formatted_transcript_api_telephony_sip.py new file mode 100644 index 0000000..9f81da4 --- /dev/null +++ b/example/Conversation_APIs/Post_APIs/formatted_transcript_api_telephony_sip.py @@ -0,0 +1,56 @@ +from symbl.utils.Threads import Thread +import symbl +import time + +# here are all events supported by Telephony API, you just need to uncomment the event which you would like to use +events = { + 'transcript_response': lambda transcript: print('printing the transcript response ', str(transcript)) + ,'message_response': lambda message: print('printing the message response ', str(message)) + #,'insight_response': lambda insight: print('printing the insight response ', str(insight)) + #,'topic_response': lambda topic: print('printing the topic response ', str(topic)) +} + +sip_uri = "" +connection_object = symbl.Telephony.start_sip(uri=sip_uri) + +connection_object.subscribe(events) + + +payload = { + 'contentType': 'text/markdown', + # 'contentType': 'text/srt', + 'createParagraphs': "true", + 'phrases': { + 'highlightOnlyInsightKeyPhrases': "true", + 'highlightAllKeyPhrases': "true" + }, + 'showSpeakerSeparation': "true" +} +print(connection_object.conversation.get_formatted_transcript(parameters= payload)) + +# you can get the response from the conversation object, when you will stop the connection explicitly using keyboard interrupt or by using +# connection_object.stop() + +# To get the message from the conversation +#print(connection_object.conversation.get_messages()) + +#To get the conversation data from the conversation +#print(connection_object.conversation.get_conversation()) + +# To get the action items from the conversation +# print(connection_object.conversation.get_action_items()) + +# To get the follow ups from the conversation +# print(connection_object.conversation.get_follow_ups()) + +# To get the members information from the conversation +# print(connection_object.conversation.get_members()) + +# To get the topics from the conversation +# print(connection_object.conversation.get_topics()) + +# To get the questions from the conversation +# print(connection_object.conversation.get_questions()) + +# To get the analytics from the conversation +#print(connection_object.conversation.get_analytics()) diff --git a/requirements.txt b/requirements.txt index 8e86d7a..5a30f20 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -symbl_rest >= 1.0.10 +symbl_rest >= 1.0.11 websocket-client >= 0.59.0 sounddevice >= 0.4.1 numpy diff --git a/setup.py b/setup.py index 8d8721c..aaef5ba 100644 --- a/setup.py +++ b/setup.py @@ -20,12 +20,12 @@ setup( name="symbl", - version="1.0.16", + version="1.0.17", description="symbl.ai SDK", author_email="info@symbl.ai", url="", keywords=["Symbl.ai SDK"], - install_requires=["symbl_rest >= 1.0.10", "websocket-client >= 0.59.0", "sounddevice >= 0.4.1", "numpy"], + install_requires=["symbl_rest >= 1.0.11", "websocket-client >= 0.59.0", "sounddevice >= 0.4.1", "numpy"], packages=find_packages(), include_package_data=True, long_description="""\ diff --git a/symbl/Conversations.py b/symbl/Conversations.py index 0338261..eed5499 100644 --- a/symbl/Conversations.py +++ b/symbl/Conversations.py @@ -96,3 +96,12 @@ def put_members(self, members_id, parameters={}): @validate_conversation_id def put_speakers_events(self, parameters={}): return self.__conversation_api.put_speakers_events(self.__conversation_id, parameters, credentials=self.__credentials) + + @validate_conversation_id + def delete_conversation(self): + return self.__conversation_api.delete_conversation(self.__conversation_id, credentials=self.__credentials) + + @validate_conversation_id + def get_formatted_transcript(self, parameters={}): + return self.__conversation_api.get_formatted_transcript(self.__conversation_id,parameters,credentials=self.__credentials) + \ No newline at end of file diff --git a/symbl/conversations_api/ConversationsApi.py b/symbl/conversations_api/ConversationsApi.py index 3046bf5..341057b 100644 --- a/symbl/conversations_api/ConversationsApi.py +++ b/symbl/conversations_api/ConversationsApi.py @@ -1,4 +1,4 @@ -from symbl.utils.Helper import correct_boolean_values, dictionary_to_valid_json, initialize_api_client +from symbl.utils.Helper import correct_boolean_values, dictionary_to_valid_json, initialize_api_client, insert_valid_boolean_values from symbl_rest import ConversationsApi as conversations_api_rest from symbl.utils import Helper @@ -13,51 +13,114 @@ def __init__(self): @initialize_api_client def get_action_items(self, conversation_id, credentials=None): - return self.conversations_api_rest.get_action_items_by_conversation_id(conversation_id) + try: + return self.conversations_api_rest.get_action_items_by_conversation_id(conversation_id) + except: + return {'message': 'The conversationId is either invalid or does not exist.'} + @initialize_api_client def get_follow_ups(self, conversation_id, credentials=None ): - return self.conversations_api_rest.get_follow_ups_by_conversation_id(conversation_id) - + try: + return self.conversations_api_rest.get_follow_ups_by_conversation_id(conversation_id) + except: + return {'message': 'The conversationId is either invalid or does not exist.'} + @initialize_api_client def get_members(self, conversation_id, credentials=None): - return self.conversations_api_rest.get_members_by_conversation_id(conversation_id) + try: + return self.conversations_api_rest.get_members_by_conversation_id(conversation_id) + except: + return {'message': 'The conversationId is either invalid or does not exist.'} + @initialize_api_client def get_messages(self, conversation_id, credentials=None, parameters={}): params = dictionary_to_valid_json(parameters) - return self.conversations_api_rest.get_messages_by_conversation_id(conversation_id, **correct_boolean_values(params)) + try: + return self.conversations_api_rest.get_messages_by_conversation_id(conversation_id, **correct_boolean_values(params)) + except: + return {'message': 'The conversationId is either invalid or does not exist.'} @initialize_api_client def get_questions(self, conversation_id, credentials=None): - return self.conversations_api_rest.get_questions_by_conversation_id(conversation_id) + try: + return self.conversations_api_rest.get_questions_by_conversation_id(conversation_id) + except: + return {'message': 'The conversationId is either invalid or does not exist.'} + @initialize_api_client def get_topics(self, conversation_id, credentials=None, parameters={}): - params = dictionary_to_valid_json(parameters) - return self.conversations_api_rest.get_topics_by_conversation_id(conversation_id, **correct_boolean_values(params)) + try: + params = dictionary_to_valid_json(parameters) + return self.conversations_api_rest.get_topics_by_conversation_id(conversation_id, **correct_boolean_values(params)) + except: + return {'message': 'The conversationId is either invalid or does not exist.'} + @initialize_api_client def get_conversation(self, conversation_id, credentials=None): - return self.conversations_api_rest.get_conversation_by_conversation_id(conversation_id) + try: + return self.conversations_api_rest.get_conversation_by_conversation_id(conversation_id) + except: + return {'message': 'The conversationId is either invalid or does not exist.'} + @initialize_api_client def get_trackers(self, conversation_id, credentials=None): - return self.conversations_api_rest.get_trackers_by_conversation_id(conversation_id) + try: + return self.conversations_api_rest.get_trackers_by_conversation_id(conversation_id) + except: + return {'message': 'The conversationId is either invalid or does not exist.'} + @initialize_api_client def get_entities(self, conversation_id, credentials=None): - api_response = self.conversations_api_rest.get_entities_by_conversation_id(conversation_id) - return Helper.parse_entity_response(api_response) if len(api_response.entities)!=0 else api_response + try: + api_response = self.conversations_api_rest.get_entities_by_conversation_id(conversation_id) + return Helper.parse_entity_response(api_response) if len(api_response.entities)!=0 else api_response + except: + return {'message': 'The conversationId is either invalid or does not exist.'} + @initialize_api_client def get_analytics(self, conversation_id, credentials=None): - return self.conversations_api_rest.get_analytics_by_conversation_id(conversation_id) + try: + return self.conversations_api_rest.get_analytics_by_conversation_id(conversation_id) + except: + return {'message': 'The conversationId is either invalid or does not exist.'} + @initialize_api_client def put_members(self, conversation_id, members_id, parameters={}, credentials=None): - return self.conversations_api_rest.put_members_information_by_members_id(conversation_id, members_id, body=parameters) + try: + return self.conversations_api_rest.put_members_information_by_members_id(conversation_id, members_id, body=parameters) + except: + return {'message': 'The conversationId is either invalid or does not exist.'} + @initialize_api_client def put_speakers_events(self, conversation_id, parameters={}, credentials=None): - return self.conversations_api_rest.put_speakers_event_by_conversation_id(conversation_id, body=parameters) + try: + return self.conversations_api_rest.put_speakers_event_by_conversation_id(conversation_id, body=parameters) + except: + return {'message': 'The conversationId is either invalid or does not exist.'} + + + @initialize_api_client + def delete_conversation(self, conversation_id, credentials=None): + try: + return self.conversations_api_rest.delete_conversation_by_conversation_id(conversation_id) + except: + pass + + @initialize_api_client + def get_formatted_transcript(self, conversation_id, parameters = {},credentials=None): + try: + content_type = "application/json" + params = insert_valid_boolean_values(parameters) + return self.conversations_api_rest.get_formatted_transcript_by_conversation_id(params,content_type,conversation_id) + except: + return {'message': 'The conversationId is either invalid or does not exist.'} + \ No newline at end of file diff --git a/symbl/readme.md b/symbl/readme.md index be192bf..14936a6 100644 --- a/symbl/readme.md +++ b/symbl/readme.md @@ -244,7 +244,20 @@ Conversation object is returned by Async API Text, Audio and Video classes. The > >click [here](https://github.com/symblai/symbl-python/tree/main/example/Conversation_APIs/Put_APIs/put_speaker_events_streaming.py) to check the example for usage of `put_speakers_events` functionality using `Conversations class` for Streaming APIs. -> +13. conversation_object.delete_conversation() + + >This API permanently deletes conversation and all related entities such as messages, insights, topics etc. associated with the Conversation ID. + > + >click [here](https://github.com/symblai/symbl-python/tree/main/example/Conversation_APIs/Delete_APIs) to check the example for usage of `delete_conversation` functionality. + +14. conversation_object.get_formatted_transcript(parameters={}) + + >parameters:- (mandatory) dictionary, takes a dictionary of request body parameters. For list of request body parameters accepted, please click [here](https://docs.symbl.ai/docs/conversation-api/transcript#request-body-parameters) + > + >returns a formatted transcript in Markdown and SRT format. + > + >click [here](https://github.com/symblai/symbl-python/tree/main/example/Conversation_APIs/Post_APIs) to check the example for usage of `get_formatted_transcript` functionality. + >example for demonstrate the use of conversation class > ``` @@ -336,6 +349,22 @@ You can utilize different functions of Conversation APIs by directly utilizing ` > >click [here](https://github.com/symblai/symbl-python/tree/main/example/Conversation_APIs/Put_APIs/put_speaker_events_streaming.py) to check the example for usage of `put_speakers_events` functionality using `Conversations class` for Streaming APIs. +13. delete_conversation(conversation_id) + + >This API permanently deletes conversation and all related entities such as messages, insights, topics etc. associated with the Conversation ID. + > + >click [here](https://github.com/symblai/symbl-python/tree/main/example/Conversation_APIs/Delete_APIs) to check the example for usage of `delete_conversation` functionality. + + +14. get_formatted_transcript(conversation_id, parameters={}) + + >parameters:- (mandatory) dictionary, takes a dictionary of request body parameters. For list of request body parameters accepted, please click [here](https://docs.symbl.ai/docs/conversation-api/transcript#request-body-parameters) + > + >returns a formatted transcript in Markdown and SRT format. + > + >click [here](https://github.com/symblai/symbl-python/tree/main/example/Conversation_APIs/Post_APIs) to check the example for usage of `get_formatted_transcript` functionality. + + >example for demonstrate the use of Conversations class > ``` @@ -384,7 +413,7 @@ Based on PSTN and SIP protocols, the Telephony API provides an interface for the >returns connection object > - >click [here]https://github.com/symblai/symbl-python/tree/main/example/Telephony_API/telephony_sip.py) to check the example for usage of parameters/arguments and connection object + >click [here](https://github.com/symblai/symbl-python/tree/main/example/Telephony_API/telephony_sip.py) to check the example for usage of parameters/arguments and connection object > >For more details check [here][telephony-docs] diff --git a/symbl/utils/Helper.py b/symbl/utils/Helper.py index fbed868..6d74e70 100644 --- a/symbl/utils/Helper.py +++ b/symbl/utils/Helper.py @@ -12,6 +12,20 @@ def correct_boolean_values(dictionary: dict): dictionary[key] = "false" return dictionary +def insert_valid_boolean_values(dictionary: dict): + for key in dictionary: + if type(dictionary[key]) == dict: + for dict_key in dictionary[key]: + if dictionary[key][dict_key] == "true": + dictionary[key][dict_key] = True + elif dictionary[key][dict_key] == "false": + dictionary[key][dict_key] = False + elif dictionary[key] == "true": + dictionary[key] = True + elif dictionary[key] == "false": + dictionary[key] = False + return dictionary + def dictionary_to_valid_json(dictionary: dict): new_dictionary = dict() for key in dictionary.keys(): diff --git a/tests/conversations_api_test.py b/tests/conversations_api_test.py index 76472a7..e99fe1d 100644 --- a/tests/conversations_api_test.py +++ b/tests/conversations_api_test.py @@ -9,75 +9,162 @@ class ConversationsApiTest(unittest.TestCase): def test_get_messages_should_succeed_given_valid_conversation_id(self): - demo_response = SimpleNamespace(**{"messages":[{"id":"6125275260649472","text":"Hey, is this a question?","from":{},"startTime":"2021-05-27T13:19:25.270Z","endTime":"2021-05-27T13:19:26.770Z","conversationId":"6549352073920512","phrases":[]}]}) + demo_response = SimpleNamespace(**{"messages": [{"id": "6125275260649472", "text": "Hey, is this a question?", "from": { + }, "startTime": "2021-05-27T13:19:25.270Z", "endTime": "2021-05-27T13:19:26.770Z", "conversationId": "6549352073920512", "phrases": []}]}) conversations_api = ConversationsApi() with patch("symbl.AuthenticationToken.get_api_client", Mock(return_value="None")), patch("symbl_rest.ConversationsApi.get_messages_by_conversation_id", Mock(return_value=demo_response)): - self.assertEqual(demo_response, conversations_api.get_messages("6549352073920512")) + self.assertEqual( + demo_response, conversations_api.get_messages("6549352073920512")) def test_get_action_items_should_succeed_given_valid_conversation_id(self): - demo_response = SimpleNamespace(**{"actionItems":[{"id":"4755377456414720","text":"Steve needs to complete the analysis by next Monday.","type":"action_item","score":0.9765610554943914,"messageIds":["5590459222065152"],"entities":[{"type":"daterange","text":"by next monday","offset":39,"end":"2021-06-07"},{"type":"person","text":"Steve","offset":0,"value":{"assignee":True,"id":"98d11b11-4a0a-4bdd-b2e1-d50238f605d6","name":"Steve","userId":"Steve@example.com"}}],"phrases":[],"from":{"id":"98d11b11-4a0a-4bdd-b2e1-d50238f605d6","name":"Steve","userId":"Steve@example.com"},"definitive":True,"assignee":{"id":"98d11b11-4a0a-4bdd-b2e1-d50238f605d6","name":"Steve","email":"Steve@example.com"}}]}) + demo_response = SimpleNamespace(**{"actionItems": [{"id": "4755377456414720", "text": "Steve needs to complete the analysis by next Monday.", "type": "action_item", "score": 0.9765610554943914, "messageIds": ["5590459222065152"], "entities":[{"type": "daterange", "text": "by next monday", "offset": 39, "end": "2021-06-07"}, {"type": "person", "text": "Steve", "offset": 0, "value": { + "assignee": True, "id": "98d11b11-4a0a-4bdd-b2e1-d50238f605d6", "name": "Steve", "userId": "Steve@example.com"}}], "phrases": [], "from":{"id": "98d11b11-4a0a-4bdd-b2e1-d50238f605d6", "name": "Steve", "userId": "Steve@example.com"}, "definitive": True, "assignee": {"id": "98d11b11-4a0a-4bdd-b2e1-d50238f605d6", "name": "Steve", "email": "Steve@example.com"}}]}) conversations_api = ConversationsApi() with patch("symbl.AuthenticationToken.get_api_client", Mock(return_value="None")), patch("symbl_rest.ConversationsApi.get_action_items_by_conversation_id", Mock(return_value=demo_response)): - self.assertEqual(demo_response, conversations_api.get_action_items("6549352073920512")) + self.assertEqual( + demo_response, conversations_api.get_action_items("6549352073920512")) def test_get_follow_ups_should_succeed_given_valid_conversation_id(self): - demo_response = SimpleNamespace(**{"followUps":[{"id":"4529863081852928","text":"Steve needs to follow up about this next Monday.","type":"follow_up","score":1,"messageIds":["5399026486738944"],"entities":[{"type":"date","text":"next monday","offset":38,"value":"2021-06-07"},{"type":"person","text":"Steve","offset":0,"value":{"assignee":True,"id":"e2219a6c-ec5e-4412-94d7-46f565ba5eb7","name":"Steve","userId":"Steve@example.com"}}],"phrases":[],"from":{"id":"e2219a6c-ec5e-4412-94d7-46f565ba5eb7","name":"Steve","userId":"Steve@example.com"},"definitive":True,"assignee":{"id":"e2219a6c-ec5e-4412-94d7-46f565ba5eb7","name":"Steve","email":"Steve@example.com"}}]}) + demo_response = SimpleNamespace(**{"followUps": [{"id": "4529863081852928", "text": "Steve needs to follow up about this next Monday.", "type": "follow_up", "score": 1, "messageIds": ["5399026486738944"], "entities":[{"type": "date", "text": "next monday", "offset": 38, "value": "2021-06-07"}, {"type": "person", "text": "Steve", "offset": 0, "value": { + "assignee": True, "id": "e2219a6c-ec5e-4412-94d7-46f565ba5eb7", "name": "Steve", "userId": "Steve@example.com"}}], "phrases": [], "from":{"id": "e2219a6c-ec5e-4412-94d7-46f565ba5eb7", "name": "Steve", "userId": "Steve@example.com"}, "definitive": True, "assignee": {"id": "e2219a6c-ec5e-4412-94d7-46f565ba5eb7", "name": "Steve", "email": "Steve@example.com"}}]}) conversations_api = ConversationsApi() with patch("symbl.AuthenticationToken.get_api_client", Mock(return_value="None")), patch("symbl_rest.ConversationsApi.get_follow_ups_by_conversation_id", Mock(return_value=demo_response)): - self.assertEqual(demo_response, conversations_api.get_follow_ups("6549352073920512")) + self.assertEqual( + demo_response, conversations_api.get_follow_ups("6549352073920512")) def test_get_members_should_succeed_given_valid_conversation_id(self): - demo_response = SimpleNamespace(**{"members":[{"id":"25f497bd-2800-4e2b-bc71-e143a8f71d6b","name":"Steve","email":"steve@abccorp.com"}]}) + demo_response = SimpleNamespace( + **{"members": [{"id": "25f497bd-2800-4e2b-bc71-e143a8f71d6b", "name": "Steve", "email": "steve@abccorp.com"}]}) conversations_api = ConversationsApi() with patch("symbl.AuthenticationToken.get_api_client", Mock(return_value="None")), patch("symbl_rest.ConversationsApi.get_members_by_conversation_id", Mock(return_value=demo_response)): - self.assertEqual(demo_response, conversations_api.get_members("6549352073920512")) + self.assertEqual( + demo_response, conversations_api.get_members("6549352073920512")) def test_get_questions_should_succeed_given_valid_conversation_id(self): - demo_response = SimpleNamespace(**{"questions":[{"id":"4784246146203648","text":"Will you be reviewint the analysis by next Monday?","type":"question","score":0.9833490590134427,"messageIds":["4580678118146048"],"from":{"id":"ca0fcd23-dc63-4d42-894a-43ca84650f6f","name":"Steve","userId":"Steve@example.com"}}]}) + demo_response = SimpleNamespace(**{"questions": [{"id": "4784246146203648", "text": "Will you be reviewint the analysis by next Monday?", "type": "question", "score": 0.9833490590134427, "messageIds": [ + "4580678118146048"], "from":{"id": "ca0fcd23-dc63-4d42-894a-43ca84650f6f", "name": "Steve", "userId": "Steve@example.com"}}]}) conversations_api = ConversationsApi() with patch("symbl.AuthenticationToken.get_api_client", Mock(return_value="None")), patch("symbl_rest.ConversationsApi.get_questions_by_conversation_id", Mock(return_value=demo_response)): - self.assertEqual(demo_response, conversations_api.get_questions("6549352073920512")) + self.assertEqual( + demo_response, conversations_api.get_questions("6549352073920512")) def test_get_topics_should_succeed_given_valid_conversation_id(self): - demo_response = SimpleNamespace(**{"topics":[{"id":"5506508885327872","text":"video","type":"topic","score":0.064,"messageIds":["5823121492803584","4673825691140096"],"parentRefs":[]}]}) + demo_response = SimpleNamespace(**{"topics": [{"id": "5506508885327872", "text": "video", "type": "topic", + "score": 0.064, "messageIds": ["5823121492803584", "4673825691140096"], "parentRefs":[]}]}) conversations_api = ConversationsApi() with patch("symbl.AuthenticationToken.get_api_client", Mock(return_value="None")), patch("symbl_rest.ConversationsApi.get_topics_by_conversation_id", Mock(return_value=demo_response)): - self.assertEqual(demo_response, conversations_api.get_topics("6549352073920512")) - + self.assertEqual( + demo_response, conversations_api.get_topics("6549352073920512")) + def test_get_conversation_should_succeed_given_valid_conversation_id(self): - demo_response = SimpleNamespace(**{"id": "5102778889273344","type": "meeting","name": "TestingTextAPI","startTime": "2021-07-27T07:11:04.304Z","endTime": "2021-07-27T07:13:19.184Z","members": [{"id": "461dd687-4341-48a5-9f3a-7f6019d6378c","name": "John","email": "john@example.com"}]}) + demo_response = SimpleNamespace(**{"id": "5102778889273344", "type": "meeting", "name": "TestingTextAPI", "startTime": "2021-07-27T07:11:04.304Z", + "endTime": "2021-07-27T07:13:19.184Z", "members": [{"id": "461dd687-4341-48a5-9f3a-7f6019d6378c", "name": "John", "email": "john@example.com"}]}) conversations_api = ConversationsApi() with patch("symbl.AuthenticationToken.get_api_client", Mock(return_value="None")), patch("symbl_rest.ConversationsApi.get_conversation_by_conversation_id", Mock(return_value=demo_response)): - self.assertEqual(demo_response, conversations_api.get_conversation("6549352073920512")) - + self.assertEqual( + demo_response, conversations_api.get_conversation("6549352073920512")) + def test_get_trackers_should_succeed_given_valid_conversation_id(self): - demo_response = SimpleNamespace(**{ "id": "5243525907087360", "name": "text_tracker", "matches": [ { "messageRefs": [ { "id": "5867975128121344", "text": "I don't know which platform is it, but I came to know that platform.", "offset": 19 }, { "id": "6328818106105856", "text": "So this is a live demo that we are trying to give very we are going to show how the platform detects various insights can do transcription in real time and also the different topics of discussions, which would be generated after the call is over, and they will be an email that will be sent to the inbox.", "offset": 84 } ], "type": "vocabulary", "value": "platform", "insightRefs": [] } ] }) + demo_response = SimpleNamespace(**{"id": "5243525907087360", "name": "text_tracker", "matches": [{"messageRefs": [{"id": "5867975128121344", "text": "I don't know which platform is it, but I came to know that platform.", "offset": 19}, { + "id": "6328818106105856", "text": "So this is a live demo that we are trying to give very we are going to show how the platform detects various insights can do transcription in real time and also the different topics of discussions, which would be generated after the call is over, and they will be an email that will be sent to the inbox.", "offset": 84}], "type": "vocabulary", "value": "platform", "insightRefs": []}]}) conversations_api = ConversationsApi() with patch("symbl.AuthenticationToken.get_api_client", Mock(return_value="None")), patch("symbl_rest.ConversationsApi.get_trackers_by_conversation_id", Mock(return_value=demo_response)): - self.assertEqual(demo_response, conversations_api.get_trackers("6549352073920512")) + self.assertEqual( + demo_response, conversations_api.get_trackers("6549352073920512")) def test_get_entities_should_succeed_given_valid_conversation_id(self): - demo_response = SimpleNamespace(**{"entities":[{"custom_type":"None","type":"person","value":"richard holmes","text":"richard holmes","end":"None","start":"None","messageRefs":[{"id":"5895830172073984","text":"We need to have the meeting today, and we're going to talk about how to run a product strategy Workshop is by Richard Holmes.","offset":111}]}]}) + demo_response = SimpleNamespace(**{"entities": [{"custom_type": "None", "type": "person", "value": "richard holmes", "text": "richard holmes", "end": "None", "start": "None", "messageRefs": [ + {"id": "5895830172073984", "text": "We need to have the meeting today, and we're going to talk about how to run a product strategy Workshop is by Richard Holmes.", "offset": 111}]}]}) conversations_api = ConversationsApi() with patch("symbl.AuthenticationToken.get_api_client", Mock(return_value="None")), patch("symbl_rest.ConversationsApi.get_entities_by_conversation_id", Mock(return_value=demo_response)), patch("symbl.utils.Helper.parse_entity_response", Mock(return_value=demo_response)): - self.assertEqual(demo_response, conversations_api.get_entities("6549352073920512")) + self.assertEqual( + demo_response, conversations_api.get_entities("6549352073920512")) def test_get_analytics_should_succeed_given_valid_conversation_id(self): - demo_response = SimpleNamespace(**{"metrics": [{"type": "total_silence","percent": 0,"seconds": 0},{"type": "total_talk_time","percent": 100,"seconds": 134.88},{"type": "total_overlap","percent": 0,"seconds": 0}],"members": [{"id": "461dd687-4341-48a5-9f3a-7f6019d6378c","name": "John","userId": "john@example.com","pace": {"wpm": 124},"talkTime": {"percentage": 100,"seconds": 134.88},"listenTime": {"percentage": 0,"seconds": 0},"overlap": {}}]}) + demo_response = SimpleNamespace(**{"metrics": [{"type": "total_silence", "percent": 0, "seconds": 0}, {"type": "total_talk_time", "percent": 100, "seconds": 134.88}, {"type": "total_overlap", "percent": 0, "seconds": 0}], "members": [ + {"id": "461dd687-4341-48a5-9f3a-7f6019d6378c", "name": "John", "userId": "john@example.com", "pace": {"wpm": 124}, "talkTime": {"percentage": 100, "seconds": 134.88}, "listenTime": {"percentage": 0, "seconds": 0}, "overlap": {}}]}) conversations_api = ConversationsApi() with patch("symbl.AuthenticationToken.get_api_client", Mock(return_value="None")), patch("symbl_rest.ConversationsApi.get_analytics_by_conversation_id", Mock(return_value=demo_response)): - self.assertEqual(demo_response, conversations_api.get_analytics("6549352073920512")) + self.assertEqual( + demo_response, conversations_api.get_analytics("6549352073920512")) + + def test_put_members_should_succeed_given_valid_conversation_id(self): + demo_response = SimpleNamespace( + **{"message": "Member with id: 1234567890 for conversationId: 6549352073920512 updated successfully! The update should be reflected in all messages and insights along with this conversation"}) + conversations_api = ConversationsApi() + + param = {"id": "1234567890", + "email": "john@example.in", + "name": "john"} + + with patch("symbl.AuthenticationToken.get_api_client", Mock(return_value="None")), patch("symbl_rest.ConversationsApi.put_members_information_by_members_id", Mock(return_value=demo_response)): + self.assertEqual(demo_response, conversations_api.put_members( + "6549352073920512", "1234567890", param)) + + def test_put_speakers_events_should_succeed_given_valid_conversation_id(self): + demo_response = SimpleNamespace( + **{"message": "Speaker events associated for conversationId: 6549352073920512 successfully! The update should be reflected in all messages and insights along with this conversation"}) + conversations_api = ConversationsApi() + + payload_streaming = { + "speakerEvents": [ + { + "type": "started_speaking", + "user": { + "id": "1234567890", + "name": "john", + "email": "john@example.com" + }, + "offset": { + "seconds": 52, + "nanos": 5000000000 + } + } + ] + } + + with patch("symbl.AuthenticationToken.get_api_client", Mock(return_value="None")), patch("symbl_rest.ConversationsApi.put_speakers_event_by_conversation_id", Mock(return_value=demo_response)): + self.assertEqual(demo_response, conversations_api.put_speakers_events( + "6549352073920512", payload_streaming)) + + def test_delete_conversation_should_succeed_given_valid_conversation_id(self): + demo_response = SimpleNamespace( + **{'message': 'successfully deleted the conversation'}) + conversations_api = ConversationsApi() + + with patch("symbl.AuthenticationToken.get_api_client", Mock(return_value="None")), patch("symbl_rest.ConversationsApi.delete_conversation_by_conversation_id", Mock(return_value=demo_response)): + self.assertEqual( + demo_response, conversations_api.delete_conversation("6549352073920512")) + + def test_get_formatted_transcript_should_succeed_given_valid_conversation_id(self): + demo_response = SimpleNamespace( + **{'transcript': {'content_type': 'text/markdown', 'payload': 'Natalia: Let us talk about India Australia'}}) + conversations_api = ConversationsApi() + + payload = { + 'contentType': 'text/markdown', + # 'contentType': 'text/srt', + 'createParagraphs': "true", + 'phrases': { + 'highlightOnlyInsightKeyPhrases': "true", + 'highlightAllKeyPhrases': "true" + }, + 'showSpeakerSeparation': "true" + } + with patch("symbl.AuthenticationToken.get_api_client", Mock(return_value="None")), patch("symbl_rest.ConversationsApi.get_formatted_transcript_by_conversation_id", Mock(return_value=demo_response)): + self.assertEqual( + demo_response, conversations_api.get_formatted_transcript("6549352073920512", parameters=payload)) + - if __name__ == '__main__': unittest.main() diff --git a/tests/conversations_test.py b/tests/conversations_test.py index 6d3324b..35e53de 100644 --- a/tests/conversations_test.py +++ b/tests/conversations_test.py @@ -57,14 +57,6 @@ def test_get_conversation_should_succeed_given_valid_conversation_id(self): with patch("symbl.AuthenticationToken.get_api_client", Mock(return_value="None")), patch("symbl.ConversationsApi.get_conversation", Mock(return_value=demo_response)): self.assertEqual(demo_response, conversations_object.get_conversation()) - - def test_get_analytics_should_succeed_given_valid_conversation_id(self): - demo_response = SimpleNamespace(**{"metrics": [{"type": "total_silence","percent": 0,"seconds": 0},{"type": "total_talk_time","percent": 100,"seconds": 134.88},{"type": "total_overlap","percent": 0,"seconds": 0}],"members": [{"id": "461dd687-4341-48a5-9f3a-7f6019d6378c","name": "John","userId": "john@example.com","pace": {"wpm": 124},"talkTime": {"percentage": 100,"seconds": 134.88},"listenTime": {"percentage": 0,"seconds": 0},"overlap": {}}]}) - conversations_object = Conversation("6549352073920512") - - with patch("symbl.AuthenticationToken.get_api_client", Mock(return_value="None")), patch("symbl.ConversationsApi.get_analytics", Mock(return_value=demo_response)): - self.assertEqual(demo_response, conversations_object.get_analytics()) - def test_get_trackers_should_succeed_given_valid_conversation_id(self): demo_response = SimpleNamespace(**{ "id": "5243525907087360", "name": "text_tracker", "matches": [ { "messageRefs": [ { "id": "5867975128121344", "text": "I don't know which platform is it, but I came to know that platform.", "offset": 19 }, { "id": "6328818106105856", "text": "So this is a live demo that we are trying to give very we are going to show how the platform detects various insights can do transcription in real time and also the different topics of discussions, which would be generated after the call is over, and they will be an email that will be sent to the inbox.", "offset": 84 } ], "type": "vocabulary", "value": "platform", "insightRefs": [] } ] }) conversations_object = Conversation("6549352073920512") @@ -86,6 +78,71 @@ def test_get_analytics_should_succeed_given_valid_conversation_id(self): with patch("symbl.AuthenticationToken.get_api_client", Mock(return_value="None")), patch("symbl.ConversationsApi.get_analytics", Mock(return_value=demo_response)): self.assertEqual(demo_response, conversations_object.get_analytics()) - + def test_put_members_should_succeed_given_valid_conversation_id(self): + demo_response = SimpleNamespace( + **{"message": "Member with id: 1234567890 for conversationId: 6549352073920512 updated successfully! The update should be reflected in all messages and insights along with this conversation"}) + conversations_object = Conversation("6549352073920512") + + param = {"id": "1234567890", + "email": "john@example.in", + "name": "john"} + + with patch("symbl.AuthenticationToken.get_api_client", Mock(return_value="None")), patch("symbl.ConversationsApi.put_members", Mock(return_value=demo_response)): + self.assertEqual(demo_response, conversations_object.put_members("1234567890", param)) + + def test_put_speakers_events_should_succeed_given_valid_conversation_id(self): + demo_response = SimpleNamespace( + **{"message": "Speaker events associated for conversationId: 6549352073920512 successfully! The update should be reflected in all messages and insights along with this conversation"}) + conversations_object = Conversation("6549352073920512") + + payload_streaming = { + "speakerEvents": [ + { + "type": "started_speaking", + "user": { + "id": "1234567890", + "name": "john", + "email": "john@example.com" + }, + "offset": { + "seconds": 52, + "nanos": 5000000000 + } + } + ] + } + + with patch("symbl.AuthenticationToken.get_api_client", Mock(return_value="None")), patch("symbl.ConversationsApi.put_speakers_events", Mock(return_value=demo_response)): + self.assertEqual(demo_response, conversations_object.put_speakers_events( payload_streaming)) + + def test_delete_conversation_should_succeed_given_valid_conversation_id(self): + demo_response = SimpleNamespace( + **{'message': 'successfully deleted the conversation'}) + conversations_object = Conversation("6549352073920512") + + with patch("symbl.AuthenticationToken.get_api_client", Mock(return_value="None")), patch("symbl.ConversationsApi.delete_conversation", Mock(return_value=demo_response)): + self.assertEqual( + demo_response, conversations_object.delete_conversation()) + + def test_get_formatted_transcript_should_succeed_given_valid_conversation_id(self): + demo_response = SimpleNamespace( + **{'transcript': {'content_type': 'text/markdown', 'payload': 'Natalia: Let us talk about India Australia'}}) + conversations_object = Conversation("6549352073920512") + + payload = { + 'contentType': 'text/markdown', + # 'contentType': 'text/srt', + 'createParagraphs': "true", + 'phrases': { + 'highlightOnlyInsightKeyPhrases': "true", + 'highlightAllKeyPhrases': "true" + }, + 'showSpeakerSeparation': "true" + } + with patch("symbl.AuthenticationToken.get_api_client", Mock(return_value="None")), patch("symbl.ConversationsApi.get_formatted_transcript", Mock(return_value=demo_response)): + self.assertEqual( + demo_response, conversations_object.get_formatted_transcript( parameters=payload)) + + if __name__ == '__main__': unittest.main()