-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP] Working in the voice flow, to control how incoming calls are ha…
…ndled
- Loading branch information
1 parent
7167e7e
commit 0d316df
Showing
9 changed files
with
264 additions
and
53 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
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
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 |
---|---|---|
@@ -1,2 +1,6 @@ | ||
# © 2018 Danimar Ribeiro <danimaibeiro@gmail.com> | ||
# © 2018 Danimar Ribeiro <danimaribeiro@gmail.com> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) | ||
|
||
|
||
from . import twilio_voice_call | ||
from . import voice_flow |
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,57 @@ | ||
# © 2018 Danimar Ribeiro <danimaribeiro@gmail.com> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) | ||
|
||
from datetime import datetime | ||
from odoo import fields, models | ||
|
||
|
||
class TwilioVoiceCall(models.Model): | ||
_name = 'twilio.voice.call' | ||
_description = 'Voice Call from Twilio' | ||
|
||
name = fields.Char(string="Name", size=50, required=True) | ||
sid = fields.Char(string="Unique Identifier", size=40, readonly=True) | ||
calling_date = fields.Datetime('Calling Date') | ||
type = fields.Selection([('inbound', 'Inbound'), | ||
('outbound', 'Outbound')]) | ||
from_number = fields.Char(string="From") | ||
to_number = fields.Char(string="To") | ||
|
||
from_city = fields.Char(string="From City") | ||
to_city = fields.Char(string="To City") | ||
from_state = fields.Char(string="From State") | ||
to_state = fields.Char(string="To State") | ||
from_country = fields.Char(string="From Country") | ||
to_country = fields.Char(string="To Country") | ||
state = fields.Selection([('ringing', 'Ringing'), | ||
('on-hold', 'On Hold'), | ||
('talking', 'Talking'), | ||
('completed', 'Completed')]) | ||
call_duration = fields.Integer(string="Duration") | ||
voice_flow_sequence = fields.Integer(default=0) | ||
last_gather_key = fields.Char() | ||
last_gather_value = fields.Char() | ||
|
||
def register_new_call(self, vals): | ||
call = self.search([('sid', '=', vals['CallSid'])]) | ||
if not call: | ||
return self.create({ | ||
'name': 'Call from %s to: %s' % (vals['From'], vals['To']), | ||
'sid': vals['CallSid'], | ||
'type': vals['Direction'], | ||
'calling_date': datetime.now(), | ||
'from_number': vals['From'], | ||
'to_number': vals['To'], | ||
'from_city': vals.get('FromCity'), | ||
'to_city': vals.get('ToCity'), | ||
'from_state': vals.get('FromState'), | ||
'to_state': vals.get('ToState'), | ||
'from_country': vals.get('FromCountry'), | ||
'to_country': vals.get('ToCountry'), | ||
'state': vals['CallStatus'], | ||
}) | ||
return call | ||
|
||
def action_call_completed(self, vals): | ||
self.write({'state': 'completed', | ||
'call_duration': vals.get('CallDuration', 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,43 @@ | ||
# © 2018 Danimar Ribeiro <danimaribeiro@gmail.com> | ||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) | ||
|
||
|
||
from odoo import fields, models | ||
|
||
|
||
class TwilioVoiceFlow(models.Model): | ||
_name = 'twilio.voice.flow' | ||
_description = 'Voice Flow Configuration from Twilio' | ||
_order = 'sequence asc' | ||
|
||
name = fields.Char(string="Description", size=100, required=True) | ||
sequence = fields.Integer(string="Sequence") | ||
|
||
flow_type = fields.Selection( | ||
[('say', 'Say'), | ||
('gather', 'Gather Information'), | ||
('connect', 'Connect Call')], | ||
string="Type Action", | ||
help="Connect Call will ring for all connected users \ | ||
unless specified partner or channel") | ||
|
||
say_message = fields.Text(string="Message to Play", size=1000) | ||
record_call = fields.Boolean(string="Record Call") | ||
|
||
gather_key = fields.Char(string="Gather Key Name", size=20, | ||
help="Identifier to be used in the next flows \ | ||
that identify the question asked!") | ||
gather_possible_values = fields.Text( | ||
string="Possible values", size=500, | ||
help="Possible values to the caller answer. Use one answer per line! \ | ||
Type just numbers or words, it is going to ask for digits or \ | ||
for the caller to say the words. Use ; for use both: e.g 1;sales") | ||
|
||
to_partner_id = fields.Many2one( | ||
'res.partner', string="Partner", help="Partner to connect this call") | ||
to_mail_channel_id = fields.Many2one( | ||
'mail.channel', string="Mail Channel", | ||
help="Channel to connect this call") | ||
|
||
filter_key = fields.Char(string="Filter Key") | ||
filter_value = fields.Char(string="Filter Value") |
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,3 @@ | ||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink | ||
access_twilio_voice_call,access_twilio_voice_call,model_twilio_voice_call,base.group_user,1,1,1,1 | ||
access_twilio_voice_flow,access_twilio_voice_flow,model_twilio_voice_flow,base.group_user,1,1,1,1 |
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,40 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
<record id="view_twilio_voice_call_form" model="ir.ui.view"> | ||
<field name="name">view_twilio_voice_call_form</field> | ||
<field name="model">twilio.voice.call</field> | ||
<field name="arch" type="xml"> | ||
<form> | ||
<group> | ||
<field name="state"/> | ||
<field name="calling_date"/> | ||
<field name="call_duration"/> | ||
<field name="sid"/> | ||
<field name="from_number" /> | ||
<field name="from_city" /> | ||
<field name="from_state" /> | ||
<field name="from_country" /> | ||
<field name="type" /> | ||
<field name="to_number" /> | ||
<field name="to_city" /> | ||
<field name="to_state" /> | ||
<field name="to_country" /> | ||
</group> | ||
</form> | ||
</field> | ||
</record> | ||
|
||
<record id="action_twilio_voice_call" model="ir.actions.act_window"> | ||
<field name="name">Voice Calls</field> | ||
<field name="res_model">twilio.voice.call</field> | ||
<field name="view_mode">tree,form</field> | ||
</record> | ||
|
||
<menuitem id="menu_twilio_voice_call" | ||
name="Voice Calls" | ||
action="action_twilio_voice_call" | ||
parent="twilio_base.menu_twilio" | ||
sequence="30"/> | ||
|
||
|
||
</odoo> |
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,55 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<odoo> | ||
<record id="view_twilio_voice_flow_form" model="ir.ui.view"> | ||
<field name="name">view_twilio_voice_flow_form</field> | ||
<field name="model">twilio.voice.flow</field> | ||
<field name="arch" type="xml"> | ||
<form> | ||
<sheet> | ||
<group> | ||
<field name="name"/> | ||
<field name="flow_type"/> | ||
<field name="say_message"/> | ||
<field name="record_call" attrs="{'invisible': [('flow_type', '!=', 'connect')]}" /> | ||
<field name="gather_key" attrs="{'invisible': [('flow_type', '!=', 'gather')]}"/> | ||
<field name="gather_possible_values" attrs="{'invisible': [('flow_type', '!=', 'gather')]}" /> | ||
<field name="to_partner_id" attrs="{'invisible': [('flow_type', '!=', 'connect')]}" /> | ||
<field name="to_mail_channel_id" attrs="{'invisible': [('flow_type', '!=', 'connect')]}" /> | ||
</group> | ||
<group string="Filter Flow"> | ||
<field name="filter_key"/> | ||
<field name="filter_value"/> | ||
</group> | ||
</sheet> | ||
</form> | ||
</field> | ||
</record> | ||
|
||
<record id="view_twilio_voice_flow_tree" model="ir.ui.view"> | ||
<field name="name">view_twilio_voice_flow_tree</field> | ||
<field name="model">twilio.voice.flow</field> | ||
<field name="arch" type="xml"> | ||
<tree> | ||
<field name="sequence" widget="handle"/> | ||
<field name="name"/> | ||
<field name="flow_type"/> | ||
<field name="to_partner_id" /> | ||
<field name="to_mail_channel_id" /> | ||
</tree> | ||
</field> | ||
</record> | ||
|
||
<record id="action_twilio_voice_flow" model="ir.actions.act_window"> | ||
<field name="name">Voice Flow</field> | ||
<field name="res_model">twilio.voice.flow</field> | ||
<field name="view_mode">tree,form</field> | ||
</record> | ||
|
||
<menuitem id="menu_twilio_voice_flow" | ||
name="Voice Flows" | ||
action="action_twilio_voice_flow" | ||
parent="twilio_base.menu_twilio_configuration" | ||
sequence="25"/> | ||
|
||
|
||
</odoo> |