-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
496 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,8 @@ | ||
.abstra | ||
|
||
.git | ||
.gitignore | ||
|
||
__pycache__ | ||
.venv | ||
.env |
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,208 @@ | ||
{ | ||
"workspace": { | ||
"id": null, | ||
"name": "Untitled Workspace", | ||
"theme": "#f9f9f9", | ||
"logo_url": "logo.png", | ||
"brand_name": "Credit Requests", | ||
"main_color": "#0023FF", | ||
"font_color": null, | ||
"font_family": "Inter", | ||
"sidebar": [ | ||
{ | ||
"id": "order-request-form", | ||
"name": "Order request form", | ||
"path": "order-request-form", | ||
"type": "form", | ||
"visible": false | ||
} | ||
] | ||
}, | ||
"visualization": [], | ||
"jobs": [], | ||
"hooks": [], | ||
"forms": [ | ||
{ | ||
"id": "sjwgs1v", | ||
"path": "order-request-form", | ||
"title": "Order request form", | ||
"is_initial": true, | ||
"auto_start": true, | ||
"allow_restart": false, | ||
"end_message": "", | ||
"start_message": null, | ||
"error_message": null, | ||
"welcome_title": null, | ||
"timeout_message": null, | ||
"start_button_text": null, | ||
"restart_button_text": null, | ||
"file": "order_request_form.py", | ||
"workflow_position": [ | ||
-495.96128921678525, | ||
-6.976191032314148 | ||
], | ||
"transitions": [ | ||
{ | ||
"target_id": "38a7lgt", | ||
"target_type": "scripts", | ||
"type": "forms:finished", | ||
"id": "npdfozm", | ||
"condition_value": null | ||
} | ||
], | ||
"notification_trigger": { | ||
"variable_name": "assignee_emails", | ||
"enabled": false | ||
} | ||
}, | ||
{ | ||
"id": "ghw9tnr", | ||
"path": "avaliacao-manual", | ||
"title": "Manual review", | ||
"is_initial": false, | ||
"auto_start": true, | ||
"allow_restart": false, | ||
"end_message": null, | ||
"start_message": null, | ||
"error_message": null, | ||
"welcome_title": null, | ||
"timeout_message": null, | ||
"start_button_text": null, | ||
"restart_button_text": null, | ||
"file": "manual_review.py", | ||
"workflow_position": [ | ||
747.980343031676, | ||
332.94062523175563 | ||
], | ||
"transitions": [ | ||
{ | ||
"target_id": "wu5q957", | ||
"target_type": "conditions", | ||
"type": "forms:finished", | ||
"id": "idrhvv6", | ||
"condition_value": null | ||
} | ||
], | ||
"notification_trigger": { | ||
"variable_name": "assignee_emails", | ||
"enabled": false | ||
} | ||
} | ||
], | ||
"scripts": [ | ||
{ | ||
"id": "38a7lgt", | ||
"file": "credit_engine.py", | ||
"title": "Credit engine", | ||
"is_initial": false, | ||
"workflow_position": [ | ||
-21.516466301152263, | ||
-9.228763364173403 | ||
], | ||
"transitions": [ | ||
{ | ||
"target_id": "3q5z75h", | ||
"target_type": "conditions", | ||
"type": "scripts:finished", | ||
"id": "codl8b3", | ||
"condition_value": null | ||
} | ||
] | ||
}, | ||
{ | ||
"id": "3v0sim3", | ||
"file": "automatic_review.py", | ||
"title": "Automatic review", | ||
"is_initial": false, | ||
"workflow_position": [ | ||
742.9116684583314, | ||
-301.51229084557326 | ||
], | ||
"transitions": [ | ||
{ | ||
"target_id": "wu5q957", | ||
"target_type": "conditions", | ||
"type": "scripts:finished", | ||
"id": "3qrrazy", | ||
"condition_value": null | ||
} | ||
] | ||
}, | ||
{ | ||
"id": "o9t6hqu", | ||
"file": "internal_notification.py", | ||
"title": "Internal notification", | ||
"is_initial": false, | ||
"workflow_position": [ | ||
1449.9245064045638, | ||
322.9532944691653 | ||
], | ||
"transitions": [] | ||
}, | ||
{ | ||
"id": "8wmhiw2", | ||
"file": "approval_email.py", | ||
"title": "Approval email", | ||
"is_initial": false, | ||
"workflow_position": [ | ||
1437.9654417219867, | ||
-309.5427547615571 | ||
], | ||
"transitions": [] | ||
} | ||
], | ||
"iterators": [], | ||
"conditions": [ | ||
{ | ||
"id": "3q5z75h", | ||
"title": "Policy", | ||
"variable_name": "score", | ||
"workflow_position": [ | ||
419.7356788709259, | ||
-11.319859231601697 | ||
], | ||
"transitions": [ | ||
{ | ||
"target_id": "3v0sim3", | ||
"target_type": "scripts", | ||
"type": "conditions:patternMatched", | ||
"id": "n3tqsuu", | ||
"condition_value": "high" | ||
}, | ||
{ | ||
"target_id": "ghw9tnr", | ||
"target_type": "forms", | ||
"type": "conditions:patternMatched", | ||
"id": "zynkj4i", | ||
"condition_value": "low" | ||
} | ||
] | ||
}, | ||
{ | ||
"id": "wu5q957", | ||
"title": "Result", | ||
"variable_name": "result", | ||
"workflow_position": [ | ||
1062.9761368937448, | ||
2.0342768127167687 | ||
], | ||
"transitions": [ | ||
{ | ||
"target_id": "o9t6hqu", | ||
"target_type": "scripts", | ||
"type": "conditions:patternMatched", | ||
"id": "kj53whe", | ||
"condition_value": "rejected" | ||
}, | ||
{ | ||
"target_id": "8wmhiw2", | ||
"target_type": "scripts", | ||
"type": "conditions:patternMatched", | ||
"id": "uqama2r", | ||
"condition_value": "approved" | ||
} | ||
] | ||
} | ||
], | ||
"version": "4.0" | ||
} |
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 @@ | ||
{"workspace": {"id": null, "name": "Untitled Workspace", "theme": "#f9f9f9", "logo_url": "logo.png", "brand_name": "", "main_color": "#0023FF", "font_color": null, "font_family": "Inter", "sidebar": [{"id": "formulario-de-pedido", "name": "Formul\u00e1rio de Pedido", "path": "formulario-de-pedido", "type": "form", "visible": false}, {"id": "avaliacao-manual", "name": "Avalia\u00e7\u00e3o manual", "path": "avaliacao-manual", "type": "form", "visible": false}]}, "visualization": [], "jobs": [], "hooks": [], "forms": [{"id": "sjwgs1v", "path": "formulario-de-pedido", "title": "Formul\u00e1rio de Pedido", "is_initial": true, "auto_start": true, "allow_restart": false, "end_message": "", "start_message": null, "error_message": null, "welcome_title": null, "timeout_message": null, "start_button_text": null, "restart_button_text": null, "file": "formulario_de_pedido.py", "workflow_position": [-495.96128921678525, -6.976191032314148], "transitions": [{"target_id": "38a7lgt", "target_type": "scripts", "type": "forms:finished", "id": "npdfozm", "condition_value": null}]}, {"id": "ghw9tnr", "path": "avaliacao-manual", "title": "Avalia\u00e7\u00e3o manual", "is_initial": true, "auto_start": true, "allow_restart": false, "end_message": null, "start_message": null, "error_message": null, "welcome_title": null, "timeout_message": null, "start_button_text": null, "restart_button_text": null, "file": "avaliacao_manual.py", "workflow_position": [747.980343031676, 332.94062523175563], "transitions": [{"target_id": "wu5q957", "target_type": "conditions", "type": "forms:finished", "id": "idrhvv6", "condition_value": null}]}], "scripts": [{"id": "38a7lgt", "file": "motor_de_credito.py", "title": "Motor de cr\u00e9dito", "is_initial": false, "workflow_position": [-22.94615588579336, -9.228763364173403], "transitions": [{"target_id": "3q5z75h", "target_type": "conditions", "type": "scripts:finished", "id": "codl8b3", "condition_value": null}]}, {"id": "3v0sim3", "file": "avaliacao_automatica.py", "title": "Avalia\u00e7\u00e3o autom\u00e1tica", "is_initial": true, "workflow_position": [742.9116684583314, -301.51229084557326], "transitions": [{"target_id": "wu5q957", "target_type": "conditions", "type": "scripts:finished", "id": "3qrrazy", "condition_value": null}]}, {"id": "o9t6hqu", "file": "notificacao_interna.py", "title": "Notifica\u00e7\u00e3o interna", "is_initial": true, "workflow_position": [1449.9245064045638, 322.9532944691653], "transitions": []}, {"id": "8wmhiw2", "file": "email_de_aprovacao.py", "title": "Email de aprova\u00e7\u00e3o", "is_initial": true, "workflow_position": [1437.9654417219867, -309.5427547615571], "transitions": []}], "iterators": [], "conditions": [{"id": "3q5z75h", "title": "Pol\u00edtica", "variable_name": "score", "workflow_position": [419.7356788709259, -11.319859231601697], "transitions": [{"target_id": "3v0sim3", "target_type": "scripts", "type": "conditions:patternMatched", "id": "n3tqsuu", "condition_value": "alto"}, {"target_id": "ghw9tnr", "target_type": "forms", "type": "conditions:patternMatched", "id": "zynkj4i", "condition_value": "baixo"}]}, {"id": "wu5q957", "title": "Resultado", "variable_name": "resultado", "workflow_position": [1062.9761368937448, 2.0342768127167687], "transitions": [{"target_id": "o9t6hqu", "target_type": "scripts", "type": "conditions:patternMatched", "id": "kj53whe", "condition_value": "reprovado"}, {"target_id": "8wmhiw2", "target_type": "scripts", "type": "conditions:patternMatched", "id": "uqama2r", "condition_value": "aprovado"}]}], "version": "3.0"} |
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,65 @@ | ||
from abstra.workflows import * | ||
import os | ||
from sendgrid import SendGridAPIClient | ||
from sendgrid.helpers.mail import * | ||
from dotenv import load_dotenv | ||
|
||
load_dotenv() | ||
sendgrid_token = os.environ.get("SENDGRID_API_KEY") | ||
sender_email = os.environ.get('SENDER_EMAIL') | ||
|
||
name = get_data("name") | ||
fname = name.split(" ")[0] | ||
email = get_data("email") | ||
income = get_data("income") | ||
employer = get_data("employer") | ||
loan_amount = get_data("loan_amount") | ||
installments = get_data("installments") | ||
score = get_data("score") | ||
result = get_data("result") | ||
|
||
html = f""" | ||
<html> | ||
<head> | ||
<style> | ||
.header-text {{ | ||
font-size: 20px; | ||
font-weight: bold; | ||
color: #333; | ||
text-align: left; | ||
}} | ||
.paragraph-text {{ | ||
font-size: 12px; | ||
color: #555; | ||
text-align: left; | ||
margin: 20px 0; | ||
}} | ||
</style> | ||
</head> | ||
<body> | ||
<div style="text-align: left; margin: 20px 0;"> | ||
<img src="https://abstracloud-webflow-assets.s3.amazonaws.com/3750logo.png" width=200px> | ||
</div> | ||
<div class="header-text"> | ||
{fname}, good news 🤑 | ||
</div> | ||
<div class="paragraph-text"> | ||
Your loan of $ {loan_amount:,.2f} has been approved! 💸💸 | ||
We will contact you soon to finalize the process. | ||
</div> | ||
</body> | ||
</html> | ||
""" | ||
|
||
message = Mail( | ||
from_email=From(sender_email, "Scranton Credit [Abstra Example]"), | ||
to_emails=email, | ||
subject=f"Loan approved, {fname}", | ||
html_content=html) | ||
|
||
sg = SendGridAPIClient(sendgrid_token) | ||
response = sg.send(message) | ||
|
||
print(response.status_code) |
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,18 @@ | ||
from abstra.workflows import get_data, set_data | ||
from time import sleep | ||
|
||
name = get_data("name") | ||
email = get_data("email") | ||
income = get_data("income") | ||
employer = get_data("employer") | ||
loan_amount = get_data("loan_amount") | ||
installments = get_data("installments") | ||
score = get_data("score") | ||
|
||
if loan_amount < 100000000: | ||
set_data("result", "approved") | ||
else: | ||
set_data("result", "rejected") | ||
set_data("rejection_reason", "Loan amount too high") | ||
|
||
sleep(10) |
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,17 @@ | ||
from abstra.workflows import get_data, set_data | ||
from time import sleep | ||
|
||
name = get_data("name") | ||
email = get_data("email") | ||
income = get_data("income") | ||
employer = get_data("employer") | ||
loan_amount = get_data("loan_amount") | ||
installments = get_data("installments") | ||
|
||
if loan_amount > income * 0.3: | ||
set_data("score", "low") | ||
set_data("reason_low_score", "Value of the loan greater than 1/3 of the income") | ||
else: | ||
set_data("score", "high") | ||
|
||
sleep(10) |
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 @@ | ||
from abstra.workflows import get_data | ||
from dotenv import load_dotenv | ||
import os | ||
import requests | ||
|
||
load_dotenv() | ||
slack_token = os.environ.get("SLACK_BOT_TOKEN") | ||
|
||
name = get_data("name") | ||
email = get_data("email") | ||
income = get_data("income") | ||
employer = get_data("employer") | ||
loan_amount = get_data("loan_amount") | ||
installments = get_data("installments") | ||
score = get_data("score") | ||
result = get_data("result") | ||
rejection_reason = get_data("rejection_reason") | ||
reviewing_user = get_data("reviewing_user") | ||
|
||
res = requests.post( | ||
'https://slack.com/api/chat.postMessage', | ||
json={ | ||
'channel': 'credit-onboarding-example', | ||
'text': f""" | ||
💰🚫 New loan request denied. Information: | ||
- *Name*: {name}, | ||
- *Email*: {email}, | ||
- *Declared income*: ${income:,.2f}, | ||
- *Employer*: {employer}, | ||
- *Loan amount*: ${loan_amount:,.2f}, | ||
- *Number of installments*: {installments}, | ||
- *Score*: {score}, | ||
- *Reason for rejection*: {rejection_reason} | ||
- *Reviewer*: {reviewing_user} | ||
"""}, | ||
headers={ | ||
'Authorization': 'Bearer ' + slack_token, | ||
'Content-type': 'application/json; charset=utf-8' | ||
}) | ||
|
||
print(res) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.