Skip to content

Commit

Permalink
slack: new module, send message to slack channel
Browse files Browse the repository at this point in the history
  • Loading branch information
arsperger authored and miconda committed Sep 1, 2021
1 parent a2b4f69 commit 74cfb52
Show file tree
Hide file tree
Showing 8 changed files with 1,216 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/modules/slack/Makefile
@@ -0,0 +1,31 @@
#
# Slac client for Kamailio
#
#
# WARNING: do not run this directly, it should be run by the main Makefile

include ../../Makefile.defs
auto_gen=
NAME=slack.so

ifeq ($(CROSS_COMPILE),)
CURL_BUILDER=$(shell \
if pkg-config --exists libcurl; then \
echo 'pkg-config libcurl'; \
else \
which curl-config; \
fi)
endif

ifneq ($(CURL_BUILDER),)
CURLDEFS += $(shell $(CURL_BUILDER) --cflags)
CURLLIBS += $(shell $(CURL_BUILDER) --libs)
else
CURLDEFS+=-I$(LOCALBASE)/include -I$(SYSBASE)/include
CURLLIBS+=-L$(LOCALBASE)/lib -L$(SYSBASE)/lib -lcurl
endif

DEFS+=$(CURLDEFS)
LIBS=$(CURLLIBS)

include ../../Makefile.modules
154 changes: 154 additions & 0 deletions src/modules/slack/README
@@ -0,0 +1,154 @@
Slack Module

Arsen Semenov

<arsperger@gmail.com>

Copyright � 2021 arsperger.com
__________________________________________________________________

Table of Contents

1. Admin Guide

1. Overview
2. Dependencies

2.1. Kamailio Modules
2.2. External Libraries or Applications

3. Parameters

3.1. slack url (str)
3.2. channel (str)
3.3. username (str)
3.4. icon_emogi (str)

4. Functions

4.1. slack_send(format)

List of Examples

1.1. Set slack webhook URL parameter
1.2. Set channel parameter
1.3. Set username parameter
1.4. Set icon_emogi parameter
1.5. slack_send usage

Chapter 1. Admin Guide

Table of Contents

1. Overview
2. Dependencies

2.1. Kamailio Modules
2.2. External Libraries or Applications

3. Parameters

3.1. slack url (str)
3.2. channel (str)
3.3. username (str)
3.4. icon_emogi (str)

4. Functions

4.1. slack_send(format)

1. Overview

This module provides integration with Slack over webhooks. Slack
integration (https://api.slack.com/messaging/webhooks)

It relays on libcurl. library (https://curl.se/libcurl).

2. Dependencies

2.1. Kamailio Modules
2.2. External Libraries or Applications

2.1. Kamailio Modules

The following modules must be loaded before this module:
* none.

2.2. External Libraries or Applications

The following libraries or applications must be installed before
running Kamailio with this module loaded:
* libcurl

3. Parameters

3.1. slack url (str)
3.2. channel (str)
3.3. username (str)
3.4. icon_emogi (str)

3.1. slack url (str)

Slack webhook url

Default value is not set (empty)

Example 1.1. Set slack webhook URL parameter
...
modparam("slack", "slack_url", "https://hooks.slack.com/services/T00000000/B0000
0000/XXXXXXXXXXXXXXXXXXXXXXXX")
...

3.2. channel (str)

Slack channel name

Default value is #kamailio

Example 1.2. Set channel parameter
...
modparam("slack", "channel", "#kamailio")
...

3.3. username (str)

Specify the username for the published message

Default value is webhookbot.

Example 1.3. Set username parameter
...
modparam("slack", "username", "webhookbot")
...

3.4. icon_emogi (str)

specify an emoji (using colon shortcodes, eg. :white_check_mark:) to
use as the profile photo alongside the message.

Default value is :ghost:

Example 1.4. Set icon_emogi parameter
...
modparam("slack", "icon_emogi", ":ghost:")
...

4. Functions

4.1. slack_send(format)

4.1. slack_send(format)

Send a formatted message to slack channel.

The parameters are:
* format - The formatted string to be send.

The parameters can contain pseudo-variables.

This function can be used from ANY_ROUTE.

Example 1.5. slack_send usage
...
slack_send("Hello from Kamailio! caller=$fU;callee=$tU;callid=$ci");
...
4 changes: 4 additions & 0 deletions src/modules/slack/doc/Makefile
@@ -0,0 +1,4 @@
docs = slack.xml

docbook_dir = ../../../../doc/docbook
include $(docbook_dir)/Makefile.module

0 comments on commit 74cfb52

Please sign in to comment.