npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

recime-bot-extension

v4.4.8

Published

Recime bot extension

Downloads

39

Readme

Bot Extension Module

The purpose of this module is to dynamically create rich UI elements for your bot inside smartloop platform.

Getting Started.

Copy and paste the following code inside script block to render a text element:

import Ext from "recime-bot-extension";
const __ = Ext.default;

exports.handler = (context, done) => {
    // context.args
    done(__.text("Hello world"));
};

Button Template.

Button template is supported in Facebook Messenger and Viber. It is possible to create a button template in the following way:

import Ext from "recime-bot-extension";
const __ = Ext.default;

exports.handler = (context, done) => {
    // context.args
    done(__.buttonTemplate("Your Summary", [
        __.postbackButton('Button1', 'about'),
        __.urlButton('Button2', "https://recime.io")
    ]));
};

Viber on the other hand supports row and column and additional properties to customize the look and feel of a button template:

//script block

import Ext from 'recime-bot-extension';
const __ = Ext.default;

exports.handler = (context, done) => {
   
    done(__.buttonTemplate('Text', [
            __.postbackButton('button1', 'about', {
                bgColor : '#e30c2e',
                fgColor : '#fff',
                row : 0,
                column : 0
            }),
             __.postbackButton('Button2', 'start', {
                bgColor : '#76c0d6',
                fgColor : '#fff',
                row : 0,
                column : 1
            })
        ]));
};

The following properties are supported for a Viber button:

| Property | Description | | --- | --- | | bgColor | Background color | | fgColor | Foreground color | | row | Number of columns per carousel content block. (0 - 5) | | column | Number of rows per carousel content block. (0 - 6) | | imageUrl | Link (https://) | | textSize | Font size. (regular, large, small) | | align | Text Alignment (left, center, right) |

Generic Template

Use this extension to dynamically construct "Generic Template" or "Carousel". An example of a generic template that is constructed dynamically from an API result is shown below:

import Ext from "recime-bot-extension";
const __ = Ext.default;

exports.handler = (context, done) => {
  const result = {
      forecast : [
          { 
              id : 1,
              day : new Date().toISOString(),
              temp: '60F',
              icon: 'https://dashboard.smartloop.ai/assets/logo1.png'
          },
          { 
              id : 2,
              day : new Date().toISOString(),
              temp: '40F',
              icon: 'https://dashboard.smartloop.ai/assets/logo1.png'
          }
      ]
  }
  
  const t = __.genericTemplate(result.forecast.map(r => {
    return __.genericItem(r.day, r.temp, r.icon, 
        null,[
            __.postbackButton('Detail', `id-${r.id}`)
        ]);
  }));
  
  done(t);
};

Methods

  • text (text: String, replies: Button[])
  • image (imageUrl: String, replies: Button[])
  • buttonTemplate(title: String, buttons:Button[])
  • postbackButton(title: String, blockName: String) => Button
  • replyButton(title: String, reply: String) => Button /* Use replyButton to capture user Input */
  • urlButton(title: String, url: String) => Button
  • genericTemplate(items)
  • genericItem(title: String, subtitle: String, imageUrl: String, defaultActionUrl: String, buttons)

License

Copyright © 2018 Recime Inc. All rights reserved.