Giter VIP home page Giter VIP logo

twilio-integration's Introduction

Twilio Integration

Custom Frappe Application for Twilio Integration

Features

  • Users can make outgoing voice calls by clicking at the phone icon that shows up next to the phone number.
  • Users can receive Incoming calls either in Phone or in browser.
  • Users can send notifications through whatsapp.

Authorize twilio

To authorise Twilio integration go to Twilio Settings Doctype and provide Account SID and Auth Token. Make sure Twilio Settings are enabled to use Twilio in the system.

Twilio Settings

Voice Call

Every user(Agent) needs to have voice call settings to make or receive calls. User can use Twilio features once Voice Call Settings created.

In voice call settings

  1. choose the Call Receiving Device as Computer to receive calls in the browser or Phone to receive calls in your Phone(Make sure that Mobile No is configured in My Settings section to receive calls in your phone).
  2. Choose your twilio number from Twilio Number dropdown field. This is going to be your twilio communication number.

Twilio Voice Call Settings

Outgoing Calls

Once the user clicks the phone icon next to the phone number, the user will see a phone popup with a call button. Make sure that area code is included in the phone number(ex: +91) before using the call button to make outgoing calls.

Twilio Outgoing Call Popup

Incoming Calls

When an incoming call comes, the call will be redirected to phone or to browser depending on user voice call Settings. Here is how it looks when call comes to browser.

Twilio Incoming Call Popup

WhatsApp message

Users can send notifications through WhatsApp channel. While creating/editing a notification please Select Channel as WhatsApp and Twilio number from dropdown if you want to send whatsapp notification.

Twilio Whatsapp notification

Development

Pre-requisites

  • ERPNext
  • Twilio account (More details from Configure Twilio section)

Configure Twilio

  • You need to create a new project in Twilio account to use communication features like whatsapp, voice calls etc through ERPNext.

Twilio For Voice Calls

  • From your Twilio console you can go to a programmable voice section and get a Twilio number to use for calls(make sure that the number is voice capable).
  • Create a TwiML App by passing voice request url as you_project_domain_name/api/method/twilio_integration.twilio_integration.doctype.twilio_settings.twilio_settings.voice . Use ngrok to get public domain for your project in case it is running locally.

Twilio For Whatsapp

  • From your Twilio console you can go to a Programmable Messaging section and get a Twilio number to use for whatsapp.

How To Setup

Once you have created a site with ERPNext app installed, you can download and install twilio-integration app using

bench get-app https://github.com/frappe/twilio-integration.git
bench --site site_name install-app twilio_integration

Use bench start command to run the project.

Configure Twilio Settings Through Project's Admin Interface

  • For Whatsapp communication you need to set Account SID and Auth Token in Twilio Settings(You can get those from Twilio console).
  • For calls you need to pass TwiML SID(Get it from TwiML app you have created) and Outgoing Voice Medium along with Account SID and Auth Token in Twilio Settings
  • Make sure that you enabled twilio by clicking Enabled checkbox in settings.

NOTE: While creating a new communication medium for Outgoing Voice Medium pass twilio number(including area code(ex:+91)) as Name, Twilio as communication channel and Voice as Communication Medium Type.

License

MIT

twilio-integration's People

Contributors

ankush avatar anupamvs avatar gavindsouza avatar leela avatar mangesh-khairnar avatar shariquerik avatar surajshetty3416 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

twilio-integration's Issues

pyngrok version needs update

When getting (bench get-app) this app from git, I got error:

frappe 13.19.0 requires pyngrok~=5.0.5, but you have pyngrok 5.1.0 which is incompatible.

Then tried to uninstall pyngrok 5.1.0 and install 5.0.6 it can be cloned and installed.

Frappe 13.19.0
No ERPNext
Ubuntu 20.04.3 LTS (Focal Fossa)

Installation Error

