Skip to content

Commit

Permalink
include only non ui changes
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderGi committed Jul 8, 2024
1 parent 553b92c commit 45f75b1
Show file tree
Hide file tree
Showing 6 changed files with 893 additions and 0 deletions.
19 changes: 19 additions & 0 deletions bots/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,21 @@
"slack_create_personal_channels",
]
web_fields = ["web_allowed_origins", "web_config_extras"]
twilio_fields = [
"twilio_account_sid",
"twilio_auth_token",
"twilio_phone_number",
"twilio_phone_number_sid",
"twilio_default_to_gooey_asr",
"twilio_default_to_gooey_tts",
"twilio_voice",
"twilio_asr_language",
"twilio_initial_text",
"twilio_initial_audio_url",
"twilio_use_missed_call",
"twilio_waiting_audio_url",
"twilio_waiting_text",
]


class BotIntegrationAdminForm(forms.ModelForm):
Expand Down Expand Up @@ -132,12 +147,14 @@ class BotIntegrationAdmin(admin.ModelAdmin):
"slack_channel_name",
"slack_channel_hook_url",
"slack_access_token",
"twilio_phone_number",
]
list_display = [
"name",
"get_display_name",
"platform",
"wa_phone_number",
"twilio_phone_number",
"created_at",
"updated_at",
"billing_account_uid",
Expand Down Expand Up @@ -192,6 +209,7 @@ class BotIntegrationAdmin(admin.ModelAdmin):
*wa_fields,
*slack_fields,
*web_fields,
*twilio_fields,
]
},
),
Expand Down Expand Up @@ -491,6 +509,7 @@ class ConversationAdmin(admin.ModelAdmin):
"slack_user_name",
"slack_channel_id",
"slack_channel_name",
"twilio_phone_number",
] + [f"bot_integration__{field}" for field in BotIntegrationAdmin.search_fields]
actions = [export_to_csv, export_to_excel]

Expand Down
108 changes: 108 additions & 0 deletions bots/migrations/0076_botintegration_twilio_account_sid_and_more.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# Generated by Django 4.2.7 on 2024-07-04 09:17

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('bots', '0075_alter_publishedrun_workflow_alter_savedrun_workflow_and_more'),
]

operations = [
migrations.AddField(
model_name='botintegration',
name='twilio_account_sid',
field=models.TextField(blank=True, default='', help_text='Twilio account sid as found on twilio.com/console (mandatory)'),
),
migrations.AddField(
model_name='botintegration',
name='twilio_asr_language',
field=models.TextField(default='en-US', help_text='The language to use for Twilio ASR (https://www.twilio.com/docs/voice/twiml/gather#languagetags)'),
),
migrations.AddField(
model_name='botintegration',
name='twilio_auth_token',
field=models.TextField(blank=True, default='', help_text='Twilio auth token as found on twilio.com/console (mandatory)'),
),
migrations.AddField(
model_name='botintegration',
name='twilio_default_to_gooey_asr',
field=models.BooleanField(default=False, help_text="If true, the bot will use Gooey ASR for speech recognition instead of Twilio's when available on the attached run"),
),
migrations.AddField(
model_name='botintegration',
name='twilio_default_to_gooey_tts',
field=models.BooleanField(default=False, help_text="If true, the bot will use Gooey TTS for text to speech instead of Twilio's when available on the attached run"),
),
migrations.AddField(
model_name='botintegration',
name='twilio_initial_audio_url',
field=models.TextField(blank=True, default='', help_text='The initial audio url to play to the user when a call is started'),
),
migrations.AddField(
model_name='botintegration',
name='twilio_initial_text',
field=models.TextField(blank=True, default='', help_text='The initial text to send to the user when a call is started'),
),
migrations.AddField(
model_name='botintegration',
name='twilio_phone_number',
field=models.TextField(blank=True, default='', help_text='Twilio unformatted phone number as found on twilio.com/console/phone-numbers/incoming (mandatory)'),
),
migrations.AddField(
model_name='botintegration',
name='twilio_phone_number_sid',
field=models.TextField(blank=True, default='', help_text='Twilio phone number sid as found on twilio.com/console/phone-numbers/incoming (mandatory)'),
),
migrations.AddField(
model_name='botintegration',
name='twilio_use_missed_call',
field=models.BooleanField(default=False, help_text="If true, the bot will reject incoming calls and call back the user instead so they don't get charged for the call"),
),
migrations.AddField(
model_name='botintegration',
name='twilio_voice',
field=models.TextField(default='woman', help_text="The voice to use for Twilio TTS ('man', 'woman', or Amazon Polly/Google Voices: https://www.twilio.com/docs/voice/twiml/say/text-speech#available-voices-and-languages)"),
),
migrations.AddField(
model_name='botintegration',
name='twilio_waiting_audio_url',
field=models.TextField(blank=True, default='', help_text='The audio url to play to the user while waiting for a response if using voice'),
),
migrations.AddField(
model_name='botintegration',
name='twilio_waiting_text',
field=models.TextField(blank=True, default='', help_text='The text to send to the user while waiting for a response if using sms'),
),
migrations.AddField(
model_name='conversation',
name='twilio_phone_number',
field=models.TextField(blank=True, default='', help_text="User's Twilio phone number (mandatory)"),
),
migrations.AlterField(
model_name='botintegration',
name='platform',
field=models.IntegerField(choices=[(1, 'Facebook Messenger'), (2, 'Instagram'), (3, 'WhatsApp'), (4, 'Slack'), (5, 'Web'), (6, 'Twilio')], help_text='The platform that the bot is integrated with'),
),
migrations.AlterField(
model_name='workflowmetadata',
name='default_image',
field=models.URLField(blank=True, default='', help_text='Image shown on explore page'),
),
migrations.AlterField(
model_name='workflowmetadata',
name='help_url',
field=models.URLField(blank=True, default='', help_text='(Not implemented)'),
),
migrations.AlterField(
model_name='workflowmetadata',
name='meta_keywords',
field=models.JSONField(blank=True, default=list, help_text='(Not implemented)'),
),
migrations.AlterField(
model_name='workflowmetadata',
name='short_title',
field=models.TextField(help_text='Title used in breadcrumbs'),
),
]
72 changes: 72 additions & 0 deletions bots/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,14 @@ class Platform(models.IntegerChoices):
WHATSAPP = (3, "WhatsApp")
SLACK = (4, "Slack")
WEB = (5, "Web")
TWILIO = (6, "Twilio")

