-
Notifications
You must be signed in to change notification settings - Fork 350
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #818 from PrefectHQ/call-routing
Add call routing example
- Loading branch information
Showing
3 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 @@ | ||
# Customer call routing | ||
|
||
Automatically route customer calls to the right department. | ||
|
||
!!! example "Call routing" | ||
```python | ||
import marvin | ||
from enum import Enum | ||
|
||
|
||
class Department(Enum): | ||
SALES = "sales" | ||
SUPPORT = "support" | ||
BILLING = "billing" | ||
|
||
|
||
# define a convenience function | ||
def route_call(transcript: str) -> Department: | ||
return marvin.classify( | ||
transcript, | ||
labels=Department, | ||
instructions="Select the best department for the customer request", | ||
) | ||
``` | ||
|
||
!!! success "💳 Update payment method" | ||
```python | ||
department = route_call("I need to update my payment method") | ||
assert department == Department.BILLING | ||
``` | ||
|
||
!!! success "💵 Price matching" | ||
```python | ||
department = route_call("Well FooCo offered me a better deal") | ||
assert department == Department.SALES | ||
``` | ||
|
||
!!! success "🤬 Angry noises" | ||
```python | ||
department = route_call("*angry noises*") | ||
assert department == Department.SUPPORT | ||
``` |
This file contains 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 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