-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
50be23e
commit 9c16932
Showing
3 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
rocket_connect/utils/asterisk2rocketchat/asterisk2rocketchat.py
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,62 @@ | ||
import asyncio | ||
|
||
import requests | ||
from panoramisk import Manager | ||
|
||
# | ||
# AMI CONF in ASTERISK | ||
# | ||
# add this below, adapting permit and deny accordingly | ||
# to /etc/asterisk/manager_custom.conf | ||
# [queue_alert_user] | ||
# secret=queue_alert_pwd | ||
# deny=0.0.0.0/0.0.0.0 | ||
# permit=0.0.0.0/0.0.0.0 | ||
# read = all | ||
# eventfilter=Event: QueueCallerAbandon | ||
|
||
manager = Manager( | ||
loop=asyncio.get_event_loop(), | ||
host="localhost", | ||
username="queue_alert_user", | ||
secret="queue_alert_pwd", | ||
) | ||
# | ||
# you need to create the above webhook in Rocket.Chat | ||
# and paste the Script from incoming.webhook.Rocket.Chat.js | ||
# this is the webhook url | ||
incoming_endpoint = ( | ||
"http://localhost:3000/hooks/" | ||
+ "620e9615701ffe000986a1c8/8fRecuRk5Muyf3mtsGtDGFgJDkZ8wuEjm5qNqNFqxuCLaErE" | ||
) | ||
|
||
# this is an example. | ||
# you can filter the callback by different method | ||
# or inside the method, using message.event | ||
# you can also duplicate the code below, and send different | ||
# events to differents webhooks / channels / users | ||
|
||
|
||
@manager.register_event("QueueCallerAbandon") | ||
def callback(manager, message): | ||
if "FullyBooted" not in message.event: | ||
"""This will print every event, but the FullyBooted events as these | ||
will continuously spam your screen""" | ||
# event = message.event | ||
# if event == "QueueCallerAbandon": | ||
# if event == "OtherEvent": | ||
payload = dict(message.items()) | ||
print(payload) | ||
requests.post(incoming_endpoint, json=payload) | ||
|
||
|
||
def main(): | ||
manager.connect() | ||
try: | ||
manager.loop.run_forever() | ||
except KeyboardInterrupt: | ||
manager.loop.close() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
21 changes: 21 additions & 0 deletions
21
rocket_connect/utils/asterisk2rocketchat/incoming.webhook.Rocket.Chat.js
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,21 @@ | ||
/* exported Script */ | ||
/* globals console, _, s */ | ||
|
||
class Script { | ||
/** | ||
* @params {object} request | ||
*/ | ||
process_incoming_request({ request }) { | ||
return { | ||
content:{ | ||
text: [ | ||
':no_mobile_phones: *Abandoned Call*', | ||
':passport_control: *Queue*: ' + request.content.Queue, | ||
':calling: *Caller Number:*: ' + request.content.CallerIDNum, | ||
':alarm_clock: *Hold Time*: ' + request.content.HoldTime + 's', | ||
':vertical_traffic_light: *Entered at position* ' + request.content.OriginalPosition + '. Abandoned at ' + request.content.Position, | ||
].join('\n') | ||
} | ||
}; | ||
} | ||
} |
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,2 @@ | ||
panoramisk==1.4 | ||
mysql-connector-python==3.6.1 |