def get_icon(self):
match self:
case Platform.WEB:
return f'<i class="fa-regular fa-globe"></i>'
case Platform.TWILIO:
return f'<img src="https://storage.googleapis.com/dara-c1b52.appspot.com/daras_ai/media/73d11836-3988-11ef-9e06-02420a00011a/favicon-32x32.png" style="height: 1.2em; vertical-align: middle;">'
case _:
return f'<i class="fa-brands fa-{self.name.lower()}"></i>'

Expand Down Expand Up @@ -605,6 +608,67 @@ class BotIntegration(models.Model):
help_text="Extra configuration for the bot's web integration",
)

twilio_account_sid = models.TextField(
blank=True,
default="",
help_text="Twilio account sid as found on twilio.com/console (mandatory)",
)
twilio_auth_token = models.TextField(
blank=True,
default="",
help_text="Twilio auth token as found on twilio.com/console (mandatory)",
)
twilio_phone_number = models.TextField(
blank=True,
default="",
help_text="Twilio unformatted phone number as found on twilio.com/console/phone-numbers/incoming (mandatory)",
)
twilio_phone_number_sid = models.TextField(
blank=True,
default="",
help_text="Twilio phone number sid as found on twilio.com/console/phone-numbers/incoming (mandatory)",
)
twilio_default_to_gooey_asr = models.BooleanField(
default=False,
help_text="If true, the bot will use Gooey ASR for speech recognition instead of Twilio's when available on the attached run",
)
twilio_default_to_gooey_tts = models.BooleanField(
default=False,
help_text="If true, the bot will use Gooey TTS for text to speech instead of Twilio's when available on the attached run",
)
twilio_voice = models.TextField(
default="woman",
help_text="The voice to use for Twilio TTS ('man', 'woman', or Amazon Polly/Google Voices: https://www.twilio.com/docs/voice/twiml/say/text-speech#available-voices-and-languages)",
)
twilio_initial_text = models.TextField(
default="",
blank=True,
help_text="The initial text to send to the user when a call is started",
)
twilio_initial_audio_url = models.TextField(
default="",
blank=True,
help_text="The initial audio url to play to the user when a call is started",
)
twilio_use_missed_call = models.BooleanField(
default=False,
help_text="If true, the bot will reject incoming calls and call back the user instead so they don't get charged for the call",
)
twilio_waiting_audio_url = models.TextField(
default="",
blank=True,
help_text="The audio url to play to the user while waiting for a response if using voice",
)
twilio_waiting_text = models.TextField(
default="",
blank=True,
help_text="The text to send to the user while waiting for a response if using sms",
)
twilio_asr_language = models.TextField(
default="en-US",
help_text="The language to use for Twilio ASR (https://www.twilio.com/docs/voice/twiml/gather#languagetags)",
)

streaming_enabled = models.BooleanField(
default=False,
help_text="If set, the bot will stream messages to the frontend (Slack & Web only)",
Expand Down Expand Up @@ -650,6 +714,7 @@ def get_display_name(self):
or " | #".join(
filter(None, [self.slack_team_name, self.slack_channel_name])
)
or self.twilio_phone_number
or self.name
or (
self.platform == Platform.WEB
Expand Down Expand Up @@ -945,6 +1010,12 @@ class Conversation(models.Model):
help_text="Whether this is a personal slack channel between the bot and the user",
)

twilio_phone_number = models.TextField(
blank=True,
default="",
help_text="User's Twilio phone number (mandatory)",
)

web_user_id = models.CharField(
max_length=512,
blank=True,
Expand Down Expand Up @@ -990,6 +1061,7 @@ def get_display_name(self):
or self.fb_page_id
or self.slack_user_id
or self.web_user_id
or self.twilio_phone_number
)

get_display_name.short_description = "User"
Expand Down
Loading

0 comments on commit 45f75b1

Please sign in to comment.