npm package: @gomobile/sdk
Description: TypeScript SDK for the Gomobile communication platform
Latest version: 0.1.1

# @gomobile/sdk

TypeScript SDK for the Gomobile communication platform. Supports voice calls, SMS, AI agents, campaigns, and more.

## Quick Start

```typescript
import { Gomobile } from "@gomobile/sdk"

const gm = new Gomobile({ apiKey: "your-api-key" })
```

Or set `GOMOBILE_API_KEY` environment variable and just:

```typescript
const gm = new Gomobile()
```

## One-Liners

```typescript
// Make a call
await gm.dial("+212600000000").say("Hello!").hangup().execute()

// Send SMS
await gm.send("+212600000000", "Hello from Gomobile")

// Import contacts
await gm.import([{ phone: "+212600000000", name: "Ahmed" }])

// List contacts
const contacts = await gm.contacts.list({ search: "ahmed", limit: 10 })
```

## Campaign Launch

```typescript
const result = await gm.campaigns.quickLaunch({
  name: "January Promo",
  contacts: [
    { phone: "+212600000000", name: "Ahmed" },
    { phone: "+212600000001", name: "Sara" },
  ],
  message: "Hi {{contact.firstName}}, check out our January sale!",
  retries: 2,
  didPool: ["+212520000000"],
})
console.log(result.programId, result.executionId)
```

## Flow Builder

```typescript
const flow = gm.flow("Appointment Reminder")
  .dial({ amd: true })
  .say("Hello {{contact.firstName}}, this is a reminder for your appointment.")
  .dtmf({ "1": "confirm", "2": "cancel" })
  .onDigit("1", b => b.say("Confirmed!").updateContact("status", "confirmed"))
  .onDigit("2", b => b.say("Cancelled.").updateContact("status", "cancelled"))
  .hangup()
  .build()

await gm.flows.create(flow)
```

## AI Agent

```typescript
const agent = await gm.agents.create({
  name: "Support Agent",
  systemPrompt: "You are a helpful customer support agent for ...",
  modelConfig: { provider: "openai", model: "gpt-4o" },
  voiceConfig: { provider: "elevenlabs", voiceId: "voice-id" },
  greeting: "Hello! How can I help you today?",
})
await gm.agents.publish(agent.id)
```

## LLM Integration

```typescript
// Get full documentation for LLM context
const docs = gm.llm.docs()

// Get tool definitions for function calling
const tools = gm.llm.tools()

// Get per-node documentation
const nodeDocs = gm.llm.nodeDocs()
```

## API Modules

| Module | Access | Methods |
|--------|--------|---------|
| Contacts | `gm.contacts` | list, get, create, update, upsert, delete |
| Contact Ingestion | `gm.contactIngestion` | upload, validate, preview, execute |
| Attributes | `gm.attributes` | list, get, create, update, delete |
| Audiences | `gm.audiences` | list, get, create, update, delete, getMembers, addMembers |
| Flows | `gm.flows` | list, get, create, update, delete, duplicate |
| Programs | `gm.programs` | list, get, create, update, delete, launch |
| Executions | `gm.executions` | get, pause, resume, stop |
| Reports | `gm.reports` | getSummary, getCallHistory, getBreakdown, getNodeStats, getBilling, export |
| Call Requests | `gm.callRequests` | list, get, create, cancel |
| Call Reports | `gm.callReports` | getJob, getCall |
| SMS Programs | `gm.smsPrograms` | list, get, create, update, delete, launch |
| Agents | `gm.agents` | list, get, create, update, publish, archive, test |
| Conversations | `gm.conversations` | list, get, start, sendMessage, streamMessage, getMessages, end |
| Knowledge Bases | `gm.knowledgeBases` | list, get, create, update, delete, uploadDocument, listDocuments, deleteDocument |
| DIDs | `gm.dids` | listAvailable |
| Sender IDs | `gm.senderIds` | list, get |
| Dictionaries | `gm.dictionaries` | list, get, create, update, delete |
| Audio | `gm.audio` | upload, list, get, getUrl, delete |
| Recordings | `gm.recordings` | get, getSegment, getFull, getTranscript, delete |
| Credits | `gm.credits` | getBalance, listTransactions |
| Auto-Pause | `gm.autoPause` | list, get, create, update, delete |
| Users | `gm.users` | getProfile, updateProfile |

## Flow Node Types

| Type | Description |
|------|-------------|
| DIAL | Initiate outbound call |
| SAY | Text-to-speech |
| PLAY | Play audio file |
| DTMF | Collect keypress input |
| HANGUP | End call |
| SMS | Send SMS during call |
| UPDATE_CONTACT | Update contact field |
| CONDITION | Branch on condition |
| SET_VARIABLE | Set flow variable |
| CONNECT_AGENT | Connect to AI agent |
| COLLECT_AUDIO | Record caller audio |
| HTTP_REQUEST | Make HTTP request |
| TRANSFER | Transfer call |
| VOICEMAIL_DETECT | Detect voicemail |
| WAIT | Pause execution |
| GOTO | Jump to node |

## License

MIT