1.1.1 • Published 1 year ago

gupshup-integrations v1.1.1

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

Gupshup Integrations Components

Web components built using stencilJS, which can be integrated to any of the front-end frameworks.

Intallation

Need to run following commands in terminal for installing package

    yarn add gupshup-integrations

or

    npm install gupshup-integrations

Usage with react

Add the following code in index.js or index.ts file present in the root of the project.

    import { applyPolyfills, defineCustomElements } from 'gupshup-integrations/loader';

    applyPolyfills().then(() => {
        defineCustomElements(window);
    });

In the file where you want to import the web component, add the following code.

    import "gupshup-integrations";

And the below code is how we can add template messaging component in the file.

    <template-messaging 
       phone-number="91XXXXXXXXXX" 
       type="self-serve" 
       app-name="<app-name>"
       api-key="<api-key"
       whatsapp-no="91XXXXXXXXXX"
    />

Usage with angular

Add the following code in app.module.ts

    import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';

and in the same file under @NgModule section, add the below line

    schemas: [CUSTOM_ELEMENTS_SCHEMA]

In main.ts file, do the following

    import { defineCustomElements } from 'gupshup-integrations/loader';

    defineCustomElements(window);

And the below code is how we can add template messaging component in the file.

    <template-messaging 
       phone-number="91XXXXXXXXXX" 
       type="self-serve" 
       app-name="<app-name>"
       api-key="<api-key"
       whatsapp-no="91XXXXXXXXXX"
    />

Usage with vue

Add the following code in main.js or main.ts file present in the root of the project.

    import { applyPolyfills, defineCustomElements } from 'gupshup-integrations/loader';

    applyPolyfills().then(() => {
        defineCustomElements(window);
    });

And the below code is how we can add template messaging component in the file.

    <template-messaging 
       phone-number="91XXXXXXXXXX" 
       type="self-serve" 
       app-name="<app-name>"
       api-key="<api-key"
       whatsapp-no="91XXXXXXXXXX"
    />

Props

PropdescriptionIs Mandatory ?
type"self-serve" or "enterprise"Yes
phone-numberNumber to which whatsapp message will be sentNo
themeAn object to handle the stylings of each element, details present at the endNo

When type is "self-serve" following props are required

Propdescription
app-nameapp name provided in gupshup
api-keycan be found in gupshup app section
whatsapp-nowhatsapp number provided while creating the app in gupshup

When type is "enterprise" following props are required

Propdescription
usernamegupshup username
passwordgupshup password

Adding themes

Any of the below mentioned attributes and its styles can be passed.

    const styleObject = {
        button: {
            color: "white",
            backgroundColor: "black"
        },
        label: {
            color: "green"
        },
        input: {
            backgroundColor: "antiquewhite"
        },
        dropdown: {
            backgroundColor: "antiquewhite"
        },
        options: {
            backgroundColor: "black",
            color: "white"
        },
        successMessage: {
            color: "green"
        },
        errorMessage: {
            color: "red"
        }
    }
    <template-messaging 
       phone-number="91XXXXXXXXXX" 
       type="self-serve" 
       app-name="<app-name>"
       api-key="<api-key"
       whatsapp-no="91XXXXXXXXXX"
       theme={JSON.stringify(styleObject)}
    />
1.1.1

1 year ago

1.1.0

1 year ago

1.0.11

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago