Skip to content

Commit

Permalink
[ACS] Call Automation Initial Commit of Python SDK (Azure#29273)
Browse files Browse the repository at this point in the history
* Initial commit for Call Automation

* Fixed test and initial input

* boots trap for callautomation service client, call connection, media, and recording

* add recording methods and models

* Create methods and models for recognize, play, and cancelallmediaoperations (Azure#28944)

* add media client

* add empty call media client

* add media methods and models

* small fixes to get build working

* add playoptions param

* small fixes for play

* add filesource functionality

* updates after testing

* add recognize event models

* Juntuchen/callauotomationv4 (Azure#29059)

* updated swagger

* updated swagger readme.md

* updated swagger

* Event Parser for Python (Azure#29070)

* rebase

* missed merge conflicts

* Improved with casting of public event
Converting CommunicationIdentifier correctly

* trim unnessary changes

---------

Co-authored-by: Min Woo Lee 🧊 <[email protected]>

* update formatting for python (Azure#29086)

* remove non GA features

* Juntuchen/callauotomationv4 (Azure#29113)

* updated swagger

* updated swagger readme.md

* updated swagger

* added main client methods

* added signaling methods

* fixed the circular import issue (Azure#29118)

* fixed bug

* test

* updated deserialize_phone_identifier for processing the data correctly

* fixed create_group_call and added media options in create calls

* moved serializer to .model to avoid strange circular import issue

* bug fixed

* fixed bug in answer_call

* fixed bug

* updates in signaling methods

* Initial commit for Call Automation

* Fixed test and initial input

* boots trap for callautomation service client, call connection, media, and recording

* add recording methods and models

* Create methods and models for recognize, play, and cancelallmediaoperations (Azure#28944)

* add media client

* add empty call media client

* add media methods and models

* small fixes to get build working

* add playoptions param

* small fixes for play

* add filesource functionality

* updates after testing

* add recognize event models

* Juntuchen/callauotomationv4 (Azure#29059)

* updated swagger

* updated swagger readme.md

* updated swagger

* remove non GA features

* Event Parser for Python (Azure#29070)

* rebase

* missed merge conflicts

* Improved with casting of public event
Converting CommunicationIdentifier correctly

* trim unnessary changes

---------

Co-authored-by: Min Woo Lee 🧊 <[email protected]>

* update formatting for python (Azure#29086)

* Juntuchen/callauotomationv4 (Azure#29113)

* updated swagger

* updated swagger readme.md

* updated swagger

* added main client methods

* added signaling methods

* fixed the circular import issue (Azure#29118)

* fixed bug

* test

* updated deserialize_phone_identifier for processing the data correctly

* fixed create_group_call and added media options in create calls

* moved serializer to .model to avoid strange circular import issue

* bug fixed

* fixed bug in answer_call

* fixed bug

* updates in signaling methods

* Added ReadMe file

* communicationIdentifiers serializer refactor

* match dotnet sdk more closely (Azure#29250)

* match dotnet sdk more closely

* add missing peram

* Fixing spelling, setup config, added unit testings (Azure#29243)

* Fixing spelling, setup config, added unit testings

* Adding CI, Adding Test, Adding Sample, Adding Changelog, Fixing bunch of lint

* communicationIdentifiers serializer refactor

* match dotnet sdk more closely (Azure#29250)

* match dotnet sdk more closely

* add missing peram

* Fixing test, Fixing requirement, fixing cspell ignore, various small changes on lint

* Fixing spelling, setup config, added unit testings

* Adding CI, Adding Test, Adding Sample, Adding Changelog, Fixing bunch of lint

* Fixing test, Fixing requirement, fixing cspell ignore, various small changes on lint

* Fixing all Pylint recommandations

---------

Co-authored-by: Min Woo Lee 🧊 <[email protected]>
Co-authored-by: juntuchen <[email protected]>
Co-authored-by: Isura Kumarapeli <[email protected]>

* Fixing spelling, Fixing lint issues

* Fixing links, naming

* pr comments for recording (Azure#29294)

* pr comments for recording

* pr comments for recording

* Adding description for events

* update PR (Azure#29310)

* removing wrong place for events, adding all models used by dev

* fix CallMediaClient name and update getCallMedia description

* Adding new line

* fix client names

* Adding all utils, fixing pylint

---------

Co-authored-by: Min Woo Lee 🧊 <[email protected]>
Co-authored-by: ikumarapeli <[email protected]>
Co-authored-by: Adam Tazi <[email protected]>
Co-authored-by: Juntu Chen <[email protected]>
Co-authored-by: Isura Kumarapeli <[email protected]>
Co-authored-by: Adam Tazi <[email protected]>
Co-authored-by: juntuchen <[email protected]>
  • Loading branch information
8 people authored Mar 15, 2023
1 parent 744f4d0 commit 0435d4f
Show file tree
Hide file tree
Showing 68 changed files with 15,295 additions and 1 deletion.
17 changes: 17 additions & 0 deletions sdk/communication/azure-communication-callautomation/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Release History

## 1.0.0b1 (Unreleased)
Call Automation enables developers to build call workflows. Personalise customer interactions by listening to call events and take actions based on your business logic.

### Features Added
- Create outbound calls to an Azure Communication Service user or a phone number.
- Answer/Redirect/Reject incoming call from an Azure Communication Service user or a phone number.
- Transfer the call to another participant.
- List, add or remove participants from the call.
- Hangup or terminate the call.
- Play audio files to one or more participants in the call.
- Recognize incoming DTMF in the call.
- Record calls with option to start/resume/stop.
- Record mixed and unmixed audio recordings.
- Download recordings.
- Parse various events happening in the call, such as CallConnected and PlayCompleted event.
21 changes: 21 additions & 0 deletions sdk/communication/azure-communication-callautomation/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Copyright (c) Microsoft Corporation.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include *.md
include azure/__init__.py
include azure/communication/__init__.py
include LICENSE
recursive-include tests *.py
recursive-include samples *.py *.md
include azure/communication/callautomation/py.typed
118 changes: 118 additions & 0 deletions sdk/communication/azure-communication-callautomation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# Azure Communication Call Automation client library for Python

This package contains a Python SDK for Azure Communication Call Automation. Call Automation provides developers the ability to build server-based, intelligent call workflows, and call recording for voice and PSTN channels.

[Overview of Call Automation][overview] | [Product documentation][product_docs]

## _Disclaimer_
_Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For more information and questions, please
refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_

## Getting started
### Prerequisites
- Python 3.7 or later is required to use this package.
- You need an [Azure subscription][azure_sub] to use this package.
- A deployed Communication Services resource. You can use the [Azure Portal][azure_portal] or the [Azure PowerShell][azure_powershell] to set it up.

### Installing
Install the Azure Communication Service Call Automation SDK.

```bash
pip install azure-communication-callautomation
```

## Key concepts
| Name | Description |
| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| CallAutomationClient | `CallAutomationClient` is the primary interface for developers using this client library. It can be used to initiate calls by `createCall` or `answerCall`. |
| CallConnectionClient | `CallConnectionClient` represents a ongoing call. Once the call is established with `createCall` or `answerCall`, further actions can be performed for the call, such as `transfer` or `addParticipant`. |
| CallMediaClient | `CallMediaClient` can be used to do media related actions, such as `play`, to play media file. This can be retrieved from established `CallConnectionClient`. |
| CallRecordingClient | `CallRecordingClient` can be used to do recording related actions, such as `startRecording`. This can be retrieved from `CallAutomationClient`. |
| Callback Events | Callback events are events sent back during duration of the call. It gives information and state of the call, such as `CallConnected`. `CallbackUrl` must be provided during `createCall` and `answerCall`, and callback events will be sent to this url. You can use `callAutomationEventParser` to parse these events when it arrives. |
| Incoming Call Event | When incoming call happens (that can be answered with `answerCall`), incoming call eventgrid event will be sent. This is different from Callback events above, and should be setup on Azure portal. See [Incoming Call][incomingcall] for detail. |

## Examples
### Initialize CallAutomationClient
```Python
from azure.communication.callautomation import (CallAutomationClient)

# Your unique Azure Communication service endpoint
endpoint_url = '<ENDPOINT>'
client = new CallAutomationClient.from_connection_string(endpoint_url)
```

### Create Call
```Python
from azure.communication.callautomation import (
CallAutomationClient,
CallInvite,
CommunicationUserIdentifier
)

# target endpoint for ACS User
user = CommunicationUserIdentifier("8:acs:...")

# make invitation
call_invite = CallInvite(target=user)

# callback url to receive callback events
callback_url = "https://<MY-EVENT-HANDLER-URL>/events"

# send out the invitation, creating call
response = client.create_call(call_invite, callback_url)
```

### Play Media
```Python
# from callconnection of response above, play media of media file
my_file = FileSource(uri="https://<FILE-SOURCE>/<SOME-FILE>.wav")
const response = call_connection.get_call_media().play_to_all(my_file)
```

## Troubleshooting
## Next steps
- [Call Automation Overview][overview]
- [Incoming Call Concept][incomingcall]
- [Build a customer interaction workflow using Call Automation][build1]
- [Redirect inbound telephony calls with Call Automation][build2]
- [Quickstart: Play action][build3]
- [Quickstart: Recognize action][build4]
- [Read more about Call Recording in Azure Communication Services][recording1]
- [Record and download calls with Event Grid][recording2]

## Provide Feedback

If you encounter any bugs or have suggestions, please file an issue in the [Issues](https://github.com/Azure/azure-sdk-for-python/issues) section of the project

## Contributing

This project welcomes contributions and suggestions. Most contributions require
you to agree to a Contributor License Agreement (CLA) declaring that you have
the right to, and actually do, grant us the rights to use your contribution.
For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether
you need to provide a CLA and decorate the PR appropriately (e.g., label,
comment). Simply follow the instructions provided by the bot. You will only
need to do this once across all repos using our CLA.

This project has adopted the
[Microsoft Open Source Code of Conduct][code_of_conduct]. For more information,
see the Code of Conduct FAQ or contact [email protected] with any
additional questions or comments.

<!-- LINKS -->
[overview]: https://learn.microsoft.com/azure/communication-services/concepts/voice-video-calling/call-automation
[product_docs]: https://docs.microsoft.com/azure/communication-services/overview
[azure_cli]: https://docs.microsoft.com/cli/azure
[azure_sub]: https://azure.microsoft.com/free/
[azure_portal]: https://portal.azure.com
[azure_powershell]: https://docs.microsoft.com/powershell/module/az.communication/new-azcommunicationservice
[build_doc]: https://aka.ms/AzureSDKBundling
[incomingcall]: https://learn.microsoft.com/azure/communication-services/concepts/voice-video-calling/incoming-call-notification
[build1]: https://learn.microsoft.com/azure/communication-services/quickstarts/voice-video-calling/callflows-for-customer-interactions?pivots=programming-language-csha
[build2]: https://learn.microsoft.com/azure/communication-services/how-tos/call-automation-sdk/redirect-inbound-telephony-calls?pivots=programming-language-csharp
[build3]: https://learn.microsoft.com/azure/communication-services/quickstarts/voice-video-calling/play-action?pivots=programming-language-csharp
[build4]: https://learn.microsoft.com/azure/communication-services/quickstarts/voice-video-calling/recognize-action?pivots=programming-language-csharp
[recording1]: https://learn.microsoft.com/azure/communication-services/concepts/voice-video-calling/call-recording
[recording2]: https://learn.microsoft.com/azure/communication-services/quickstarts/voice-video-calling/get-started-call-recording?pivots=programming-language-csharp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__path__ = __import__('pkgutil').extend_path(__path__, __name__)
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
from ._version import VERSION
from ._call_connection_client import CallConnectionClient
from ._call_media_client import CallMediaClient
from ._call_recording_client import CallRecordingClient
from ._call_automation_client import (
CallAutomationClient,
AnswerCallResult,
CreateCallResult
)
from ._call_automation_event_parser import CallAutomationEventParser
from ._models import (
RecordingStateResponse,
StartRecordingOptions,
ServerCallLocator,
GroupCallLocator,
CallInvite,
RecordingFormat,
RecordingContent,
RecordingStorage,
RecordingChannel,
PlaySource,
FileSource,
CallMediaRecognizeOptions,
CallConnectionProperties,
CallParticipant,
CallMediaRecognizeDtmfOptions,
Gender,
DtmfTone,
CallRejectReason
)
from ._shared.models import (
CommunicationIdentifier,
PhoneNumberIdentifier,
MicrosoftTeamsUserIdentifier,
CommunicationUserIdentifier
)
from ._events import (
AddParticipantSucceeded,
AddParticipantFailed,
CallConnected,
CallDisconnected,
CallTransferAccepted,
CallTransferFailed,
ParticipantsUpdated,
RecordingStateChanged,
PlayCompleted,
PlayFailed,
PlayCanceled,
RecognizeCompleted,
RecognizeCanceled,
RecognizeFailed
)
from ._generated.models import (
GetParticipantsResponse,
TransferCallResponse,
AddParticipantResponse,
CustomContext,
RemoveParticipantResponse
)

__all__ = [
'CallAutomationClient',
'RecordingFormat',
'RecordingContent',
'RecordingStorage',
'RecordingChannel',
'CallConnectionClient',
'CallMediaClient',
'CallRecordingClient',
"StartRecordingOptions",
"RecordingStateResponse",
"ServerCallLocator",
"GroupCallLocator",
"CallAutomationEventParser",
"AddParticipantSucceeded",
"AddParticipantFailed",
"CallConnected",
"CallDisconnected",
"CallTransferAccepted",
"CallTransferFailed",
"ParticipantsUpdated",
"RecordingStateChanged",
"PlayCompleted",
"PlayFailed",
"PlayCanceled",
"RecognizeCompleted",
"RecognizeCanceled",
"RecognizeFailed",
"CallInvite",
"CommunicationIdentifier",
"CommunicationUserIdentifier",
"PhoneNumberIdentifier",
"MicrosoftTeamsUserIdentifier",
"PlaySource",
"FileSource",
"CallMediaRecognizeOptions",
"CallMediaRecognizeDtmfOptions",
"AnswerCallResult",
"CreateCallResult",
"CallConnectionProperties",
"CallParticipant",
"GetParticipantsResponse",
"TransferCallResponse",
"AddParticipantResponse",
"CustomContext",
"RemoveParticipantResponse",
"Gender",
"DtmfTone",
"CallRejectReason"
]
__version__ = VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# ------------------------------------
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------

from enum import Enum
from azure.core import CaseInsensitiveEnumMeta

class ApiVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta):
V2023_01_15_PREVIEW = "2023-01-15-preview"

DEFAULT_VERSION = ApiVersion.V2023_01_15_PREVIEW
Loading

0 comments on commit 0435d4f

Please sign in to comment.