@flowxo/twa
TypeScript icon, indicating that this package has built-in type declarations

1.3.0 • Public • Published

@flowxo/twa

Flow XO Telegram Web App Client

Install

npm install @flowxo/twa

Usage

import { FlowXOClient } from '@flowxo/twa';

clinet = new FlowXOClient({webApp: window.Telegram.WebApp});
client.fetchUserProfile().then((profile) => {
    console.log(profile)
})
client.updateUserProfile({attributes:{new:"attribute"}}).then((updated) => {
    console.log(updated)
})
client.event('myEvent', { my:"data"});

Types

export interface UserProfile {
  id: string;
  name: string;
  firstName: string;
  lastName: string;
  timezone: string;
  country: string;
  locale: string;
  gender: string;
  email: string;
  phone: string;
  company: string;
  firstMessage: string;
  lastMessage: string;
  status: string;
  bot: {
    id: string;
    name: string;
  };
  attributes: Record<string, string>;
  segments: {
    id: string;
    name: string;
  }[];
}

export interface UserProfileUpdate {
  name: string;
  firstName: string;
  lastName: string;
  timezone: string;
  country: string;
  locale: string;
  gender: string;
  email: string;
  phone: string;
  company: string;
  status: string;
  attributes: Record<string, string>;
  segments: {
    add?: string[],
    remove?: string[],
    replace?: string[]
  }[];
}

Package Sidebar

Install

npm i @flowxo/twa

Weekly Downloads

6

Version

1.3.0

License

MIT

Unpacked Size

10.7 kB

Total Files

7

Last publish

Collaborators

  • nathanstults