mirror of https://github.com/OCA/social.git
[ADD] mail_broker_whatsapp
parent
721c8511dc
commit
26a364f382
|
@ -0,0 +1 @@
|
||||||
|
TO DO
|
|
@ -0,0 +1 @@
|
||||||
|
from . import models
|
|
@ -0,0 +1,15 @@
|
||||||
|
# Copyright 2022 Creu Blanca
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
{
|
||||||
|
"name": "Mail Whatsapp Broker",
|
||||||
|
"summary": """
|
||||||
|
Set a broker for whatsapp""",
|
||||||
|
"version": "13.0.1.0.0",
|
||||||
|
"license": "AGPL-3",
|
||||||
|
"author": "Creu Blanca, Odoo Community Association (OCA)",
|
||||||
|
"website": "https://github.com/OCA/social",
|
||||||
|
"depends": ["mail_broker"],
|
||||||
|
"data": ["views/mail_broker.xml"],
|
||||||
|
"external_dependencies": {},
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
from . import mail_broker_channel
|
||||||
|
from . import mail_message_broker
|
||||||
|
from . import mail_broker
|
|
@ -0,0 +1,54 @@
|
||||||
|
# Copyright 2022 Creu Blanca
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from odoo import fields, models
|
||||||
|
from odoo.http import request
|
||||||
|
|
||||||
|
_logger = logging
|
||||||
|
|
||||||
|
|
||||||
|
class MailBroker(models.Model):
|
||||||
|
_inherit = "mail.broker"
|
||||||
|
|
||||||
|
whatsapp_security_key = fields.Char()
|
||||||
|
broker_type = fields.Selection(selection_add=[("whatsapp", "WhatsApp")])
|
||||||
|
whatsapp_from_phone = fields.Char()
|
||||||
|
|
||||||
|
def _set_webhook(self):
|
||||||
|
super(MailBroker, self)._set_webhook()
|
||||||
|
|
||||||
|
def _remove_webhook(self):
|
||||||
|
super(MailBroker, self)._remove_webhook()
|
||||||
|
|
||||||
|
def _get_channel_vals(self, token, update):
|
||||||
|
result = super(MailBroker, self)._get_channel_vals(token, update)
|
||||||
|
if self.broker_type == "whatsapp" and not result.get("name"):
|
||||||
|
for contact in update["contacts"]:
|
||||||
|
if contact["wa_id"] == token:
|
||||||
|
result["name"] = contact["profile"]["name"]
|
||||||
|
continue
|
||||||
|
return result
|
||||||
|
|
||||||
|
def _receive_update_whatsapp(self, update):
|
||||||
|
chat = {}
|
||||||
|
if update:
|
||||||
|
for entry in update["entry"]:
|
||||||
|
for change in entry["changes"]:
|
||||||
|
if change["field"] != "messages":
|
||||||
|
continue
|
||||||
|
for message in change["value"].get("messages", []):
|
||||||
|
chat = self._get_channel(
|
||||||
|
message["from"], change["value"], force_create=True
|
||||||
|
)
|
||||||
|
if not chat:
|
||||||
|
return
|
||||||
|
return chat.whatsapp_update(update)
|
||||||
|
|
||||||
|
def _verify_bot(self, **kwargs):
|
||||||
|
self.ensure_one()
|
||||||
|
if self.broker_type != "whatsapp":
|
||||||
|
return super()._verify_bot()
|
||||||
|
response = request.make_response(kwargs.get("hub").get("challenge"))
|
||||||
|
response.status_code = 200
|
||||||
|
return response
|
|
@ -0,0 +1,78 @@
|
||||||
|
# Copyright 2022 Creu Blanca
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
import base64
|
||||||
|
import mimetypes
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
|
from odoo import models
|
||||||
|
|
||||||
|
|
||||||
|
class MailBrokerChannel(models.Model):
|
||||||
|
_inherit = "mail.broker.channel"
|
||||||
|
|
||||||
|
def whatsapp_update(self, updates):
|
||||||
|
self.ensure_one()
|
||||||
|
body = ""
|
||||||
|
attachments = []
|
||||||
|
for entry in updates["entry"]:
|
||||||
|
for change in entry["changes"]:
|
||||||
|
if change["field"] != "messages":
|
||||||
|
continue
|
||||||
|
for message in change["value"]["messages"]:
|
||||||
|
if message.get("text"):
|
||||||
|
body = message.get("text").get("body")
|
||||||
|
for key in ["image", "audio", "video"]:
|
||||||
|
if message.get(key):
|
||||||
|
image_id = message.get(key).get("id")
|
||||||
|
image_info_request = requests.get(
|
||||||
|
"https://graph.facebook.com/v13.0/%s" % image_id,
|
||||||
|
headers={
|
||||||
|
"Authorization": "Bearer %s" % self.broker_id.token,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
image_info_request.raise_for_status()
|
||||||
|
image_info = image_info_request.json()
|
||||||
|
image_request = requests.get(
|
||||||
|
image_info["url"],
|
||||||
|
headers={
|
||||||
|
"Authorization": "Bearer %s" % self.broker_id.token,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
image_request.raise_for_status()
|
||||||
|
attachments.append(
|
||||||
|
(
|
||||||
|
"{}{}".format(
|
||||||
|
image_id,
|
||||||
|
mimetypes.guess_extension(
|
||||||
|
image_info["mime_type"]
|
||||||
|
),
|
||||||
|
),
|
||||||
|
base64.b64encode(image_request.content).decode(
|
||||||
|
"utf-8"
|
||||||
|
),
|
||||||
|
image_info["mime_type"],
|
||||||
|
)
|
||||||
|
)
|
||||||
|
if message.get("location"):
|
||||||
|
body += (
|
||||||
|
'<a target="_blank" href="https://www.google.com/'
|
||||||
|
'maps/search/?api=1&query=%s,%s">Location</a>'
|
||||||
|
% (
|
||||||
|
message["location"]["latitude"],
|
||||||
|
message["location"]["longitude"],
|
||||||
|
)
|
||||||
|
)
|
||||||
|
if message.get("contacts"):
|
||||||
|
pass
|
||||||
|
if len(body) > 0 or attachments:
|
||||||
|
self.message_post_broker(
|
||||||
|
body=body,
|
||||||
|
broker_type="whatsapp",
|
||||||
|
date=datetime.fromtimestamp(int(message["timestamp"])),
|
||||||
|
message_id=message.get("id"),
|
||||||
|
subtype="mt_comment",
|
||||||
|
attachments=attachments,
|
||||||
|
)
|
|
@ -0,0 +1,78 @@
|
||||||
|
# Copyright 2022 Creu Blanca
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
import logging
|
||||||
|
import traceback
|
||||||
|
from io import StringIO
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
|
from odoo import _, models
|
||||||
|
from odoo.tools import html2plaintext
|
||||||
|
|
||||||
|
from odoo.addons.base.models.ir_mail_server import MailDeliveryException
|
||||||
|
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class MailMessageBroker(models.Model):
|
||||||
|
_inherit = "mail.message.broker"
|
||||||
|
|
||||||
|
def _send_whatsapp_payload(self, body=False, media_id=False):
|
||||||
|
if body:
|
||||||
|
return {
|
||||||
|
"messaging_product": "whatsapp",
|
||||||
|
"recipient_type": "individual",
|
||||||
|
"to": self.channel_id.token,
|
||||||
|
"type": "text",
|
||||||
|
"text": {"preview_url": False, "body": html2plaintext(body)},
|
||||||
|
}
|
||||||
|
if media_id:
|
||||||
|
return {
|
||||||
|
"messaging_product": "whatsapp",
|
||||||
|
"recipient_type": "individual",
|
||||||
|
"to": self.channel_id.token,
|
||||||
|
"type": "image",
|
||||||
|
"image": {"id": media_id},
|
||||||
|
}
|
||||||
|
|
||||||
|
def _send_whatsapp(
|
||||||
|
self, auto_commit=False, raise_exception=False, parse_mode=False
|
||||||
|
):
|
||||||
|
message = False
|
||||||
|
try:
|
||||||
|
# TODO: Now only works for text. improve it...
|
||||||
|
if self.body:
|
||||||
|
response = requests.post(
|
||||||
|
"https://graph.facebook.com/v13.0/%s/messages"
|
||||||
|
% self.channel_id.broker_id.whatsapp_from_phone,
|
||||||
|
headers={
|
||||||
|
"Authorization": "Bearer %s" % self.channel_id.broker_id.token,
|
||||||
|
},
|
||||||
|
json=self._send_whatsapp_payload(body=self.body),
|
||||||
|
)
|
||||||
|
response.raise_for_status()
|
||||||
|
message = response.json()
|
||||||
|
except Exception as exc:
|
||||||
|
buff = StringIO()
|
||||||
|
traceback.print_exc(file=buff)
|
||||||
|
_logger.error(buff.getvalue())
|
||||||
|
if raise_exception:
|
||||||
|
raise MailDeliveryException(
|
||||||
|
_("Unable to send the whatsapp message"), exc
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
_logger.warning(
|
||||||
|
"Issue sending message with id {}: {}".format(self.id, exc)
|
||||||
|
)
|
||||||
|
self.write({"state": "exception", "failure_reason": exc})
|
||||||
|
if message:
|
||||||
|
self.write(
|
||||||
|
{
|
||||||
|
"state": "sent",
|
||||||
|
"message_id": message["messages"][0]["id"],
|
||||||
|
"failure_reason": False,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
if auto_commit is True:
|
||||||
|
# pylint: disable=invalid-commit
|
||||||
|
self._cr.commit()
|
|
@ -0,0 +1,29 @@
|
||||||
|
First steps
|
||||||
|
~~~~~~~~~~~
|
||||||
|
|
||||||
|
You need to create a WhatsApp Business Account (WABA), a Meta App and define a phone number.
|
||||||
|
You can follow this `steps <https://developers.facebook.com/micro_site/url/?click_from_context_menu=true&country=ES&destination=https%3A%2F%2Fwww.facebook.com%2Fbusiness%2Fhelp%2F2087193751603668&event_type=click&last_nav_impression_id=0m3TRxrxOlly1eRmB&max_percent_page_viewed=22&max_viewport_height_px=1326&max_viewport_width_px=2560&orig_http_referrer=https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2Fwhatsapp%2Fcloud-api%2Fget-started-for-bsps%3Flocale%3Den_US&orig_request_uri=https%3A%2F%2Fdevelopers.facebook.com%2Fajax%2Fpagelet%2Fgeneric.php%2FDeveloperNotificationsPayloadPagelet%3Ffb_dtsg_ag%3D--sanitized--%26data%3D%257B%2522businessUserID%2522%253Anull%252C%2522cursor%2522%253Anull%252C%2522length%2522%253A15%252C%2522clientRequestID%2522%253A%2522js_k6%2522%257D%26__usid%3D6-Trd7hi4itpm%253APrd7ifiub2tvy%253A0-Ard7g9twdm0p1-RV%253D6%253AF%253D%26locale%3Den_US%26jazoest%3D24920®ion=emea&scrolled=false&session_id=1jLoVJNU6iVMaw3ml&site=developers>`_.
|
||||||
|
|
||||||
|
If you create a test Business Account, passwords will change every 24 hours.
|
||||||
|
|
||||||
|
In order to make the webhook accessible, the system must be public.
|
||||||
|
|
||||||
|
Configure the broker
|
||||||
|
~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Once you have created the Meta App, you need to add the broker and webhook.
|
||||||
|
In order to make it you must follow this steps:
|
||||||
|
|
||||||
|
* Access `Settings > Emails > Mail Broker`
|
||||||
|
* Create a Broker of type `WhatsApp`
|
||||||
|
|
||||||
|
* Use the Meta App authentication key as `Token` field
|
||||||
|
* Use the Meta App Phone Number ID as `Whatsapp from Phone` field
|
||||||
|
* Write your own `Webhook key` and `Whatsapp Security Key`
|
||||||
|
* Press the `Integrate Webhook Key`. In this case, it will not integrate it, we need to make it manually
|
||||||
|
* Copy the webhook URL
|
||||||
|
|
||||||
|
* Access `Facebook Apps website <https://developers.facebook.com/apps/>`_
|
||||||
|
* Access your App then `Whatsapp > Configuration`
|
||||||
|
* Create your webhook using your URL and put the Whatsapp Security Key as validation Key
|
||||||
|
* Administer the Webhook and activate the messages webhook
|
|
@ -0,0 +1,2 @@
|
||||||
|
* Olga Marco <olga.marco@creublanca.es>
|
||||||
|
* Enric Tobella <etobella@creublanca.es>
|
|
@ -0,0 +1,4 @@
|
||||||
|
This module allows to respond whatsapp chats.
|
||||||
|
|
||||||
|
This way, a group of users can respond customers or any other set
|
||||||
|
of partners in an integrated way.
|
|
@ -0,0 +1,3 @@
|
||||||
|
1. Access `Broker`
|
||||||
|
2. Wait until someone starts a conversation.
|
||||||
|
3. Now you will be able to respond and receive messages to this person.
|
Binary file not shown.
After Width: | Height: | Size: 7.7 KiB |
|
@ -0,0 +1,160 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
id="Capa_1"
|
||||||
|
data-name="Capa 1"
|
||||||
|
viewBox="0 0 200.33 200"
|
||||||
|
version="1.1"
|
||||||
|
sodipodi:docname="icon.svg"
|
||||||
|
inkscape:version="0.92.3 (2405546, 2018-03-11)"
|
||||||
|
inkscape:export-filename="/home/operador/pyworkspace12/social/mail_telegram_broker/static/description/icon.png"
|
||||||
|
inkscape:export-xdpi="95.841858"
|
||||||
|
inkscape:export-ydpi="95.841858">
|
||||||
|
<metadata
|
||||||
|
id="metadata24">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work
|
||||||
|
rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||||
|
<dc:title>icon</dc:title>
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<sodipodi:namedview
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1"
|
||||||
|
objecttolerance="10"
|
||||||
|
gridtolerance="10"
|
||||||
|
guidetolerance="10"
|
||||||
|
inkscape:pageopacity="0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:window-width="1853"
|
||||||
|
inkscape:window-height="1025"
|
||||||
|
id="namedview22"
|
||||||
|
showgrid="false"
|
||||||
|
showguides="true"
|
||||||
|
inkscape:guide-bbox="true"
|
||||||
|
inkscape:snap-text-baseline="true"
|
||||||
|
inkscape:zoom="1.668772"
|
||||||
|
inkscape:cx="32.080636"
|
||||||
|
inkscape:cy="54.692004"
|
||||||
|
inkscape:window-x="67"
|
||||||
|
inkscape:window-y="27"
|
||||||
|
inkscape:window-maximized="1"
|
||||||
|
inkscape:current-layer="layer2">
|
||||||
|
<sodipodi:guide
|
||||||
|
position="51.271186,126.37712"
|
||||||
|
orientation="-0.70710678,0.70710678"
|
||||||
|
id="guide40"
|
||||||
|
inkscape:locked="false"
|
||||||
|
inkscape:label=""
|
||||||
|
inkscape:color="rgb(0,0,255)" />
|
||||||
|
<sodipodi:guide
|
||||||
|
position="118.65012,168.08767"
|
||||||
|
orientation="-0.70710678,0.70710678"
|
||||||
|
id="guide42"
|
||||||
|
inkscape:locked="false"
|
||||||
|
inkscape:label=""
|
||||||
|
inkscape:color="rgb(0,0,255)" />
|
||||||
|
<sodipodi:guide
|
||||||
|
position="138.02966,143.00847"
|
||||||
|
orientation="-0.70710678,0.70710678"
|
||||||
|
id="guide46"
|
||||||
|
inkscape:locked="false"
|
||||||
|
inkscape:label=""
|
||||||
|
inkscape:color="rgb(0,0,255)" />
|
||||||
|
<sodipodi:guide
|
||||||
|
position="137.92373,118.22034"
|
||||||
|
orientation="-0.70710678,0.70710678"
|
||||||
|
id="guide48"
|
||||||
|
inkscape:locked="false"
|
||||||
|
inkscape:label=""
|
||||||
|
inkscape:color="rgb(0,0,255)" />
|
||||||
|
<sodipodi:guide
|
||||||
|
position="156.99152,93.008474"
|
||||||
|
orientation="-0.70710678,0.70710678"
|
||||||
|
id="guide50"
|
||||||
|
inkscape:locked="false"
|
||||||
|
inkscape:label=""
|
||||||
|
inkscape:color="rgb(0,0,255)" />
|
||||||
|
<sodipodi:guide
|
||||||
|
position="139.19491,46.822034"
|
||||||
|
orientation="-0.70710678,0.70710678"
|
||||||
|
id="guide52"
|
||||||
|
inkscape:locked="false"
|
||||||
|
inkscape:label=""
|
||||||
|
inkscape:color="rgb(0,0,255)" />
|
||||||
|
<sodipodi:guide
|
||||||
|
position="33.070725,104.38065"
|
||||||
|
orientation="-0.70710678,0.70710678"
|
||||||
|
id="guide839"
|
||||||
|
inkscape:locked="false"
|
||||||
|
inkscape:label=""
|
||||||
|
inkscape:color="rgb(0,0,255)" />
|
||||||
|
<sodipodi:guide
|
||||||
|
position="136.62741,46.516241"
|
||||||
|
orientation="-0.70710678,0.70710678"
|
||||||
|
id="guide841"
|
||||||
|
inkscape:locked="false"
|
||||||
|
inkscape:label=""
|
||||||
|
inkscape:color="rgb(0,0,255)" />
|
||||||
|
</sodipodi:namedview>
|
||||||
|
<defs
|
||||||
|
id="defs4">
|
||||||
|
<style
|
||||||
|
id="style2">.cls-1{fill:none;}.cls-2{fill:#3b588f;}.cls-3{fill:#070308;opacity:0.4;}.cls-4{fill:#fff;}</style>
|
||||||
|
</defs>
|
||||||
|
<title
|
||||||
|
id="title6">icon</title>
|
||||||
|
<rect
|
||||||
|
id="_Sector_"
|
||||||
|
data-name="<Sector>"
|
||||||
|
class="cls-1"
|
||||||
|
width="200"
|
||||||
|
height="200" />
|
||||||
|
<rect
|
||||||
|
class="cls-2"
|
||||||
|
x="0.33000001"
|
||||||
|
width="200"
|
||||||
|
height="200"
|
||||||
|
id="rect9"
|
||||||
|
ry="5.6928086"
|
||||||
|
y="0"
|
||||||
|
style="fill:#179cde;fill-opacity:1" />
|
||||||
|
<g
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer1"
|
||||||
|
inkscape:label="Layer 1"
|
||||||
|
style="display:inline" />
|
||||||
|
<g
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer2"
|
||||||
|
inkscape:label="Layer 3">
|
||||||
|
<path
|
||||||
|
style="fill:#000000;fill-opacity:0.29051986;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||||
|
d="M 34.149962,94.540113 0.33939645,128.35068 c 0,22.04621 -0.005125,-37.02851 -0.005125,66.40594 0,1.19849 0.87634879,2.80824 1.47559179,3.40749 0,0 1.6732367,1.97005 4.5570938,1.85769 l 83.7317707,-0.009 47.844652,-47.84466 4.88661,-95.023805 z"
|
||||||
|
id="path843"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
sodipodi:nodetypes="ccccccccc" />
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
inkscape:groupmode="layer"
|
||||||
|
id="layer4"
|
||||||
|
inkscape:label="Layer 2"
|
||||||
|
style="display:inline">
|
||||||
|
<path
|
||||||
|
id="path828"
|
||||||
|
d="m 158.96325,57.709612 -19.05983,89.885658 c -1.43794,6.34387 -5.18788,7.92279 -10.51673,4.93412 l -29.04085,-21.4 -14.012923,13.47721 c -1.550725,1.55072 -2.84769,2.84769 -5.836362,2.84769 l 2.086431,-29.57656 53.824254,-48.636368 c 2.34019,-2.08643 -0.50751,-3.24242 -3.63715,-1.15599 L 66.229882,109.98314 37.583764,101.01713 c -6.23109,-1.945458 -6.34388,-6.231088 1.29697,-9.219758 L 150.92767,48.63082 c 5.18788,-1.945453 9.72728,1.155997 8.03558,9.078792 z"
|
||||||
|
inkscape:connector-curvature="0"
|
||||||
|
style="display:inline;fill:#ffffff;fill-opacity:1;stroke-width:0.28195" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 5.3 KiB |
|
@ -0,0 +1,452 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
|
<meta name="generator" content="Docutils: http://docutils.sourceforge.net/" />
|
||||||
|
<title>Mail Telegram Broker</title>
|
||||||
|
<style type="text/css">
|
||||||
|
|
||||||
|
/*
|
||||||
|
:Author: David Goodger (goodger@python.org)
|
||||||
|
:Id: $Id: html4css1.css 7952 2016-07-26 18:15:59Z milde $
|
||||||
|
:Copyright: This stylesheet has been placed in the public domain.
|
||||||
|
|
||||||
|
Default cascading style sheet for the HTML output of Docutils.
|
||||||
|
|
||||||
|
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
|
||||||
|
customize this style sheet.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* used to remove borders from tables and images */
|
||||||
|
.borderless, table.borderless td, table.borderless th {
|
||||||
|
border: 0 }
|
||||||
|
|
||||||
|
table.borderless td, table.borderless th {
|
||||||
|
/* Override padding for "table.docutils td" with "! important".
|
||||||
|
The right padding separates the table cells. */
|
||||||
|
padding: 0 0.5em 0 0 ! important }
|
||||||
|
|
||||||
|
.first {
|
||||||
|
/* Override more specific margin styles with "! important". */
|
||||||
|
margin-top: 0 ! important }
|
||||||
|
|
||||||
|
.last, .with-subtitle {
|
||||||
|
margin-bottom: 0 ! important }
|
||||||
|
|
||||||
|
.hidden {
|
||||||
|
display: none }
|
||||||
|
|
||||||
|
.subscript {
|
||||||
|
vertical-align: sub;
|
||||||
|
font-size: smaller }
|
||||||
|
|
||||||
|
.superscript {
|
||||||
|
vertical-align: super;
|
||||||
|
font-size: smaller }
|
||||||
|
|
||||||
|
a.toc-backref {
|
||||||
|
text-decoration: none ;
|
||||||
|
color: black }
|
||||||
|
|
||||||
|
blockquote.epigraph {
|
||||||
|
margin: 2em 5em ; }
|
||||||
|
|
||||||
|
dl.docutils dd {
|
||||||
|
margin-bottom: 0.5em }
|
||||||
|
|
||||||
|
object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Uncomment (and remove this text!) to get bold-faced definition list terms
|
||||||
|
dl.docutils dt {
|
||||||
|
font-weight: bold }
|
||||||
|
*/
|
||||||
|
|
||||||
|
div.abstract {
|
||||||
|
margin: 2em 5em }
|
||||||
|
|
||||||
|
div.abstract p.topic-title {
|
||||||
|
font-weight: bold ;
|
||||||
|
text-align: center }
|
||||||
|
|
||||||
|
div.admonition, div.attention, div.caution, div.danger, div.error,
|
||||||
|
div.hint, div.important, div.note, div.tip, div.warning {
|
||||||
|
margin: 2em ;
|
||||||
|
border: medium outset ;
|
||||||
|
padding: 1em }
|
||||||
|
|
||||||
|
div.admonition p.admonition-title, div.hint p.admonition-title,
|
||||||
|
div.important p.admonition-title, div.note p.admonition-title,
|
||||||
|
div.tip p.admonition-title {
|
||||||
|
font-weight: bold ;
|
||||||
|
font-family: sans-serif }
|
||||||
|
|
||||||
|
div.attention p.admonition-title, div.caution p.admonition-title,
|
||||||
|
div.danger p.admonition-title, div.error p.admonition-title,
|
||||||
|
div.warning p.admonition-title, .code .error {
|
||||||
|
color: red ;
|
||||||
|
font-weight: bold ;
|
||||||
|
font-family: sans-serif }
|
||||||
|
|
||||||
|
/* Uncomment (and remove this text!) to get reduced vertical space in
|
||||||
|
compound paragraphs.
|
||||||
|
div.compound .compound-first, div.compound .compound-middle {
|
||||||
|
margin-bottom: 0.5em }
|
||||||
|
|
||||||
|
div.compound .compound-last, div.compound .compound-middle {
|
||||||
|
margin-top: 0.5em }
|
||||||
|
*/
|
||||||
|
|
||||||
|
div.dedication {
|
||||||
|
margin: 2em 5em ;
|
||||||
|
text-align: center ;
|
||||||
|
font-style: italic }
|
||||||
|
|
||||||
|
div.dedication p.topic-title {
|
||||||
|
font-weight: bold ;
|
||||||
|
font-style: normal }
|
||||||
|
|
||||||
|
div.figure {
|
||||||
|
margin-left: 2em ;
|
||||||
|
margin-right: 2em }
|
||||||
|
|
||||||
|
div.footer, div.header {
|
||||||
|
clear: both;
|
||||||
|
font-size: smaller }
|
||||||
|
|
||||||
|
div.line-block {
|
||||||
|
display: block ;
|
||||||
|
margin-top: 1em ;
|
||||||
|
margin-bottom: 1em }
|
||||||
|
|
||||||
|
div.line-block div.line-block {
|
||||||
|
margin-top: 0 ;
|
||||||
|
margin-bottom: 0 ;
|
||||||
|
margin-left: 1.5em }
|
||||||
|
|
||||||
|
div.sidebar {
|
||||||
|
margin: 0 0 0.5em 1em ;
|
||||||
|
border: medium outset ;
|
||||||
|
padding: 1em ;
|
||||||
|
background-color: #ffffee ;
|
||||||
|
width: 40% ;
|
||||||
|
float: right ;
|
||||||
|
clear: right }
|
||||||
|
|
||||||
|
div.sidebar p.rubric {
|
||||||
|
font-family: sans-serif ;
|
||||||
|
font-size: medium }
|
||||||
|
|
||||||
|
div.system-messages {
|
||||||
|
margin: 5em }
|
||||||
|
|
||||||
|
div.system-messages h1 {
|
||||||
|
color: red }
|
||||||
|
|
||||||
|
div.system-message {
|
||||||
|
border: medium outset ;
|
||||||
|
padding: 1em }
|
||||||
|
|
||||||
|
div.system-message p.system-message-title {
|
||||||
|
color: red ;
|
||||||
|
font-weight: bold }
|
||||||
|
|
||||||
|
div.topic {
|
||||||
|
margin: 2em }
|
||||||
|
|
||||||
|
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
|
||||||
|
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
|
||||||
|
margin-top: 0.4em }
|
||||||
|
|
||||||
|
h1.title {
|
||||||
|
text-align: center }
|
||||||
|
|
||||||
|
h2.subtitle {
|
||||||
|
text-align: center }
|
||||||
|
|
||||||
|
hr.docutils {
|
||||||
|
width: 75% }
|
||||||
|
|
||||||
|
img.align-left, .figure.align-left, object.align-left, table.align-left {
|
||||||
|
clear: left ;
|
||||||
|
float: left ;
|
||||||
|
margin-right: 1em }
|
||||||
|
|
||||||
|
img.align-right, .figure.align-right, object.align-right, table.align-right {
|
||||||
|
clear: right ;
|
||||||
|
float: right ;
|
||||||
|
margin-left: 1em }
|
||||||
|
|
||||||
|
img.align-center, .figure.align-center, object.align-center {
|
||||||
|
display: block;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.align-center {
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.align-left {
|
||||||
|
text-align: left }
|
||||||
|
|
||||||
|
.align-center {
|
||||||
|
clear: both ;
|
||||||
|
text-align: center }
|
||||||
|
|
||||||
|
.align-right {
|
||||||
|
text-align: right }
|
||||||
|
|
||||||
|
/* reset inner alignment in figures */
|
||||||
|
div.align-right {
|
||||||
|
text-align: inherit }
|
||||||
|
|
||||||
|
/* div.align-center * { */
|
||||||
|
/* text-align: left } */
|
||||||
|
|
||||||
|
.align-top {
|
||||||
|
vertical-align: top }
|
||||||
|
|
||||||
|
.align-middle {
|
||||||
|
vertical-align: middle }
|
||||||
|
|
||||||
|
.align-bottom {
|
||||||
|
vertical-align: bottom }
|
||||||
|
|
||||||
|
ol.simple, ul.simple {
|
||||||
|
margin-bottom: 1em }
|
||||||
|
|
||||||
|
ol.arabic {
|
||||||
|
list-style: decimal }
|
||||||
|
|
||||||
|
ol.loweralpha {
|
||||||
|
list-style: lower-alpha }
|
||||||
|
|
||||||
|
ol.upperalpha {
|
||||||
|
list-style: upper-alpha }
|
||||||
|
|
||||||
|
ol.lowerroman {
|
||||||
|
list-style: lower-roman }
|
||||||
|
|
||||||
|
ol.upperroman {
|
||||||
|
list-style: upper-roman }
|
||||||
|
|
||||||
|
p.attribution {
|
||||||
|
text-align: right ;
|
||||||
|
margin-left: 50% }
|
||||||
|
|
||||||
|
p.caption {
|
||||||
|
font-style: italic }
|
||||||
|
|
||||||
|
p.credits {
|
||||||
|
font-style: italic ;
|
||||||
|
font-size: smaller }
|
||||||
|
|
||||||
|
p.label {
|
||||||
|
white-space: nowrap }
|
||||||
|
|
||||||
|
p.rubric {
|
||||||
|
font-weight: bold ;
|
||||||
|
font-size: larger ;
|
||||||
|
color: maroon ;
|
||||||
|
text-align: center }
|
||||||
|
|
||||||
|
p.sidebar-title {
|
||||||
|
font-family: sans-serif ;
|
||||||
|
font-weight: bold ;
|
||||||
|
font-size: larger }
|
||||||
|
|
||||||
|
p.sidebar-subtitle {
|
||||||
|
font-family: sans-serif ;
|
||||||
|
font-weight: bold }
|
||||||
|
|
||||||
|
p.topic-title {
|
||||||
|
font-weight: bold }
|
||||||
|
|
||||||
|
pre.address {
|
||||||
|
margin-bottom: 0 ;
|
||||||
|
margin-top: 0 ;
|
||||||
|
font: inherit }
|
||||||
|
|
||||||
|
pre.literal-block, pre.doctest-block, pre.math, pre.code {
|
||||||
|
margin-left: 2em ;
|
||||||
|
margin-right: 2em }
|
||||||
|
|
||||||
|
pre.code .ln { color: grey; } /* line numbers */
|
||||||
|
pre.code, code { background-color: #eeeeee }
|
||||||
|
pre.code .comment, code .comment { color: #5C6576 }
|
||||||
|
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
|
||||||
|
pre.code .literal.string, code .literal.string { color: #0C5404 }
|
||||||
|
pre.code .name.builtin, code .name.builtin { color: #352B84 }
|
||||||
|
pre.code .deleted, code .deleted { background-color: #DEB0A1}
|
||||||
|
pre.code .inserted, code .inserted { background-color: #A3D289}
|
||||||
|
|
||||||
|
span.classifier {
|
||||||
|
font-family: sans-serif ;
|
||||||
|
font-style: oblique }
|
||||||
|
|
||||||
|
span.classifier-delimiter {
|
||||||
|
font-family: sans-serif ;
|
||||||
|
font-weight: bold }
|
||||||
|
|
||||||
|
span.interpreted {
|
||||||
|
font-family: sans-serif }
|
||||||
|
|
||||||
|
span.option {
|
||||||
|
white-space: nowrap }
|
||||||
|
|
||||||
|
span.pre {
|
||||||
|
white-space: pre }
|
||||||
|
|
||||||
|
span.problematic {
|
||||||
|
color: red }
|
||||||
|
|
||||||
|
span.section-subtitle {
|
||||||
|
/* font-size relative to parent (h1..h6 element) */
|
||||||
|
font-size: 80% }
|
||||||
|
|
||||||
|
table.citation {
|
||||||
|
border-left: solid 1px gray;
|
||||||
|
margin-left: 1px }
|
||||||
|
|
||||||
|
table.docinfo {
|
||||||
|
margin: 2em 4em }
|
||||||
|
|
||||||
|
table.docutils {
|
||||||
|
margin-top: 0.5em ;
|
||||||
|
margin-bottom: 0.5em }
|
||||||
|
|
||||||
|
table.footnote {
|
||||||
|
border-left: solid 1px black;
|
||||||
|
margin-left: 1px }
|
||||||
|
|
||||||
|
table.docutils td, table.docutils th,
|
||||||
|
table.docinfo td, table.docinfo th {
|
||||||
|
padding-left: 0.5em ;
|
||||||
|
padding-right: 0.5em ;
|
||||||
|
vertical-align: top }
|
||||||
|
|
||||||
|
table.docutils th.field-name, table.docinfo th.docinfo-name {
|
||||||
|
font-weight: bold ;
|
||||||
|
text-align: left ;
|
||||||
|
white-space: nowrap ;
|
||||||
|
padding-left: 0 }
|
||||||
|
|
||||||
|
/* "booktabs" style (no vertical lines) */
|
||||||
|
table.docutils.booktabs {
|
||||||
|
border: 0px;
|
||||||
|
border-top: 2px solid;
|
||||||
|
border-bottom: 2px solid;
|
||||||
|
border-collapse: collapse;
|
||||||
|
}
|
||||||
|
table.docutils.booktabs * {
|
||||||
|
border: 0px;
|
||||||
|
}
|
||||||
|
table.docutils.booktabs th {
|
||||||
|
border-bottom: thin solid;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
|
||||||
|
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
|
||||||
|
font-size: 100% }
|
||||||
|
|
||||||
|
ul.auto-toc {
|
||||||
|
list-style-type: none }
|
||||||
|
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="document" id="mail-telegram-broker">
|
||||||
|
<h1 class="title">Mail Telegram Broker</h1>
|
||||||
|
|
||||||
|
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
!! This file is generated by oca-gen-addon-readme !!
|
||||||
|
!! changes will be overwritten. !!
|
||||||
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||||
|
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/tegin/cb-addons/tree/13.0/mail_broker_telegram"><img alt="tegin/cb-addons" src="https://img.shields.io/badge/github-tegin%2Fcb--addons-lightgray.png?logo=github" /></a></p>
|
||||||
|
<p>This module allows to respond telegram chats as a telegram bot.</p>
|
||||||
|
<p>This way, a group of users can respond customers or any other set
|
||||||
|
of partners in an integrated way.</p>
|
||||||
|
<p>It is not intended to be integrated on default chatter as users don’t need
|
||||||
|
to review again when one has responded.</p>
|
||||||
|
<p><strong>Table of contents</strong></p>
|
||||||
|
<div class="contents local topic" id="contents">
|
||||||
|
<ul class="simple">
|
||||||
|
<li><a class="reference internal" href="#configuration" id="id1">Configuration</a><ul>
|
||||||
|
<li><a class="reference internal" href="#create-the-bot" id="id2">Create the bot</a></li>
|
||||||
|
<li><a class="reference internal" href="#configure-odoo" id="id3">Configure Odoo</a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<li><a class="reference internal" href="#usage" id="id4">Usage</a></li>
|
||||||
|
<li><a class="reference internal" href="#bug-tracker" id="id5">Bug Tracker</a></li>
|
||||||
|
<li><a class="reference internal" href="#credits" id="id6">Credits</a><ul>
|
||||||
|
<li><a class="reference internal" href="#authors" id="id7">Authors</a></li>
|
||||||
|
<li><a class="reference internal" href="#contributors" id="id8">Contributors</a></li>
|
||||||
|
<li><a class="reference internal" href="#maintainers" id="id9">Maintainers</a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="section" id="configuration">
|
||||||
|
<h1><a class="toc-backref" href="#id1">Configuration</a></h1>
|
||||||
|
<div class="section" id="create-the-bot">
|
||||||
|
<h2><a class="toc-backref" href="#id2">Create the bot</a></h2>
|
||||||
|
<ol class="arabic simple">
|
||||||
|
<li>Create a Bot on telegram <a class="reference external" href="https://core.telegram.org/bots">https://core.telegram.org/bots</a></li>
|
||||||
|
<li>Create a broker following the examples on
|
||||||
|
<a class="reference external" href="https://github.com/tegin/telegram-broker">https://github.com/tegin/telegram-broker</a> with the TOKEN provided</li>
|
||||||
|
</ol>
|
||||||
|
</div>
|
||||||
|
<div class="section" id="configure-odoo">
|
||||||
|
<h2><a class="toc-backref" href="#id3">Configure Odoo</a></h2>
|
||||||
|
<ol class="arabic simple">
|
||||||
|
<li>Access on debug mode</li>
|
||||||
|
<li>Access <cite>Settings > Technical Settings > Email > Telegram Bot</cite>.</li>
|
||||||
|
<li>Create a bot and assign the token. Mark it as <cite>Show on App</cite></li>
|
||||||
|
</ol>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="section" id="usage">
|
||||||
|
<h1><a class="toc-backref" href="#id4">Usage</a></h1>
|
||||||
|
<ol class="arabic simple">
|
||||||
|
<li>Access <cite>Telegram</cite></li>
|
||||||
|
<li>Wait until someone starts a conversation with your bot.</li>
|
||||||
|
<li>Now you will be able to respond and receive messages to this person.</li>
|
||||||
|
</ol>
|
||||||
|
</div>
|
||||||
|
<div class="section" id="bug-tracker">
|
||||||
|
<h1><a class="toc-backref" href="#id5">Bug Tracker</a></h1>
|
||||||
|
<p>Bugs are tracked on <a class="reference external" href="https://github.com/tegin/cb-addons/issues">GitHub Issues</a>.
|
||||||
|
In case of trouble, please check there if your issue has already been reported.
|
||||||
|
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
||||||
|
<a class="reference external" href="https://github.com/tegin/cb-addons/issues/new?body=module:%20mail_broker_telegram%0Aversion:%2013.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||||
|
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||||
|
</div>
|
||||||
|
<div class="section" id="credits">
|
||||||
|
<h1><a class="toc-backref" href="#id6">Credits</a></h1>
|
||||||
|
<div class="section" id="authors">
|
||||||
|
<h2><a class="toc-backref" href="#id7">Authors</a></h2>
|
||||||
|
<ul class="simple">
|
||||||
|
<li>Creu Blanca</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="section" id="contributors">
|
||||||
|
<h2><a class="toc-backref" href="#id8">Contributors</a></h2>
|
||||||
|
<ul class="simple">
|
||||||
|
<li>Enric Tobella <<a class="reference external" href="mailto:etobella@creublanca.es">etobella@creublanca.es</a>></li>
|
||||||
|
<li>Olga Marco <<a class="reference external" href="mailto:olga.marco@creublanca.es">olga.marco@creublanca.es</a>></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="section" id="maintainers">
|
||||||
|
<h2><a class="toc-backref" href="#id9">Maintainers</a></h2>
|
||||||
|
<p>This module is part of the <a class="reference external" href="https://github.com/tegin/cb-addons/tree/13.0/mail_broker_telegram">tegin/cb-addons</a> project on GitHub.</p>
|
||||||
|
<p>You are welcome to contribute.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<!-- Copyright 2022 Creu Blanca
|
||||||
|
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
|
||||||
|
<odoo>
|
||||||
|
<record model="ir.ui.view" id="mail_broker_form_view">
|
||||||
|
<field name="name">mail.broker.form (in mail_broker_telegram)</field>
|
||||||
|
<field name="model">mail.broker</field>
|
||||||
|
<field name="inherit_id" ref="mail_broker.mail_broker_form_view" />
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<field name="webhook_user_id" position="after">
|
||||||
|
<field
|
||||||
|
name="whatsapp_security_key"
|
||||||
|
attrs="{'invisible': [('broker_type', '!=', 'whatsapp')]}"
|
||||||
|
/>
|
||||||
|
<field
|
||||||
|
name="whatsapp_from_phone"
|
||||||
|
attrs="{'invisible': [('broker_type', '!=', 'whatsapp')]}"
|
||||||
|
/>
|
||||||
|
</field>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
Loading…
Reference in New Issue