> For the complete documentation index, see [llms.txt](https://guilded-js.gitbook.io/api-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://guilded-js.gitbook.io/api-docs/create-a-basic-bot.md).

# Create a basic bot

If you haven't created the bot application on Guilded or copied your bots auth token follow the below.

{% content-ref url="/pages/Ii8c2MzTJyXEwoRSnd3J" %}
[Setting up a Guilded bot](/api-docs/setting-up-a-guilded-bot.md)
{% endcontent-ref %}

## Create the bots main file

Let's create an `index.js` or `index.ts` file so that we can have our bot login!

{% tabs %}
{% tab title="JavaScript" %}
{% code overflow="wrap" %}

```javascript
// index.js
// Import the guilded client
const { Client } = require('guilded.js');

/**
 * Create an instance of the client class
 * To be even more secure use environment variables or a config.json!
 */
const client = new Client({
  token: 'your-super-secret-bot-token',
});

// When the bot connects successfully, log to the console.
client.on('ready', () => {
  console.log(`Bot is successfully logged in as ${client.user.name}`);
});

// Login to Guilded
client.login();

```

{% endcode %}
{% endtab %}

{% tab title="TypeScript" %}

```typescript
// index.ts
// Import the guilded client
import { Client } from 'guilded.js';

/**
 * Create an instance of the client class
 * To be even more secure use environment variables or a config.json!
 */
const client = new Client({
  token: 'your-super-secret-bot-token',
});

// When the bot connects successfully, log to the console.
client.on('ready', () => {
  console.log(`Bot is successfully logged in as ${client.user?.name}`);
});

// Login to Guilded
client.login();
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://guilded-js.gitbook.io/api-docs/create-a-basic-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.
