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
2
Login to Magma
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.4
Save the Agent
After you’ve created your agent,
cd into the project directory and run: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.Required Changes
Required Changes
AGENT_NAMEin thedisplay_informationsectionAGENT_IDin thesettings.event_subscriptions.request_urlsection
What these values mean
What these values mean
AGENT_NAMEis what users will see when they interact with your botAGENT_IDis used to route Slack events to your specific Magma agent
Creating Your Slack App
1
Create New App
- Go to https://api.slack.com/apps
- Click “Create an app”
- 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.json4
Review and Create
Click “Create” to finalize your app
Installing the App
1
Install to Workspace
- Navigate to “OAuth & Permissions”
- Click “Install to Workspace”
- Approve the requested permissions
2
Get Bot Token
After installation, copy the
Bot User OAuth Token3
Set Environment Variable
Add the token to your
.env file:Deployment
- 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!- Open your Slack workspace
- Search for your agent by name
- Start a DM conversation
- 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.