I tried to install twilio on frappe version 14 and version 15. Giving same error on both versions-
Getting twilio-integration
$ git clone https://github.com/frappe/twilio-integration.git --depth 1 --origin upstream
Cloning into 'twilio-integration'...
fatal: unable to access 'https://github.com/frappe/twilio-integration.git/': Failed to connect to github.com port 443 after 129455 ms: Connection timed out
ERROR: git clone https://github.com/frappe/twilio-integration.git --depth 1 --origin upstream
subprocess.CalledProcessError: Command 'git clone https://github.com/frappe/twilio-integration.git --depth 1 --origin upstream' returned non-zero exit status 128.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/local/bin/bench", line 8, in
sys.exit(cli())
File "/usr/local/lib/python3.10/dist-packages/bench/cli.py", line 132, in cli
bench_command()
File "/usr/local/lib/python3.10/dist-packages/bench/commands/make.py", line 167, in get_app
get_app(
File "/usr/local/lib/python3.10/dist-packages/bench/app.py", line 437, in get_app
app.get()
File "/usr/local/lib/python3.10/dist-packages/bench/utils/render.py", line 126, in wrapper_fn
return fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/bench/app.py", line 194, in get
self.bench.run(
File "/usr/local/lib/python3.10/dist-packages/bench/bench.py", line 48, in run
return exec_cmd(cmd, cwd=cwd or self.cwd, _raise=_raise)
File "/usr/local/lib/python3.10/dist-packages/bench/utils/init.py", line 158, in exec_cmd
raise CommandFailedError(cmd) from subprocess.CalledProcessError(return_code, cmd)
bench.exceptions.CommandFailedError: git clone https://github.com/frappe/twilio-integration.git --depth 1 --origin upstream

No module named 'pyngrok'

pyngrok was a direct dependency of twilio-integration but wasn't added to requirements.txt. Since it was removed from frappe via frappe/frappe@49b157e#diff-4d7c51b1efe9043e44439a949dfd92e5827321b34082903477fd04876edb7552, new setups/envs seem to be breaking with the following traceback:

Traceback (most recent call last):
  File "apps/frappe/frappe/email/doctype/notification/notification.py", line 398, in evaluate_alert
    alert = frappe.get_doc("Notification", alert)
  File "apps/frappe/frappe/__init__.py", line 898, in get_doc
    doc = frappe.model.document.get_doc(*args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 70, in get_doc
    controller = get_controller(doctype)
  File "apps/frappe/frappe/model/base_document.py", line 70, in get_controller
    site_controllers[doctype] = _get_controller()
  File "apps/frappe/frappe/model/base_document.py", line 48, in _get_controller
    module = frappe.get_module(module_path)
  File "apps/frappe/frappe/__init__.py", line 987, in get_module
    return importlib.import_module(modulename)
  File "/home/frappe/.pyenv/versions/3.9.9/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "apps/twilio_integration/twilio_integration/overrides/notification.py", line 4, in <module>
    from twilio_integration.twilio_integration.doctype.whatsapp_message.whatsapp_message import WhatsAppMessage
  File "apps/twilio_integration/twilio_integration/twilio_integration/__init__.py", line 1, in <module>
    from . import api
  File "apps/twilio_integration/twilio_integration/twilio_integration/api.py", line 6, in <module>
    from .twilio_handler import Twilio, IncomingCall, TwilioCallDetails
  File "apps/twilio_integration/twilio_integration/twilio_integration/twilio_handler.py", line 11, in <module>
    from .utils import get_public_url, merge_dicts
  File "apps/twilio_integration/twilio_integration/twilio_integration/utils.py", line 1, in <module>
    from pyngrok import ngrok
ModuleNotFoundError: No module named 'pyngrok'

Twilio Voice call error - localhost instead of mysite.com

Hi all.

Thank you for the fantastic work.

I am running ERPnext 14.20.2 in docker container. When setting up twilio integration, the url of the api call says https://localhost and doesn't pickup the site url. below is the error message.
<twilio.base.exceptions.TwilioRestException: HTTP 400 error: Unable to create record: VoiceUrl is not a valid URL: https://localhost/api/method/twilio_integration.twilio_integration.api.voice>

Can someone help me solve this. Do I need to install ngrok for docker images?
Thanks

cannot install on v14

Hi i cannot install on v14, i am getting error

error: <class 'PermissionError'>, [Errno 13] Permission denied: file: /usr/lib/python3/dist-packages/supervisor/xmlrpc.py line: 560
ERROR:
Traceback (most recent call last):
File "/usr/local/bin/bench", line 8, in
sys.exit(cli())
File "/usr/local/lib/python3.10/dist-packages/bench/cli.py", line 127, in cli
bench_command()
File "/usr/lib/python3/dist-packages/click/core.py", line 1128, in call
return self.main(*args, **kwargs)
File "/usr/lib/python3/dist-packages/click/core.py", line 1053, in main
rv = self.invoke(ctx)
File "/usr/lib/python3/dist-packages/click/core.py", line 1659, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/lib/python3/dist-packages/click/core.py", line 1395, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/lib/python3/dist-packages/click/core.py", line 754, in invoke
return __callback(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/bench/commands/make.py", line 159, in get_app
get_app(
File "/usr/local/lib/python3.10/dist-packages/bench/app.py", line 444, in get_app
app.install(verbose=verbose, skip_assets=skip_assets, restart_bench=restart_bench)
File "/usr/local/lib/python3.10/dist-packages/bench/utils/render.py", line 126, in wrapper_fn
return fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/bench/app.py", line 242, in install
install_app(
File "/usr/local/lib/python3.10/dist-packages/bench/app.py", line 589, in install_app
bench.reload()
File "/usr/local/lib/python3.10/dist-packages/bench/utils/render.py", line 126, in wrapper_fn
return fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/bench/bench.py", line 151, in reload
restart_supervisor_processes(bench_path=self.name, web_workers=web)
File "/usr/local/lib/python3.10/dist-packages/bench/utils/bench.py", line 304, in restart_supervisor_processes
bench.run(f"{sudo}supervisorctl restart {group}")
File "/usr/local/lib/python3.10/dist-packages/bench/bench.py", line 48, in run
return exec_cmd(cmd, cwd=cwd or self.cwd)
File "/usr/local/lib/python3.10/dist-packages/bench/utils/init.py", line 155, in exec_cmd
raise CommandFailedError
bench.exceptions.CommandFailedError

How do I call numbers outside the Contact doctype

I am struggling to make calls from doctypes other than Contact. The call button appears in contact and so does the phone icon against every number. But not in any other doctype like Lead.

Is this a bug or design? If this is intentional, how do I add the call button to other doctypes?

I've looked through the code and can't figure it out by myself.

No outgoing whatsApp notification/message from ERPnext

Issue: No outgoing whatsApp notification/message from ERPnext

Steps to reproduce the bug:

  1. Click on 'Purchase Invoice' in the "Buying" module.
  2. Click on 'Add Purchase invoice'.
  3. Enter details and Submit the invoice.

Actual result:
The purchase invoice is submitted but no whatsapp message is sent to the "supplier" phone number.

**Note:

  1. Twilio account configured and whatsapp templates approved.
    wp
  2. Twilio settings and communication channel configured in EPRnext system.
    wp3
    wp4
  3. Notification created in EPRnext.
    wp2
    wp1

Twilio was unable to fetch content from:

Twilio was unable to fetch content from: http://139.144.181.182:8000/api/method/twilio_integration.twilio_integration.api.whatsapp_message_status_callback
Error: Failed to connect to ip 139.144.181.182: No route to host: /139.144.181.182:8000
Account SID: AC1874ca79a16312b64e4849dc8fa16d7e
SID: SM05d655599e5f04483b2c73263fdc0170
Request ID: d29b9a6c-8870-4000-a116-6e61dff9c3fa
Remote Host: 139.144.181.182
Request Method: POST
Request URI: http://139.144.181.182:8000/api/method/twilio_integration.twilio_integration.api.whatsapp_message_status_callback
URL Fragment: true

Installation error

I have an issue installing this custom app - when I run the command bench --site mysitename install-app twilio_integration - I get the following error;

An error occurred while installing twilio_integration:
No module named 'pyngrok'.

v14 installation error

Hi I am getting this error when I am installing on v14

error: <class 'PermissionError'>, [Errno 13] Permission denied: file: /usr/lib/python3/dist-packages/supervisor /xmlrpc.py line: 560
ERROR:
Traceback (most recent call last):
File "/usr/local/bin/bench", line 8, in
sys.exit(cli())
File "/usr/local/lib/python3.10/dist-packages/bench/cli.py", line 127, in cli
bench_command()
File "/usr/lib/python3/dist-packages/click/core.py", line 1128, in call
return self.main(*args, **kwargs)
File "/usr/lib/python3/dist-packages/click/core.py", line 1053, in main
rv = self.invoke(ctx)
File "/usr/lib/python3/dist-packages/click/core.py", line 1659, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/lib/python3/dist-packages/click/core.py", line 1395, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/lib/python3/dist-packages/click/core.py", line 754, in invoke
return __callback(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/bench/commands/make.py", line 159, in get_app
get_app(
File "/usr/local/lib/python3.10/dist-packages/bench/app.py", line 444, in get_app
app.install(verbose=verbose, skip_assets=skip_assets, restart_bench=restart_bench)
File "/usr/local/lib/python3.10/dist-packages/bench/utils/render.py", line 126, in wrapper_fn
return fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/bench/app.py", line 242, in install
install_app(
File "/usr/local/lib/python3.10/dist-packages/bench/app.py", line 589, in install_app
bench.reload()
File "/usr/local/lib/python3.10/dist-packages/bench/utils/render.py", line 126, in wrapper_fn
return fn(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/bench/bench.py", line 151, in reload
restart_supervisor_processes(bench_path=self.name, web_workers=web)
File "/usr/local/lib/python3.10/dist-packages/bench/utils/bench.py", line 304, in restart_supervisor_processe s
bench.run(f"{sudo}supervisorctl restart {group}")
File "/usr/local/lib/python3.10/dist-packages/bench/bench.py", line 48, in run
return exec_cmd(cmd, cwd=cwd or self.cwd)
File "/usr/local/lib/python3.10/dist-packages/bench/utils/init.py", line 155, in exec_cmd
raise CommandFailedError
bench.exceptions.CommandFailedError

Whatsapp Notification Error

Information about bug

I have integrated twilio for using whatsapp notification and I'm getting this error. What I'm doing wrong. Please help me.
Thank you..

Module

integrations, other

Version

ERPNext: v13.28.0

Frappe Framework: v13.28.0

Twilio Integration: v0.0.1

Installation method

manual install

Relevant log output / Stack trace / Full Error Message.

Traceback (most recent call last):
  File "apps/frappe/frappe/email/doctype/notification/notification.py", line 147, in send
    self.create_system_notification(doc, context)
  File "apps/frappe/frappe/email/doctype/notification/notification.py", line 178, in create_system_notification
    if "{" in subject:
TypeError: argument of type 'NoneType' is not iterable

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.