Skip to content
Scalekit Docs
Talk to an Engineer Dashboard

Connect AI agents to 2Chat

Scalekit connector
Open markdown

The 2Chat connector lets your AI agent act in each user's 2Chat account. Each user connects their own 2Chat API key once, and Scalekit sends it with every call, so your agent never handles credentials. It comes with 60 tools.

Tools
60
What they doRead · write · destructive
34 · 20 · 634 read20 write6 destructive
Users sign in with

Setup

  1. Install the SDK

    Terminal window
    npm install @scalekit-sdk/node dotenv
  2. Set your credentials

    Add your Scalekit credentials to your .env file. Find values in app.scalekit.com > Developers > API Credentials.

    .env
    SCALEKIT_ENVIRONMENT_URL=<your-environment-url>
    SCALEKIT_CLIENT_ID=<your-client-id>
    SCALEKIT_CLIENT_SECRET=<your-client-secret>
  3. Create the 2Chat connection

    In AgentKit > Connections, create a 2Chat connection. The name you give it is the connection_name your code passes. See Configure connections.

  4. Authorize a user and make your first call

    quickstart.mts
    import { ScalekitClient } from '@scalekit-sdk/node'
    import 'dotenv/config'
    import { createInterface } from 'node:readline/promises'
    const scalekit = new ScalekitClient(
    process.env.SCALEKIT_ENVIRONMENT_URL,
    process.env.SCALEKIT_CLIENT_ID,
    process.env.SCALEKIT_CLIENT_SECRET,
    )
    const actions = scalekit.actions
    const connector = 'twochat'
    const identifier = 'user_123'
    // Generate an authorization link for the user
    const { link } = await actions.getAuthorizationLink({ connectionName: connector, identifier })
    console.log('Authorize 2Chat:', link)
    const rl = createInterface({ input: process.stdin, output: process.stdout })
    await rl.question('Press Enter after authorizing...')
    rl.close()
    // Make your first call
    const result = await actions.executeTool({
    connector,
    identifier,
    toolName: 'twochat_call_history_list',
    toolInput: {},
    })
    console.log(result)
    Terminal window
    npx tsx quickstart.mts

    Each user opens the link once and enters their 2Chat credentials there. See Authorize a user for the full flow and statuses.

Tools

Pass the exact name to execute_tool
Try in PlaygroundRequest a tool
  • twochat_call_getGet the full details of one phone call.Read-only

    Get Call Details

    Get the full details of one phone call. Returns call metadata, cost breakdown and agent information. Use twochat_call_history_list to find call UUIDs.

    Inputs

    call_uuidstringrequired
    Call record UUID (starts with CDR). Example: CDR8b3e7a1f-6c94-4d52-ae17-5f2b9d4c8e63.
  • twochat_call_history_listList the phone calls made or received through your 2Chat virtual numbers.Read-only

    List Call History

    List the phone calls made or received through your 2Chat virtual numbers. Returns call records with uuid, direction, numbers, duration, status and cost. Use twochat_call_get for one call's full details.

    Inputs

    directionstring
    Only inbound or outbound calls. Any direction when empty. Example: outbound.one of inboundoutbound
    from_numberstring
    Inbound calls: only calls from this number. Example: +12124557899.
    page_numberinteger
    Page number to return. Example: 0.
    to_numberstring
    Outbound calls: only calls to this number. Example: +12124557899.
  • twochat_call_price_getGet the estimated per-minute price of calling a phone number.Read-only

    Get Call Price

    Get the estimated per-minute price of calling a phone number. Returns the destination and price per minute. Use this before placing calls to a new country.

    Inputs

    phone_numberstringrequired
    Destination phone number in international format. Example: +595984153762.
  • twochat_contact_getGet one 2Chat contact by UUID.Read-only

    Get Contact

    Get one 2Chat contact by UUID. Returns the contact's uuid, first_name, last_name, channel_uuid, profile_pic_url and last_updated. Use twochat_contacts_search or twochat_contacts_list to find UUIDs.

    Inputs

    contact_uuidstringrequired
    Contact UUID (starts with CON), from twochat_contacts_list or twochat_contacts_search. Example: CON58147f7c-3756-4ca1-893c-c3360342b424.
  • twochat_contacts_listList the contacts in your 2Chat account, page by page.Read-only

    List Contacts

    List the contacts in your 2Chat account, page by page. Returns contacts with uuid, first_name, last_name, channel_uuid, profile_pic_url and details (phones, emails, addresses). Use this to browse. Use twochat_contacts_search to find a contact by name or number.

    Inputs

    channel_uuidstring
    Only contacts linked to this connected number (WPN...). Example: WPN66037eca-9ad1-4c96-9eff-526a90a48c77.
    page_numberinteger
    Page number to return, starting at 0. Example: 0.
    results_per_pageinteger
    Contacts per page, from 1 to 100. Example: 20.
  • twochat_conversation_assignment_getGet the user and the team a conversation is assigned to.Read-only

    Get Conversation Assignment

    Get the user and the team a conversation is assigned to. Returns the assigned user and team, or null for each when unassigned. Use this before reassigning.

    Inputs

    session_keystringrequired
    The conversation's session_key, from twochat_conversations_search, twochat_whatsapp_conversations_list or a message. Example: WA-WAN8fd3442f-e111-4fed-9323-1824fd7546c9-14085550176.
  • twochat_conversation_tags_getGet the tags a conversation has now, including ones added in the live chat or by flows.Read-only

    Get Conversation Tags

    Get the tags a conversation has now, including ones added in the live chat or by flows. Returns the conversation's tags with uuid, name and color. Use twochat_conversation_tag_add or twochat_conversation_tag_remove to change them.

    Inputs

    session_keystringrequired
    The conversation's session_key, from twochat_conversations_search, twochat_whatsapp_conversations_list or a message. Example: WA-WAN8fd3442f-e111-4fed-9323-1824fd7546c9-14085550176.