Skip to content

Instantly share code, notes, and snippets.

View DanyF-github's full-sized avatar

Daniela Facchinetti DanyF-github

View GitHub Profile
.container {
max-width: 500 !important;
margin: auto;
margin-top: 4%;
letter-spacing: 0.5px;
}
.msg-header {
border: 1px solid #ccc;
width: 100%;
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')),
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"),
]
@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)
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
= 'sales_fox.routing.application'
channels.routing import ProtocolTypeRouter, URLRouter
from channels.auth import AuthMiddlewareStack
from conversation import routing
application = ProtocolTypeRouter({
'websocket': AuthMiddlewareStack(URLRouter(
routing.websocket_urlpatterns
)),
})
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):
django.urls import re_path
from .consumers import ConversationConsumer
websocket_urlpatterns = [
re_path(r'ws/conversation/(?P<lead_id>\d+)/$', ConversationConsumer),
]
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