Estimated time to complete: 5 minutes

Overview

Welcome to Magma! 🌋

This template will help you create:

  • An AI agent hosted on Magma
  • A Slack app connected to your agent
  • Interactive chat with your agent right in your Slack workspace

Prerequisites:

  • A Slack workspace where you have admin permissions

Getting Started

First, we need the Magma CLI to clone the Slack DM template, and save it to your Magma account.

1

Install the CLI

npm install -g @pompeii-labs/cli
2

Login to Magma

magma login
3

Use the Slack DM Template

The magma init command is how you create a new Magma agent project. If you provide the -t flag, it will use the template you specify. Here, we’re using the slack-dm template.

magma init -t slack-dm <agent-name>
4

Save the Agent

After you’ve created your agent, cd into the project directory and run:

magma save
5

Update the Slack manifest.json

Running magma save will return your AGENT_ID which you will need to update the settings.event_subscriptions.request_url. The manifest.json file can be found inside of your slack agent container.

Slack App Setup

Manifest Configuration

The manifest.json file in your project root contains all the necessary Slack app configurations. You only need to update two values.

Creating Your Slack App

1

Create New App

  1. Go to https://api.slack.com/apps
  2. Click “Create an app”
  3. Select “From a manifest”
2

Select Workspace

Choose the workspace where you want to install the app

3

Upload Manifest

Replace the default manifest with the contents of your manifest.json

4

Review and Create

Click “Create” to finalize your app

Installing the App

1

Install to Workspace

  1. Navigate to “OAuth & Permissions”
  2. Click “Install to Workspace”
  3. Approve the requested permissions
2

Get Bot Token

After installation, copy the Bot User OAuth Token

3

Set Environment Variable

Add the token to your .env file:

SLACK_BOT_TOKEN=xoxb-your-token-here

Deployment

This will:

  • Deploy your agent to Magma’s infrastructure
  • Set up the webhook endpoint for Slack events
  • Enable real-time communication between Slack and your agent

After deployment, go to your Slack App settings > Event Subscriptions and verify that the Request URL shows as “Verified”. If it’s not verified, double-check your AGENT_ID in the manifest.json.

Testing Your Agent

Use cmd+t (Mac) or ctrl+t (Windows) to quickly search for your bot in Slack!

  1. Open your Slack workspace
  2. Search for your agent by name
  3. Start a DM conversation
  4. Send a message to test the connection

If you run into any issues, use magma logs to view your agent’s logs and debug the problem.