Skip to main content

Action Menu Module

The @credo-ts/action-menu package implements the DIDComm Action Menu Protocol, allowing agents to present interactive menus to users.

Installation

npm install @credo-ts/action-menu

Registration

import { Agent } from '@credo-ts/core'
import { ActionMenuModule } from '@credo-ts/action-menu'

const agent = new Agent({
  // ... config
  modules: {
    actionMenu: new ActionMenuModule(),
  },
})

What It Provides

The Action Menu module enables:
  • Present interactive menus to connected agents
  • Receive menu selections from users
  • Dynamic menu options based on context
  • Multi-step workflows via nested menus

Usage

Sending a Menu

const { menu } = await agent.modules.actionMenu.sendMenu({
  connectionId: connection.id,
  menu: {
    title: 'Main Menu',
    description: 'Please select an option',
    options: [
      {
        name: 'option-1',
        title: 'Request Credential',
        description: 'Request a new credential',
      },
      {
        name: 'option-2',
        title: 'View Profile',
        description: 'View your profile information',
      },
    ],
  },
})

Receiving Menu Selections

import { ActionMenuEventTypes } from '@credo-ts/action-menu'

agent.events.on(ActionMenuEventTypes.ActionMenuStateChanged, async (event) => {
  if (event.payload.actionMenuRecord.state === ActionMenuState.Done) {
    const selection = event.payload.actionMenuRecord.selection
    console.log('User selected:', selection)
    
    // Handle the selection
    if (selection === 'option-1') {
      // Initiate credential issuance
    }
  }
})

Use Cases

  • Credential Issuance - Present options for different credential types
  • Service Selection - Allow users to choose from available services
  • Workflow Navigation - Guide users through multi-step processes
  • Settings Management - Provide menu-based settings configuration
interface ActionMenu {
  title: string
  description?: string
  options: ActionMenuOption[]
}

interface ActionMenuOption {
  name: string
  title: string
  description?: string
  disabled?: boolean
}

See Also

Build docs developers (and LLMs) love