Webhooks

Overview

Webhooks allow you to send messages and create threads inside of Glue by making a simple POST to the webhook endpoint. Here is a basic example that sends a message to the group chat for the group with ID grp_2hSyORgf8VqMLg0ADIvTi9oY6Nk.

curl -s -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "target": "grp_2hSyORgf8VqMLg0ADIvTi9oY6Nk",
    "text": "New bug reported!"
  }' \
  "https://app.gluegroups.com/webhook/wbh_123.../456..."

Create a webhook

In Glue, navigate to the Apps section of the workspace settings.

Locate Webhook in the list and click Add.

Enter a name and description, and then click Create.

After creating, you can see and copy the URL for the webhook.

Obtain a target ID

In order to send a webhook, you'll need the ID of a group or thread.

To do this, navigate to the appropriate group or thread, open the menu, and then select Copy share link.

Paste the link and then look for an identifier in the URL. Group IDs start with grp_... and thread IDs start with thr_...

If you are using the app from your browser, you can also look for these values in the URL bar. Note that at times, multiple IDs may be present depending on what you're viewing.

In this case, you can see the group ID of grp_2hSyORgf8VqMLg0ADIvTi9oY6Nk in the following URL:

https://app.gluegroups.com/grp_2hSyORgf8VqMLg0ADIvTi9oY6Nk?t=Chat

Use this value in the target field of your webhook payload.

Webhook payload

Here are the fields that you can send to the webhook endpoint. These fields should be sent as JSON with Content-Type application/json .

Field
Description

text

Required. The text of the message to send. By default, this is treated as markdown.

target

Required. The ID of a thread or group to send to.

For a group, a message will be sent to the chat unless a threadSubject is specific - in this case a thread will be created in the group instead.

For a thread, a message will be sent to the thread. When specifying a thread target, you cannot create threads by specifying a threadSubject. Note: For the workspace wide, "General" group, the workspace id (wks_...) functions as the group ID. Use the full ID including "wks_".

threadSubject

If specified, a thread will be created instead of just sending a message.

The target must be a group if a subject is specified.

uniqueBy

Specify a value here to be able to update this message after it is created. If you call the webhook again with the same value, it will update the existing message instead of generating a new one. The uniqueBy value should be unique for the the thread or chat that the message is sent to.

threadBy

If specified, the webhook will send follow up messages to created threads with the same value. The first message will create the thread and then the following messages will be appending to that thread.

Examples

At a minimum, you must specify a target and text to send a message via a webhook.

The additional examples below demonstrate more advanced functionality.

Example: Sending and updating a message

To send a message, simply provide a target field with a thread or group ID and a text field with the message text. Optionally, you can pass a uniqueBy value that you can use to update the message by calling the webhook again with the same value.

To update the previously sent message, call the webhook again with the same uniqueBy value.

To generate a new message, simply provide a new uniqueBy value, or omit the uniqueBy value if you do not need to update the message.

Example: Formatting messages

Glue uses markdown to format messages. The following features are supported:

  • Text styling

    • Bold

    • Italics

    • Strikethrough

  • Links

  • User mentions

  • Inline code

  • Code blocks

  • Blockquotes

  • Paragraphs

  • Lists

    • Ordered

    • Unordered

These features are described in detail below.

1. Text Styling

Bold

To make text bold, wrap it with two asterisks (**) or two underscores (__). For example:

Displays as:

Italics

To italicize text, wrap it with one asterisk (*) or one underscore (_). For example:

Displays as:

Strikethrough

To strikethrough text, wrap it with two tildes (~~). For example:

Displays as:

Bold and Italics Combined

You can combine bold and italics for even more emphasis. For example:

Displays as:

2. Links

To create a hyperlink, use square brackets [ ] to set the text and parentheses ( ) to set the URL. For example:

Displays as:

User Mentions

To mention a user in our chat app, use the following format:

Displays as:

3. Inline Code

To include inline code, wrap your text with backticks (`). For example:

Displays as:

4. Code Blocks

For longer code snippets, use triple backticks (```) before and after your code block. You can also specify the language for syntax highlighting. For example:

Displays as:

5. Blockquotes

To create a blockquote, use the greater than (>) symbol followed by a space. For example:

Displays as:

6. Paragraphs

To create paragraphs, simply separate your text with one or more blank lines. For example:

Displays as:

7. Lists

Unordered Lists

To create an unordered list, use -, *, or + followed by a space. For example:

Displays as:

Ordered Lists

To create an ordered list, use numbers followed by a period and a space. For example:

Displays as:

Example: Creating threads

To create a thread instead of just sending a message, specify a threadSubject and ensure that the target value is a group. This will result in a thread created in the group with the subject of threadSubject and starter message from text. The threadBy and uniqueBy values are optional values that let us update this message (uniqueBy) and post more messages to the thread (threadBy).

When you specify a threadBy value, you can send follow up messages to the thread by calling the webhook again with the same threadBy value. In this case we're using the value BUG268. The value is normally and identifier from the external system that is generating the message.

Because we specified a uniqueBy value for the starter message, we can call the webhook again to update that starter message (rather than send a new message). Here we're using "uniqueBy": "BUG268-starter-message" which is the value we passed in the first webhook to start the thread.

To create a different thread, send a new threadBy value or, if the thread by value is omitted, a new thread will alsways be created.

Example: Attachments

To send a message with an attachment, start by uploading the attachment. To do this, append /attachment to the end of your webhook URL and make a PUT request. The body of the request should contain the raw contents of the file you are uploading.

The following headers are required:

  1. Content-Length: The length of the file/body of the request

  2. Content-MD5: The MD5 computed from the contents of the file

  3. X-File-Name: The name of the file to be uploaded.

A PUT request is required. POST is not accepted. Also multipart/form-data is not accepted.

You will receive a JSON response back with the id of the file that was uploaded.

To send a message with the uploaded file attached, simply include an attachments field with an array containing the file IDs you want to attach. You can attach up to 10 files per message.

Coming soon

  • Automatic link parsing

  • Link previews

  • Option to send plain text instead of markdown for the text field

Last updated

Was this helpful?