UltraMSG

This is the UltraMSG integration for getting started made by Trustnet.

Utilities · UltraMSG

Details

IDUltraMSG
ProviderUltraMSG
CategoryUtilities
From Version6.0.0
Docker Imagedemisto/python3:3.12.8.3296088
Supported ModulesAgentix XSIAM

README

This is the UltraMSG integration for getting started made by Trustnet

Configure UltraMSG in Cortex

Parameter Description Required
Token When creating an instance, you’ll get a token Example: ty37deadbeef37xx True
Instance When creating an instance, you’ll get an instance id. Example: instance12345 True

Commands

You can execute these commands from the CLI, as part of an automation, or in a playbook.
After you successfully execute a command, a DBot message appears in the War Room with the command details.

send-whatsapp


Send WhatsApp Message

Base Command

send-whatsapp

Input

Argument Name Description Required
id Phone Number or Group ID. Example: +972501234567. Required
text Message Body. Required

Context Output

There is no context output for this command.

Configuration parameters

  • token — Token (required)
  • instance — Instance (required)

Commands (1)

  • send-whatsapp

    Send WhatsApp Message

import demistomock as demisto  # noqa: F401
import requests
from CommonServerPython import *  # noqa: F401


def send_whatsapp(token, instance, t_id, text):
    try:
        payload = "token={token}&to={t_id}&body={text}&priority=1"
        headers = {"content-type": "application/x-www-form-urlencoded"}
        requests.post(f"api.ultramsg.com/{instance}/messages/chat?{payload}", headers=headers)
        return_results("Task send_whatsapp successfully added to project")
    except Exception:
        return_results("Task creation failed")


def test_module(token, instance):
    try:
        headers = {"content-type": "application/x-www-form-urlencoded"}
        url_path = f"api.ultramsg.com/{instance}/instance/status?token={token}"
        res = requests.get(url_path, headers=headers)
        data_json = res.json()
        status = data_json["status"]["accountStatus"]["substatus"]
        if status == "connected":
            return "ok"
        else:
            return "Instance Status is: '" + status + "' Should be 'connected'.Please check your instance"
    except Exception:
        return "Please check you'r instance"


def main():
    params = demisto.params()
    token = params.get("token")
    instance = params.get("instance")
    try:
        if demisto.command() == "send-whatsapp":
            t_id = demisto.args()["id"]
            text = demisto.args()["text"]
            send_whatsapp(token, instance, t_id, text)
        elif demisto.command() == "test-module":
            return_results(test_module(token, instance))
    except Exception as err:
        return_error(str(err))


if __name__ in ["__builtin__", "builtins", "__main__"]:
    main()