# Tutorial: Creating a hello world bot

In this guide, we’ll walk through how to set up a simple "Hello World" bot:

1. Configure a Custom OAuth App and generate API credentials.
2. Finding a thread ID to target.
3. Sending your first message.
4. Updating or creating threads.
5. Adding attachments.

***

### 1. Configure a Custom OAuth App

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

Locate **OAuth App** under the **Custom configuration** section, and click **Add**.

<div data-full-width="false"><figure><img src="/files/61cBKaof019OQlnr2WdK" alt="" width="375"><figcaption></figcaption></figure></div>

Enter a Name and a Description for your Custom App, and click **Create app**.

<figure><img src="/files/LYP7GFROIl42RJfJW1Rz" alt="" width="375"><figcaption></figcaption></figure>

Once created, you'll be able to see your app's Client ID and Client Secret, which are your credentials to authenticate with the Glue API.

Reference [OAuth 2.0 authentication](/developers/authentication/oauth-2-0-authentication.md) to use your Client ID and secret to generate your Access Tokens.&#x20;

***

### Step 2. Using the SendMessage Mutation

The core building block for integrations is the `sendMessage` mutation. This is how you post into an existing thread or create a new one.

Here’s the GraphQL definition we'll use:

```graphql
mutation SendMessage($input: SendMessageInput!) {
  sendMessage(input: $input) {
    thread {
      id
      subject
    }
    message {
      id
      text
    }
  }
}
```

***

### Step 3. Finding a Thread ID

Every message needs a target thread, so let's find one.&#x20;

To see what Threads your App can see, we'll start by running this query:

```graphql
query Query {
  threads {
    edges {
      node {
        id
        subject
      }
    }
  }
}
```

Sample response:

```graphql
{
  "data": {
    "threads": {
      "edges": [
        {
          "node": {
            "id": "thr_1234lrtjf6gLyiQrscylCtqpxeG",
            "subject": "🍮 Fans of Flan Chat"
          }
        },
      ]
    }
  }
}
```

Let's store this thread ID for the next step.&#x20;

#### Not seeing any Threads? Let's check Group Membership

The App you just created only has access to Groups it has been added to. By default, your newly created App is not part of any Group, and a Groups query will return no results.&#x20;

This is intentional! Your App shouldn't have access to DMs and private messages in closed groups, after all. You can verify this by specifying `GroupPreview` in your query to see the list of Groups you are not added to.&#x20;

**Adding Apps to Groups**

In Glue, navigate to a group you want to grant access to your App.&#x20;

In the three dot menu in the top right corner, select **Apps** to open the Apps modal.&#x20;

The modal should looks something like this:&#x20;

<figure><img src="/files/0xBceptvAku4nc8J04b5" alt="" width="375"><figcaption></figcaption></figure>

To check to see the Groups the App has been added to, specify Group in your query:

```graphql
query Query {
  workspace {
    groups {
      edges {
        node {
          ... on Group {
            id
            name
          }
        }
      }
    }
  }
}
```

You might see a response like this:

```graphql
{
  "data": {
    "workspace": {
      "groups": {
        "edges": [
          {
            "node": {
              "id": "grp_1234EYwyzBEbFbNeTAJCtFw460",
              "name": "🔍 Bots Welcome!"
            }
          },
          {
            "node": {
              "id": "grp_1234lrnK07Tc6GNv5Npqto7qTqK",
              "name": "🍮 Fans of Flan"
            }
          }
        ]
      }
    }
  }
}
```

To find a thread ID:

* In the Glue app, navigate to the thread.
* Open the menu and select **Copy share link**.
* Paste the link — thread IDs start with `thr_...` and group IDs with `grp_...`.

For example in the following URL:

```
https://app.gluegroups.com/thr_2hSyORgf8VqMLg0ADIvTi9oY6Nk?t=Chat
```

the thread ID is `thr_2hSyORgf8VqMLg0ADIvTi9oY6Nk`.

***

### Step 4. Send Your First Message

Let’s post “Hello World!” into our thread. Replace the `threadID` with the one you copied above.

```json
{
  "input": {
    "threadID": "thr_2hSyORgf8VqMLg0ADIvTi9oY6Nk",
    "message": {
      "text": "Hello World! 👋"
    }
  }
}
```

Run this mutation, and your bot has spoken. 🎉

***

### Step 5. Creating a New Thread

If you know your recipients, you can also start a new thread and send the first message in one go. Just pass a `thread` object instead of a `threadID`.

```json
{
  "input": {
    "thread": {
      "recipients": ["grp_2hSyORgf8VqMLg0ADIvTi9oY6Nk"],
      "subject": "Hello World Bot waves into the workspace!",
      "externalID": "HELLOBOT-INTRO-THREAD"
    },
    "message": {
      "text": "Hello World, I'm the Hello Bot!",
      "externalID": "hellobot-starter-message"
    }
  }
}
```

This creates a new thread in the target group and posts the message as the starter message.

***

### Wrap Up

That’s it :tada: — you now know how to:

* Post a simple “Hello World!” into a thread.
* Create new threads on the fly.

With these basics, you can build bots that announce deploys, report incidents, or connect Glue to your internal systems.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.glue.ai/developers/tutorials/tutorial-creating-a-hello-world-bot.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
