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
.container { | |
max-width: 500 !important; | |
margin: auto; | |
margin-top: 4%; | |
letter-spacing: 0.5px; | |
} | |
.msg-header { | |
border: 1px solid #ccc; | |
width: 100%; |
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
django.contrib import admin | |
from django.conf import settings | |
from django.conf.urls.static import static | |
from django.urls import path, include | |
from lead_manager.views import HomeView | |
urlpatterns = [ | |
path('admin/', admin.site.urls), | |
path('leads/', include('lead_manager.urls', namespace='lead_manager')), | |
path('agent/', include('lead_manager.agent.urls', namespace='agent')), |
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
django.urls import path | |
from .views import inbound, status, lead_conversation_room | |
app_name = 'conversation' | |
urlpatterns = [ | |
path('inbound/', inbound, name='conversation-inbound'), | |
path('status/', status, name='conversation-status'), | |
path('lead/<int:lead_id>/', lead_conversation_room, name="lead-conversation-room"), | |
] |
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
@require_POST | |
@csrf_exempt | |
def status(request): | |
body = json.loads(request.body) | |
with open('status.txt', 'w') as status_file: | |
json.dump(body, status_file) | |
return HttpResponse(status=204) |
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
channels.layers import get_channel_layer | |
from asgiref.sync import async_to_sync | |
from django.views.decorators.http import require_POST | |
from django.views.decorators.csrf import csrf_exempt | |
from django.contrib.contenttypes.models import ContentType | |
from lead_manager.models import Lead | |
from .models import Message | |
@require_POST |
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
= 'sales_fox.routing.application' |
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
channels.routing import ProtocolTypeRouter, URLRouter | |
from channels.auth import AuthMiddlewareStack | |
from conversation import routing | |
application = ProtocolTypeRouter({ | |
'websocket': AuthMiddlewareStack(URLRouter( | |
routing.websocket_urlpatterns | |
)), | |
}) |
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
json | |
from channels.generic.websocket import WebsocketConsumer | |
from asgiref.sync import async_to_sync | |
from django.contrib.contenttypes.models import ContentType | |
from .models import Message | |
from .views import send_outbound | |
from lead_manager.models import Lead, Agent | |
def create_conversation_group(convo_id): |
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
django.urls import re_path | |
from .consumers import ConversationConsumer | |
websocket_urlpatterns = [ | |
re_path(r'ws/conversation/(?P<lead_id>\d+)/$', ConversationConsumer), | |
] |
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
django.conf import settings | |
import requests | |
import json | |
import base64 | |
from requests.exceptions import ConnectionError | |
def send_outbound(message, lead_facebook_id): | |
url = settings.VONAGE_MESSAGES_ENDPOINT | |
auth_param = settings.VONAGE_API_KEY + ":" + settings.VONAGE_API_SECRET |