Skip to content

Latest commit

 

History

History
121 lines (102 loc) · 6.21 KB

File metadata and controls

121 lines (102 loc) · 6.21 KB

Update an Integration

To update an integration, the callee needs to have the permissions manage-incoming-integrations AND manage-own-incoming-integrations permissions to be able to update incoming integrations and manage-outgoing-integrations AND manage-own-outgoing-integrations to be able to update outgoing integrations.

HTTP MethodURLRequires Auth
PUT/api/v1/integrations.updateyes

Body Parameters

KeyExample ValueDescription
type*webhook-outgoingThe type of integration to update, webhook-outgoing and webhook-incoming are supported.
name*GuggyThe name of the integration only is shown in the Administration area.
enabled*trueWhether this integration should be enabled or not.
username*rocket.catThe username who to post this the messages as.
channel*#generalThe channel, group, or @username. Can also be all_public_channels, all_private_groups, or all_direct_messages. Comma separated for more than one.
scriptEnabled*falseWhether the script should be enabled.
integrationId*ncjK_idsnmsThe integration ID that you want to update.
urls['http://text2gif.guggy.com/guggify']The urls to call whenever this integration is triggered.
eventsendMessage

This field is required only for outgoing integration.

The type of event can be any of these: sendMessage, fileUploaded, roomArchived, roomCreated, roomJoined, roomLeft, userCreated.

triggerWords!guggySpecific words, separated by commas, which should trigger this integration.
aliasGuggyThe alias which should be applied to messages when this integration is processed.
avatarhttp://res.guggy.com/logo_128.pngThe logo to apply to the messages that this integration sends.
emoji:ghost:The emoji which should be displayed as the avatar for messages from this integration.
token8DFS89DMKLWENIf your integration requires a special token from the server (api key), use this.
scriptIntegrationsScript triggered when this integration is triggered.
targetChanneltargeted channelThe channel where messages will be sent to.
target_urlopen.rocket.chatThe target url to set.

Example Payload

{
    "type": "webhook-incoming",
    "name": "Test",
    "enabled": false,
    "username": "rocket.cat",
    "scriptEnabled": false,
    "channel": "#test",
    "integrationId": "x3tPXa9XXRqW6Xp2M"
}

Example Call

curl -L -X PUT 'http://localhost:3000/api/v1/integrations.update' \
-H 'X-User-Id: d26x6zSkaPSe5gCyy' \
-H 'X-Auth-Token: Zu-Z6eKzIIz7MCCRGeHi29bYkXZCJ4SxFC0JAasqm92' \
-H 'Content-Type: application/json' \
--data-raw '{
    "type": "webhook-incoming",
    "name": "Test",
    "enabled": false,
    "username": "rocket.cat",
    "scriptEnabled": false,
    "channel": "#test",
    "integrationId": "x3tPXa9XXRqW6Xp2M"
}'

Example Response

Success

{
    "integration": {
        "_id": "x3tPXa9XXRqW6Xp2M",
        "enabled": false,
        "channel": [
            "#test"
        ],
        "username": "rodriq",
        "name": "Test",
        "alias": "Jim",
        "avatarUrl": "",
        "emoji": ":ghost:",
        "scriptEnabled": false,
        "script": "console.log(\"MANNNNN ---------------------------------------------------------\")",
        "type": "webhook-incoming",
        "token": "XYsrkngRr5PBkWhCqJWk5ZfKzQoxSv4QhxkK5trSgJENwbRL",
        "userId": "d26x6zSkaPSe5gCyy",
        "_createdAt": "2021-10-22T14:48:46.025Z",
        "_createdBy": {
            "_id": "d26x6zSkaPSe5gCyy",
            "username": "rodriq"
        },
        "_updatedAt": "2021-10-22T16:08:39.843Z",
        "_updatedBy": {
            "_id": "d26x6zSkaPSe5gCyy",
            "username": "rodriq"
        }
    },
    "success": true
}

Error

Any of the following errors can occur on the endpoint.

  • Authorization: Requires an authentication token for the request to be made.
  • Missing Key: Triggers when the endpoint is called without any required endpoint.
  • No integration Found: You get this error when the integration you're trying to update is not found.

{% tabs %} {% tab title=" Authorization" %}

{
    "success": false,
    "error": "unauthorized"
}

{% endtab %}

{% tab title="Missing Key" %}

{
    "success": false,
    "error": "Match error: Missing key '<key name>'"
}

{% endtab %}

{% tab title="No Integration Found" %}

{
    "success": false,
    "error": "No integration found."
}

{% endtab %} {% endtabs %}

Change Log

Version Description
3.4.0 Added